https://gcc.gnu.org/bugzilla/show_bug.cgi?id=99998
Richard Biener <rguenth at gcc dot gnu.org> changed: What |Removed |Added ---------------------------------------------------------------------------- Last reconfirmed| |2021-04-12 Keywords| |missed-optimization Ever confirmed|0 |1 Status|UNCONFIRMED |NEW --- Comment #1 from Richard Biener <rguenth at gcc dot gnu.org> --- Confirmed. The issue is that the RMB is conditionally skipped, so there isn't anything we can do here unless we want to treat empty asm text specially and thus essentially drop the asm. I think the proper fix is to make the smp_rmb unconditional in the source, or, if the kernel has archs where the RMB isn't a no-op, add a conditional_smp_rmb (condition). (insn 18 17 19 4 (set (reg:CCZ 17 flags) (compare:CCZ (reg:QI 88 [ <retval> ]) (const_int 0 [0]))) "t.c":27:5 5 {*cmpqi_ccno_1} (nil)) (jump_insn 19 18 20 4 (set (pc) (if_then_else (eq (reg:CCZ 17 flags) (const_int 0 [0])) (label_ref:DI 26) (pc))) "t.c":27:5 806 {*jcc} (int_list:REG_BR_PROB 536870916 (nil)) -> 26) ;; succ: 5 [50.0% (guessed)] count:536870912 (estimated locally) (FALLTHRU) ;; 6 [50.0% (guessed)] count:536870912 (estimated locally) ;; basic block 5, loop depth 0, count 536870913 (estimated locally), maybe hot ;; prev block 4, next block 6, flags: (RTL) ;; pred: 4 [50.0% (guessed)] count:536870912 (estimated locally) (FALLTHRU) (note 20 19 21 5 [bb 5] NOTE_INSN_BASIC_BLOCK) (insn 21 20 26 5 (parallel [ (asm_operands/v ("") ("") 0 [] [] [] t.c:28) (clobber (mem:BLK (scratch) [0 A8])) (clobber (reg:CC 17 flags)) ]) "t.c":28:3 -1 (nil)) ;; succ: 6 [always] count:536870913 (estimated locally) (FALLTHRU) ;; basic block 6, loop depth 0, count 1073741824 (estimated locally), maybe hot ;; prev block 5, next block 1, flags: (RTL) ;; pred: 5 [always] count:536870913 (estimated locally) (FALLTHRU) ;; 4 [50.0% (guessed)] count:536870912 (estimated locally) (code_label 26 21 29 6 1 (nil) [1 uses]) (note 29 26 27 6 [bb 6] NOTE_INSN_BASIC_BLOCK) (insn 27 29 28 6 (set (reg/i:QI 0 ax) (reg:QI 88 [ <retval> ])) "t.c":30:1 77 {*movqi_internal} (nil)) (insn 28 27 0 6 (use (reg/i:QI 0 ax)) "t.c":30:1 -1 (nil)) ;; succ: EXIT [always] count:1073741824 (estimated locally) (FALLTHRU) That said, this is WONTFIX I fear.