Skip to content

Commit 2952fe4

Browse files
wdvxdr1123mengzhuo
authored andcommitted
cmd/compile: use correct type in riscv64 late lower pass
The right-hand side SLLI always contains valid content in the high 32 bits, so we should use the 64 bit integer type. Using wrong type may lead to wrong optimizations in cse pass. Should fix x/text test failures. Change-Id: I972dd913b8fb238d180bb12f8b1801adc8503fc0 Reviewed-on: https://go-review.googlesource.com/c/go/+/443875 Reviewed-by: Dmitri Goutnik <[email protected]> Reviewed-by: Cherry Mui <[email protected]> TryBot-Result: Gopher Robot <[email protected]> Run-TryBot: Wayne Zuo <[email protected]> Reviewed-by: David Chase <[email protected]>
1 parent 85196fc commit 2952fe4

File tree

2 files changed

+39
-45
lines changed

2 files changed

+39
-45
lines changed

src/cmd/compile/internal/ssa/_gen/RISCV64latelower.rules

Lines changed: 9 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -3,15 +3,15 @@
33
// license that can be found in the LICENSE file.
44

55
// Fold constant shift with extension.
6-
(SRAI <t> [c] (MOVBreg x)) && c < 8 => (SRAI [56+c] (SLLI <t> [56] x))
7-
(SRAI <t> [c] (MOVHreg x)) && c < 16 => (SRAI [48+c] (SLLI <t> [48] x))
8-
(SRAI <t> [c] (MOVWreg x)) && c < 32 => (SRAI [32+c] (SLLI <t> [32] x))
9-
(SRLI <t> [c] (MOVBUreg x)) && c < 8 => (SRLI [56+c] (SLLI <t> [56] x))
10-
(SRLI <t> [c] (MOVHUreg x)) && c < 16 => (SRLI [48+c] (SLLI <t> [48] x))
11-
(SRLI <t> [c] (MOVWUreg x)) && c < 32 => (SRLI [32+c] (SLLI <t> [32] x))
12-
(SLLI <t> [c] (MOVBUreg x)) && c <= 56 => (SRLI [56-c] (SLLI <t> [56] x))
13-
(SLLI <t> [c] (MOVHUreg x)) && c <= 48 => (SRLI [48-c] (SLLI <t> [48] x))
14-
(SLLI <t> [c] (MOVWUreg x)) && c <= 32 => (SRLI [32-c] (SLLI <t> [32] x))
6+
(SRAI [c] (MOVBreg x)) && c < 8 => (SRAI [56+c] (SLLI <typ.Int64> [56] x))
7+
(SRAI [c] (MOVHreg x)) && c < 16 => (SRAI [48+c] (SLLI <typ.Int64> [48] x))
8+
(SRAI [c] (MOVWreg x)) && c < 32 => (SRAI [32+c] (SLLI <typ.Int64> [32] x))
9+
(SRLI [c] (MOVBUreg x)) && c < 8 => (SRLI [56+c] (SLLI <typ.UInt64> [56] x))
10+
(SRLI [c] (MOVHUreg x)) && c < 16 => (SRLI [48+c] (SLLI <typ.UInt64> [48] x))
11+
(SRLI [c] (MOVWUreg x)) && c < 32 => (SRLI [32+c] (SLLI <typ.UInt64> [32] x))
12+
(SLLI [c] (MOVBUreg x)) && c <= 56 => (SRLI [56-c] (SLLI <typ.UInt64> [56] x))
13+
(SLLI [c] (MOVHUreg x)) && c <= 48 => (SRLI [48-c] (SLLI <typ.UInt64> [48] x))
14+
(SLLI [c] (MOVWUreg x)) && c <= 32 => (SRLI [32-c] (SLLI <typ.UInt64> [32] x))
1515

1616
// Shift by zero.
1717
(SRAI [0] x) => x

src/cmd/compile/internal/ssa/rewriteRISCV64latelower.go

Lines changed: 30 additions & 36 deletions
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

0 commit comments

Comments
 (0)