]> Cypherpunks repositories - gostls13.git/commit
[release-branch.go1.11] cmd/compile: fix MIPS SGTconst-with-shift rules
authorCherry Zhang <cherryyz@google.com>
Wed, 26 Dec 2018 00:36:25 +0000 (19:36 -0500)
committerKatie Hockman <katie@golang.org>
Fri, 4 Jan 2019 20:43:18 +0000 (20:43 +0000)
commitb2c472f91e9ad8e8a302ad9fc963d4875bdfbae0
treec826daf9b3403c6454c55a0a39600e9c3d7aa89d
parent61b8817b8ea28fd56649db38b6f3499a0874e2f9
[release-branch.go1.11] 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.

Updates #29402.
Fixes #29442.

Change-Id: I5940fc9538d9bc3a4bcae8aa34672867540dc60e
Reviewed-on: https://go-review.googlesource.com/c/155798
Run-TryBot: Cherry Zhang <cherryyz@google.com>
TryBot-Result: Gobot Gobot <gobot@golang.org>
Reviewed-by: Keith Randall <khr@golang.org>
(cherry picked from commit 6a64efc25004175e198e75191e215a7b1a08a2fa)
Reviewed-on: https://go-review.googlesource.com/c/155799
Reviewed-by: David Chase <drchase@google.com>
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]