cmd/compile: fix MIPS SGTconst-with-shift rules
authorCherry Zhang <cherryyz@google.com>
Wed, 26 Dec 2018 00:36:25 +0000 (19:36 -0500)
committerMichael Stapelberg <stapelberg@debian.org>
Thu, 24 Jan 2019 07:23:06 +0000 (07:23 +0000)
commit59988e3506c633cf54bf0c8e04b22fed7bf4fd86
tree77c0173c9692073d712b8e560e162e6d95d35d27
parent858b2d3a54fcdd67c62be178425bcb1506a0f9e4
cmd/compile: fix MIPS SGTconst-with-shift rules

(SGTconst [c] (SRLconst _ [d])) && 0 <= int32(c) && uint32(d) <= 31 && 1<<(32-uint32(d)) <= int32(c) -> (MOVWconst [1])

This rule is problematic. 1<<(32-uint32(d)) <= int32(c) meant to
say that it is true if c is greater than the largest possible
value of the right shift. But when d==1, 1<<(32-1) is negative
and results in the wrong comparison.

Rewrite the rules in a more direct way.

Fixes #29402.

Change-Id: I5940fc9538d9bc3a4bcae8aa34672867540dc60e

Gbp-Pq: Name 0005-fix-MIPS-SGTconst-with-shift-rules.patch
src/cmd/compile/internal/ssa/gen/MIPS.rules
src/cmd/compile/internal/ssa/gen/MIPS64.rules
src/cmd/compile/internal/ssa/rewriteMIPS.go
src/cmd/compile/internal/ssa/rewriteMIPS64.go
test/fixedbugs/issue29402.go [new file with mode: 0644]