From patchwork Fri Jan 8 12:49:59 2021 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: "Maciej W. Rozycki" X-Patchwork-Id: 1423764 Return-Path: X-Original-To: incoming@patchwork.ozlabs.org Delivered-To: patchwork-incoming@bilbo.ozlabs.org Authentication-Results: ozlabs.org; spf=pass (sender SPF authorized) smtp.mailfrom=gcc.gnu.org (client-ip=2620:52:3:1:0:246e:9693:128c; helo=sourceware.org; envelope-from=gcc-patches-bounces@gcc.gnu.org; receiver=) Authentication-Results: ozlabs.org; dmarc=none (p=none dis=none) header.from=linux-mips.org Received: from sourceware.org (server2.sourceware.org [IPv6:2620:52:3:1:0:246e:9693:128c]) (using TLSv1.3 with cipher TLS_AES_256_GCM_SHA384 (256/256 bits) key-exchange X25519 server-signature RSA-PSS (4096 bits) server-digest SHA256) (No client certificate requested) by ozlabs.org (Postfix) with ESMTPS id 4DC2xw3Z1bz9sW8 for ; Fri, 8 Jan 2021 23:50:09 +1100 (AEDT) Received: from server2.sourceware.org (localhost [IPv6:::1]) by sourceware.org (Postfix) with ESMTP id B5F3B38438E4; Fri, 8 Jan 2021 12:50:06 +0000 (GMT) X-Original-To: gcc-patches@gcc.gnu.org Delivered-To: gcc-patches@gcc.gnu.org Received: from cvs.linux-mips.org (eddie.linux-mips.org [148.251.95.138]) by sourceware.org (Postfix) with ESMTP id 6F0383844028 for ; Fri, 8 Jan 2021 12:50:03 +0000 (GMT) DMARC-Filter: OpenDMARC Filter v1.3.2 sourceware.org 6F0383844028 Authentication-Results: sourceware.org; dmarc=none (p=none dis=none) header.from=linux-mips.org Authentication-Results: sourceware.org; spf=none smtp.mailfrom=macro@linux-mips.org Received: from localhost.localdomain ([127.0.0.1]:55234 "EHLO localhost" rhost-flags-OK-OK-OK-OK) by eddie.linux-mips.org with ESMTP id S23993316AbhAHMt7qdeIh (ORCPT ); Fri, 8 Jan 2021 13:49:59 +0100 Date: Fri, 8 Jan 2021 12:49:59 +0000 (GMT) From: "Maciej W. Rozycki" To: gcc-patches@gcc.gnu.org Subject: [PATCH] VAX/testsuite: Remove notsi comparison elimination regressions Message-ID: MIME-Version: 1.0 X-Spam-Status: No, score=-2.7 required=5.0 tests=BAYES_00, KAM_ASCII_DIVIDERS, KAM_DMARC_STATUS, KAM_LAZY_DOMAIN_SECURITY, KHOP_HELO_FCRDNS, SPF_HELO_NONE, SPF_NONE, TXREP autolearn=no autolearn_force=no version=3.4.2 X-Spam-Checker-Version: SpamAssassin 3.4.2 (2018-09-13) on server2.sourceware.org X-BeenThere: gcc-patches@gcc.gnu.org X-Mailman-Version: 2.1.29 Precedence: list List-Id: Gcc-patches mailing list List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Cc: Jakub Jelinek Errors-To: gcc-patches-bounces@gcc.gnu.org Sender: "Gcc-patches" 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. --- gcc/testsuite/gcc.target/vax/cmpelim-eq-notsi.c | 4 ++-- gcc/testsuite/gcc.target/vax/cmpelim-le-notsi.c | 4 ++-- gcc/testsuite/gcc.target/vax/cmpelim-lt-notsi.c | 4 ++-- 3 files changed, 6 insertions(+), 6 deletions(-) gcc-test-vax-notsi-pr96685.diff Index: gcc/gcc/testsuite/gcc.target/vax/cmpelim-eq-notsi.c =================================================================== --- gcc.orig/gcc/testsuite/gcc.target/vax/cmpelim-eq-notsi.c +++ gcc/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: */ Index: gcc/gcc/testsuite/gcc.target/vax/cmpelim-le-notsi.c =================================================================== --- gcc.orig/gcc/testsuite/gcc.target/vax/cmpelim-le-notsi.c +++ gcc/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: */ Index: gcc/gcc/testsuite/gcc.target/vax/cmpelim-lt-notsi.c =================================================================== --- gcc.orig/gcc/testsuite/gcc.target/vax/cmpelim-lt-notsi.c +++ gcc/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: */