https://gcc.gnu.org/bugzilla/show_bug.cgi?id=93565
--- Comment #29 from Andrew Pinski <pinskia at gcc dot gnu.org> ---
Looking back at this one, I (In reply to Wilco from comment #8)
> Here is a much simpler example:
>
> void f (int *p, int y)
> {
> int a = y & 14;
> *p = a | p[a];
> }
After r14-9692-g839bc42772ba7af66af3bd16efed4a69511312ae, we now get:
f:
.LFB0:
.cfi_startproc
and w2, w1, 14
mov x1, x2
ldr w2, [x0, x2, lsl 2]
orr w1, w2, w1
str w1, [x0]
ret
.cfi_endproc
There is an extra move still but the duplicated and is gone. (with
-frename-registers added, the move is gone as REE is able to remove the zero
extend but then there is a life range conflict so can't remove the move too).
So maybe this should be closed as fixed for GCC 14 and the cost changes for clz
reverted.
```
Trying 7 -> 9:
7: r105:SI=r115:SI&0xe
REG_DEAD r115:SI
9: r110:DI=zero_extend(r105:SI)
Failed to match this instruction:
(parallel [
(set (reg:DI 110 [ _1 ])
(and:DI (subreg:DI (reg:SI 115) 0)
(const_int 14 [0xe])))
(set (reg/v:SI 105 [ a ])
(and:SI (reg:SI 115)
(const_int 14 [0xe])))
])
Failed to match this instruction:
(parallel [
(set (reg:DI 110 [ _1 ])
(and:DI (subreg:DI (reg:SI 115) 0)
(const_int 14 [0xe])))
(set (reg/v:SI 105 [ a ])
(and:SI (reg:SI 115)
(const_int 14 [0xe])))
])
Successfully matched this instruction:
(set (reg/v:SI 105 [ a ])
(and:SI (reg:SI 115)
(const_int 14 [0xe])))
Successfully matched this instruction:
(set (reg:DI 110 [ _1 ])
(and:DI (subreg:DI (reg:SI 115) 0)
(const_int 14 [0xe])))
allowing combination of insns 7 and 9
original costs 4 + 4 = 8
replacement costs 4 + 4 = 8
i2 didn't change, not doing this
```