[Bug target/122018] x86 doesn't use BTS bitmanip instruction to both set and test bit
ubizjak at gmail dot com via Gcc-bugs <[email protected]>
| Newsgroups | gmane.comp.gcc.bugs |
|---|---|
| Message-ID | <[email protected]/bugzilla/> |
https://gcc.gnu.org/bugzilla/show_bug.cgi?id=122018
--- Comment #20 from Uroš Bizjak <ubizjak at gmail dot com> ---
(In reply to uis from comment #18)
> I still don't know if ix86_pre_reload_split() should be here, which I copied
> from other insn_and_split.
>
> I also noticed how fragile bts combine can be, here I can move one line and
> both gcc 15 and trunk fail:
>
> void g();
> int f(int a, int b) {
> bool t = false;
> t = (a >> b) & 1;
> if(!t) {
> a = a | (1 << b);
> g();
> }
> return a;
> }
Combine wants to create:
Trying 12, 13 -> 14:
12: r107:SI=0x1
13: {r106:SI=r107:SI<<r103:SI#0;clobber flags:CC;}
REG_DEAD r107:SI
REG_DEAD r103:SI
REG_UNUSED flags:CC
REG_EQUAL 0x1<<r103:SI#0
14: {r102:SI=r102:SI|r106:SI;clobber flags:CC;}
REG_DEAD r106:SI
REG_UNUSED flags:CC
Successfully matched this instruction:
(parallel [
(set (zero_extract:SI (reg/v:SI 102 [ a ])
(const_int 1 [0x1])
(subreg:QI (reg/v:SI 103 [ b ]) 0))
(const_int 1 [0x1]))
(clobber (reg:CC 17 flags))
])
which is another (and probably canonical) form of bit set RTX.