https://gcc.gnu.org/bugzilla/show_bug.cgi?id=80301
Andrew Pinski <pinskia at gcc dot gnu.org> changed: What |Removed |Added ---------------------------------------------------------------------------- Severity|normal |enhancement --- Comment #4 from Andrew Pinski <pinskia at gcc dot gnu.org> --- We are able to do the 2->2 combine now (after r9-2064): Trying 9 -> 10: 9: {r87:DI=r86:DI+0x2;clobber flags:CC;} REG_DEAD r86:DI REG_UNUSED flags:CC 10: flags:CCZ=cmp([r87:DI*0x8+`m'],r83:SI) Failed to match this instruction: (parallel [ (set (reg:CCZ 17 flags) (compare:CCZ (mem:SI (plus:DI (mult:DI (reg:DI 86 [ indexD.2442 ]) (const_int 8 [0x8])) (const:DI (plus:DI (symbol_ref:DI ("m") [flags 0x2] <var_decl 0x7fda6f169cf0 m>) (const_int 16 [0x10])))) [1 mD.2375.sD.2374[index_4(D)].aD.2372+0 S4 A64]) (reg:SI 83 [ <retval> ]))) (set (reg:DI 87) (plus:DI (reg:DI 86 [ indexD.2442 ]) (const_int 2 [0x2]))) ]) Failed to match this instruction: (parallel [ (set (reg:CCZ 17 flags) (compare:CCZ (mem:SI (plus:DI (mult:DI (reg:DI 86 [ indexD.2442 ]) (const_int 8 [0x8])) (const:DI (plus:DI (symbol_ref:DI ("m") [flags 0x2] <var_decl 0x7fda6f169cf0 m>) (const_int 16 [0x10])))) [1 mD.2375.sD.2374[index_4(D)].aD.2372+0 S4 A64]) (reg:SI 83 [ <retval> ]))) (set (reg:DI 87) (plus:DI (reg:DI 86 [ indexD.2442 ]) (const_int 2 [0x2]))) ]) Successfully matched this instruction: (set (reg:DI 87) (plus:DI (reg:DI 86 [ indexD.2442 ]) (const_int 2 [0x2]))) Successfully matched this instruction: (set (reg:CCZ 17 flags) (compare:CCZ (mem:SI (plus:DI (mult:DI (reg:DI 86 [ indexD.2442 ]) (const_int 8 [0x8])) (const:DI (plus:DI (symbol_ref:DI ("m") [flags 0x2] <var_decl 0x7fda6f169cf0 m>) (const_int 16 [0x10])))) [1 mD.2375.sD.2374[index_4(D)].aD.2372+0 S4 A64]) (reg:SI 83 [ <retval> ]))) allowing combination of insns 9 and 10 original costs 4 + 13 = 17 replacement costs 4 + 13 = 17 modifying insn i2 9: r87:DI=r86:DI+0x2 deferring rescan insn with uid = 9. modifying insn i3 10: flags:CCZ=cmp([r86:DI*0x8+const(`m'+0x10)],r83:SI) REG_DEAD r86:DI deferring rescan insn with uid = 10. But then we don't sink the add into the conditional and do the combine there. The code we get now is: func(unsigned int): movl %edi, %edx movq %rdx, %rax leaq 2(%rdx), %rcx cmpl %edx, m+16(,%rdx,8) je .L1 movl m+4(,%rcx,8), %eax .L1: ret