[Bug rtl-optimization/105338] [12 Regression] Regression: jump or cmove generated for pattern (x ? CST : 0)
jakub at gcc dot gnu.org
gcc-bugzilla@gcc.gnu.org
Fri Apr 22 11:00:56 GMT 2022
https://gcc.gnu.org/bugzilla/show_bug.cgi?id=105338
--- Comment #3 from Jakub Jelinek <jakub at gcc dot gnu.org> ---
So, if I change passes.def
NEXT_PASS (pass_sink_code, true /* unsplit edges */);
line
NEXT_PASS (pass_sink_code, false /* unsplit edges */);
I get back the 11.x code.
Before ce1 pass, in that case say f looks like:
8: flags:CCZ=cmp(r83:SI,0)
9: pc={(flags:CCZ!=0)?L22:pc}
REG_DEAD flags:CCZ
REG_BR_PROB 375809644
10: NOTE_INSN_BASIC_BLOCK 3
5: r82:SI=0
REG_DEAD r83:SI
; pc falls through to BB 5
22: L22:
21: NOTE_INSN_BASIC_BLOCK 4
4: r82:SI=0x5
15: L15:
18: NOTE_INSN_BASIC_BLOCK 5
use (r82)
i.e. essentially
if (tmp83 != 0)
tmp82 = 5;
else
tmp82 = 0;
But with vanilla trunk, it is instead:
7: flags:CCZ=cmp(r83:SI,0)
8: pc={(flags:CCZ==0)?L10:pc}
REG_DEAD flags:CCZ
REG_BR_PROB 697932188
9: NOTE_INSN_BASIC_BLOCK 4
4: r83:SI=0x5
10: L10:
11: NOTE_INSN_BASIC_BLOCK 5
use (r83)
i.e.
if (tmp83 != 0)
tmp83 = 5;
Before fwprop1, the code looks roughly the same except for the swapped
branches,
so in C
if (tmp83 != 0)
tmp82 = 5;
else
tmp82 = tmp83;
vs.
if (tmp83 == 0)
tmp82 = tmp83;
else
tmp82 = 5;
I think fwprop1 only works on extended basic blocks and therefore turns the
latter into
if (tmp83 == 0)
tmp82 = 0;
else
tmp82 = 5;
and not the former.
More information about the Gcc-bugs
mailing list