From: Maciej W. Rozycki Date: Fri, 8 Jan 2021 12:49:59 +0000 (+0000) Subject: VAX/testsuite: Remove notsi comparison elimination regressions X-Git-Url: https://git.libre-soc.org/?a=commitdiff_plain;h=f2a5346244a18c89bebac078657d0f74dbb24622;p=gcc.git VAX/testsuite: Remove notsi comparison elimination regressions 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. --- diff --git a/gcc/testsuite/gcc.target/vax/cmpelim-eq-notsi.c b/gcc/testsuite/gcc.target/vax/cmpelim-eq-notsi.c index ba5b735e01b..dbd6d43212d 100644 --- a/gcc/testsuite/gcc.target/vax/cmpelim-eq-notsi.c +++ b/gcc/testsuite/gcc.target/vax/cmpelim-eq-notsi.c @@ -11,14 +11,14 @@ eq_notsi (int_t x) if (x == 0) return x; else - return x + 2; + return 2 - x; } /* Expect assembly like: mcoml 4(%ap),%r0 # 32 [c=16] *one_cmplsi2_ccz jeql .L1 # 34 [c=26] *branch_ccz - addl2 $2,%r0 # 31 [c=32] *addsi3 + subl3 %r0,$2,%r0 # 31 [c=32] *subsi3/1 .L1: */ diff --git a/gcc/testsuite/gcc.target/vax/cmpelim-le-notsi.c b/gcc/testsuite/gcc.target/vax/cmpelim-le-notsi.c index 938a6b3a4d3..3e52da13bee 100644 --- a/gcc/testsuite/gcc.target/vax/cmpelim-le-notsi.c +++ b/gcc/testsuite/gcc.target/vax/cmpelim-le-notsi.c @@ -11,14 +11,14 @@ le_notsi (int_t x) if (x <= 0) return x; else - return x + 2; + return 2 - x; } /* Expect assembly like: mcoml 4(%ap),%r0 # 28 [c=16] *one_cmplsi2_ccnz jleq .L1 # 30 [c=26] *branch_ccnz - addl2 $2,%r0 # 27 [c=32] *addsi3 + subl3 %r0,$2,%r0 # 27 [c=32] *subsi3/1 .L1: */ diff --git a/gcc/testsuite/gcc.target/vax/cmpelim-lt-notsi.c b/gcc/testsuite/gcc.target/vax/cmpelim-lt-notsi.c index c3586b198fd..2c758ccb593 100644 --- a/gcc/testsuite/gcc.target/vax/cmpelim-lt-notsi.c +++ b/gcc/testsuite/gcc.target/vax/cmpelim-lt-notsi.c @@ -11,14 +11,14 @@ lt_notsi (int_t x) if (x < 0) return x; else - return x + 2; + return 2 - x; } /* Expect assembly like: mcoml 4(%ap),%r0 # 28 [c=16] *one_cmplsi2_ccn jlss .L1 # 30 [c=26] *branch_ccn - addl2 $2,%r0 # 27 [c=32] *addsi3 + subl3 %r0,$2,%r0 # 27 [c=32] *subsi3/1 .L1: */