https://gcc.gnu.org/bugzilla/show_bug.cgi?id=58195
--- Comment #10 from Andrew Pinski <pinskia at gcc dot gnu.org> --- For aarch64 we could also solve this at the rtl level by simplifying: (if_then_else:SI (ne (reg:SI 108 [ inputD.4415 ]) (const_int 0 [0])) (neg:SI (reg:SI 108 [ inputD.4415 ])) (const_int 0 [0])) into: (neg:SI (reg:SI 108 [ inputD.4415 ])) Trying 2, 38 -> 17: 2: r104:SI=r108:SI REG_DEAD r108:SI 38: cc:CC=cmp(r104:SI,0) 17: x0:SI={(cc:CC!=0)?-r104:SI:0} REG_DEAD cc:CC REG_DEAD r104:SI Failed to match this instruction: (set (reg/i:SI 0 x0) (if_then_else:SI (ne (reg:SI 108 [ inputD.4415 ]) (const_int 0 [0])) (neg:SI (reg:SI 108 [ inputD.4415 ])) (const_int 0 [0]))) I am going to implement that first and then implement the phiopt change.