Skip to content

Commit

Permalink
[release-branch.go1.18] cmd/compile: fix boolean comparison on RISCV64
Browse files Browse the repository at this point in the history
Following CL 421457, for RISCV64.

May fix RISCV64 builds.

Updates #52788.
Updates #53397.

Change-Id: Ifc34658703d1e8b97665e7b862060152e3005d71
Reviewed-on: https://go-review.googlesource.com/c/go/+/405553
Reviewed-by: David Chase <[email protected]>
Run-TryBot: Cherry Mui <[email protected]>
Reviewed-on: https://go-review.googlesource.com/c/go/+/421460
TryBot-Result: Gopher Robot <[email protected]>
Reviewed-by: Dmitri Shuralyov <[email protected]>
Run-TryBot: Dmitri Shuralyov <[email protected]>
Reviewed-by: Cherry Mui <[email protected]>
  • Loading branch information
cherrymui authored and thanm committed Aug 8, 2022
1 parent 276a7bf commit 21befdc
Show file tree
Hide file tree
Showing 2 changed files with 50 additions and 3 deletions.
6 changes: 5 additions & 1 deletion src/cmd/compile/internal/ssa/gen/RISCV64.rules
Original file line number Diff line number Diff line change
Expand Up @@ -583,7 +583,7 @@
(AtomicOr32 ...) => (LoweredAtomicOr32 ...)

// Conditional branches
(If cond yes no) => (BNEZ cond yes no)
(If cond yes no) => (BNEZ (MOVBUreg <typ.UInt64> cond) yes no)

// Optimizations

Expand Down Expand Up @@ -621,6 +621,10 @@
(MOVWstore [off] {sym} ptr (MOVDconst [0]) mem) => (MOVWstorezero [off] {sym} ptr mem)
(MOVDstore [off] {sym} ptr (MOVDconst [0]) mem) => (MOVDstorezero [off] {sym} ptr mem)

// Boolean ops are already extended.
(MOVBUreg x:((SEQZ|SNEZ) _)) => x
(MOVBUreg x:((SLT|SLTU) _ _)) => x

// Avoid sign/zero extension for consts.
(MOVBreg (MOVDconst [c])) => (MOVDconst [int64(int8(c))])
(MOVHreg (MOVDconst [c])) => (MOVDconst [int64(int16(c))])
Expand Down
47 changes: 45 additions & 2 deletions src/cmd/compile/internal/ssa/rewriteRISCV64.go

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

0 comments on commit 21befdc

Please sign in to comment.