On 1/8/21 5:49 AM, Maciej W. Rozycki wrote:
> Remove fallout from commit 0bd675183d94 ("match.pd: Add ~(X - Y) -> ~X
> + Y simplification [PR96685]") and paper over the regression caused as
> it is not the matter of the test cases affected.
>
> Previously assembly like this:
>
> .text
> .align 1
> .globl eq_notsi
> .type eq_notsi, @function
> eq_notsi:
> .word 0 # 35 [c=0] procedure_entry_mask
> subl2 $4,%sp # 46 [c=32] *addsi3
> mcoml 4(%ap),%r0 # 32 [c=16] *one_cmplsi2_ccz
> jeql .L1 # 34 [c=26] *branch_ccz
> addl2 $2,%r0 # 31 [c=32] *addsi3
> .L1:
> ret # 40 [c=0] return
> .size eq_notsi, .-eq_notsi
>
> was produced. Now this:
>
> .text
> .align 1
> .globl eq_notsi
> .type eq_notsi, @function
> eq_notsi:
> .word 0 # 36 [c=0] procedure_entry_mask
> subl2 $4,%sp # 48 [c=32] *addsi3
> movl 4(%ap),%r0 # 33 [c=16] *movsi_2
> cmpl %r0,$-1 # 34 [c=8] *cmpsi_ccz/1
> jeql .L3 # 35 [c=26] *branch_ccz
> subl3 %r0,$1,%r0 # 32 [c=32] *subsi3/1
> ret # 27 [c=0] return
> .L3:
> clrl %r0 # 31 [c=2] *movsi_2
> ret # 41 [c=0] return
> .size eq_notsi, .-eq_notsi
>
> is, which cannot work with post-reload comparison elimination, due to
> the comparison against -1 rather than 0.
>
> Use subtraction from a constant then rather than addition as the former
> operation is not transformed, removing these regressions:
>
> FAIL: gcc.target/vax/cmpelim-eq-notsi.c -O1 scan-rtl-dump-times cmpelim
> "deleting insn with uid" 1
> FAIL: gcc.target/vax/cmpelim-eq-notsi.c -O1 scan-assembler-not
> \t(bit|cmpz?|tst).
> FAIL: gcc.target/vax/cmpelim-eq-notsi.c -O1 scan-assembler one_cmplsi[^
> ]*_ccz(/[0-9]+)?\n
> FAIL: gcc.target/vax/cmpelim-lt-notsi.c -O1 scan-rtl-dump-times cmpelim
> "deleting insn with uid" 1
> FAIL: gcc.target/vax/cmpelim-lt-notsi.c -O1 scan-assembler-not
> \t(bit|cmpz?|tst).
> FAIL: gcc.target/vax/cmpelim-lt-notsi.c -O1 scan-assembler one_cmplsi[^
> ]*_ccn(/[0-9]+)?\n
>
> and likewise across some of the other the optimization levels verified.
>
> The LE variant appears unaffected as the new transformation produces
> slightly different although still suboptimal code:
>
> .text
> .align 1
> .globl le_notsi
> .type le_notsi, @function
> le_notsi:
> .word 0 # 27 [c=0] procedure_entry_mask
> subl2 $4,%sp # 34 [c=32] *addsi3
> movl 4(%ap),%r1 # 23 [c=16] *movsi_2
> mcoml %r1,%r0 # 24 [c=8] *one_cmplsi2_ccnz
> jleq .L1 # 26 [c=26] *branch_ccnz
> subl3 %r1,$1,%r0 # 22 [c=32] *subsi3/1
> .L1:
> ret # 32 [c=0] return
> .size le_notsi, .-le_notsi
>
> but update the test case too, for consistency with the other two.
>
> gcc/testsuite/
> * gcc.target/vax/cmpelim-eq-notsi.c: Use subtraction from a
> constant then rather than addition.
> * gcc.target/vax/cmpelim-le-notsi.c: Likewise.
> * gcc.target/vax/cmpelim-lt-notsi.c: Likewise.
OK
jeff