https://gcc.gnu.org/bugzilla/show_bug.cgi?id=126118
Oleg Endo <olegendo at gcc dot gnu.org> changed:
What |Removed |Added
----------------------------------------------------------------------------
Target| |sh*-*-*
Last reconfirmed| |2026-07-05
Status|UNCONFIRMED |NEW
Ever confirmed|0 |1
Component|target |middle-end
--- Comment #1 from Oleg Endo <olegendo at gcc dot gnu.org> ---
Initial expansion on GCC 17 and of GCC 15 (last known working):
(insn 6 5 7 (set (reg:SI 165)
(const_int 0 [0])) "sh_tmp.cpp":6:5 -1
(nil))
(insn 7 6 0 (parallel [
(asm_operands/v ("cmp/str %0,%1") ("") 0 [
(reg:SI 165)
(reg/v:SI 164 [ val ])
]
[
(asm_input:SI ("r") sh_tmp.cpp:6)
(asm_input:SI ("r") sh_tmp.cpp:6)
]
[] sh_tmp.cpp:6)
(clobber (reg:SI 147 t))
]) "sh_tmp.cpp":6:5 -1
(nil))
;; t.0_1 = t;
(insn 8 7 0 (set (reg:SI 162 [ t.0_1 ])
(reg/v:SI 147 t [ t ])) "sh_tmp.cpp":8:5 -1
(nil))
;; return _4;
(insn 9 8 10 (set (reg:SI 147 t)
(eq:SI (reg:SI 162 [ t.0_1 ])
(const_int 0 [0]))) "sh_tmp.cpp":8:12 -1
(nil))
(insn 10 9 11 (set (reg:SI 168)
(const_int -1 [0xffffffffffffffff])) "sh_tmp.cpp":8:12 -1
(nil))
(insn 11 10 12 (parallel [
(set (reg:SI 167)
(xor:SI (reg:SI 147 t)
(const_int 1 [0x1])))
(set (reg:SI 147 t)
(const_int 1 [0x1]))
(use (reg:SI 168))
]) "sh_tmp.cpp":8:12 -1
(nil))
(insn 12 11 13 (set (reg:QI 166 [ _4 ])
(subreg:QI (reg:SI 167) 0)) "sh_tmp.cpp":8:12 -1
(nil))
(insn 13 12 14 (set (reg:SI 169)
(zero_extend:SI (reg:QI 166 [ _4 ]))) "sh_tmp.cpp":8:12 discrim 1 -1
(nil))
However, looking at the first diff points in the combine log...
GCC 15:
Trying 11 -> 13:
11: {r167:SI=t:SI^0x1;t:SI=0x1;use r168:SI;}
REG_DEAD r168:SI
REG_UNUSED t:SI
13: r169:SI=zero_extend(r167:SI#0)
REG_DEAD r167:SI
Successfully matched this instruction:
(set (reg:SI 169 [ _4 ])
(xor:SI (zero_extend:SI (subreg:QI (reg:SI 147 t) 0))
(const_int 1 [0x1])))
GCC 17:
Trying 11 -> 13:
11: {r167:SI=t:SI^0x1;t:SI=0x1;use r168:SI;}
REG_DEAD r168:SI
REG_UNUSED t:SI
13: r169:SI=zero_extend(r167:SI#0)
REG_DEAD r167:SI
Failed to match this instruction:
(set (reg:SI 169 [ _4 ])
(xor:SI (zero_extend:SI (clobber:QI (const_int 0 [0])))
(const_int 1 [0x1])))
For whatever reason, combine replaces
(subreg:QI (reg:SI 147 t) 0)
with
(clobber:QI (const_int 0 [0]))
This doesn't make any sense to me.