Skip to content

Commit

Permalink
cmd/compile: fix boolean comparison on RISCV64
Browse files Browse the repository at this point in the history
Following CL 405114, for RISCV64.

May fix RISCV64 builds.

Updates #52788.

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]>
  • Loading branch information
cherrymui committed May 12, 2022
1 parent f269d90 commit d6e6140
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 d6e6140

Please sign in to comment.