Skip to content

Commit 4b61875

Browse files
Jeff LawJeffreyALaw
authored andcommitted
[RISC-V][PR target/123283] Wrap naked REG operands with a USE.
I was in the process of testing this patch when Andreas filed PR123283. What's going on is we have patterns in sync.md which have naked operands: (define_insn "subword_atomic_fetch_strong_<atomic_optab>" [(set (match_operand:SI 0 "register_operand" "=&r") ;; old value at mem (match_operand:SI 1 "memory_operand" "+A")) ;; mem location (set (match_dup 1) (unspec_volatile:SI [(any_atomic:SI (match_dup 1) (match_operand:SI 2 "arith_operand" "rI")) ;; value for op (match_operand:SI 3 "const_int_operand")] ;; model UNSPEC_SYNC_OLD_OP_SUBWORD)) (match_operand:SI 4 "arith_operand" "rI") ;; mask (match_operand:SI 5 "arith_operand" "rI") ;; not_mask (clobber (match_scratch:SI 6 "=&r")) ;; tmp_1 (clobber (match_scratch:SI 7 "=&r"))] ;; tmp_2 Note carefully operands #4 and #5 and the fact they are a toplevel construct as opposed to being an operand of another RTX. That's a no-no. They need to be wrapped with a USE. I spot-checked sync.md and found a few more instances. Fixing the set I found fixed the testsuite regressions I was seeing and also fixes the mis-compilation of libgo. Bootstrapped and regression tested on my BPI and Pioneer. It's also clean on the riscv64-elf and riscv32-elf targets in my tester. PR target/123283 gcc/ * config/riscv/sync.md (subword_atomic_fetch_strong_nand): Add USEs for naked operands that might be pseudos. (subword_atomic_fetch_strong_<atomic_optab>): Likewise. (subword_atomic_exchange_strong): Likewise. (subword_atomic_cas_strong): Likewise.
1 parent 8e649a5 commit 4b61875

File tree

1 file changed

+9
-9
lines changed

1 file changed

+9
-9
lines changed

gcc/config/riscv/sync.md

Lines changed: 9 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -210,8 +210,8 @@
210210
(match_operand:SI 2 "arith_operand" "rI")) ;; value for op
211211
(match_operand:SI 3 "const_int_operand")] ;; model
212212
UNSPEC_SYNC_OLD_OP_SUBWORD))
213-
(match_operand:SI 4 "arith_operand" "rI") ;; mask
214-
(match_operand:SI 5 "arith_operand" "rI") ;; not_mask
213+
(use (match_operand:SI 4 "arith_operand" "rI")) ;; mask
214+
(use (match_operand:SI 5 "arith_operand" "rI")) ;; not_mask
215215
(clobber (match_scratch:SI 6 "=&r")) ;; tmp_1
216216
(clobber (match_scratch:SI 7 "=&r"))] ;; tmp_2
217217
"TARGET_ZALRSC && TARGET_INLINE_SUBWORD_ATOMIC"
@@ -277,8 +277,8 @@
277277
(match_operand:SI 2 "arith_operand" "rI"))) ;; value for op
278278
(match_operand:SI 3 "const_int_operand")] ;; mask
279279
UNSPEC_SYNC_OLD_OP_SUBWORD))
280-
(match_operand:SI 4 "arith_operand" "rI") ;; mask
281-
(match_operand:SI 5 "arith_operand" "rI") ;; not_mask
280+
(use (match_operand:SI 4 "arith_operand" "rI")) ;; mask
281+
(use (match_operand:SI 5 "arith_operand" "rI")) ;; not_mask
282282
(clobber (match_scratch:SI 6 "=&r")) ;; tmp_1
283283
(clobber (match_scratch:SI 7 "=&r"))] ;; tmp_2
284284
"TARGET_ZALRSC && TARGET_INLINE_SUBWORD_ATOMIC"
@@ -512,7 +512,7 @@
512512
[(match_operand:SI 2 "arith_operand" "rI") ;; value
513513
(match_operand:SI 3 "const_int_operand")] ;; model
514514
UNSPEC_SYNC_EXCHANGE_SUBWORD))
515-
(match_operand:SI 4 "arith_operand" "rI") ;; not_mask
515+
(use (match_operand:SI 4 "arith_operand" "rI")) ;; not_mask
516516
(clobber (match_scratch:SI 5 "=&r"))] ;; tmp_1
517517
"TARGET_ZALRSC && TARGET_INLINE_SUBWORD_ATOMIC"
518518
{
@@ -785,10 +785,10 @@
785785
(unspec_volatile:SI [(match_operand:SI 2 "reg_or_0_operand" "rJ") ;; expected value
786786
(match_operand:SI 3 "arith_operand" "rI")] ;; desired value
787787
UNSPEC_COMPARE_AND_SWAP_SUBWORD))
788-
(match_operand:SI 4 "const_int_operand") ;; model
789-
(match_operand:SI 5 "arith_operand" "rI") ;; mask
790-
(match_operand:SI 6 "arith_operand" "rI") ;; not_mask
791-
(clobber (match_scratch:SI 7 "=&r"))] ;; tmp_1
788+
(match_operand:SI 4 "const_int_operand") ;; model
789+
(use (match_operand:SI 5 "arith_operand" "rI")) ;; mask
790+
(use (match_operand:SI 6 "arith_operand" "rI")) ;; not_mask
791+
(clobber (match_scratch:SI 7 "=&r"))] ;; tmp_1
792792
"TARGET_ZALRSC && TARGET_INLINE_SUBWORD_ATOMIC"
793793
{
794794
return "1:\;"

0 commit comments

Comments
 (0)