From patchwork Wed May 10 18:00:06 2023 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Andrew Pinski X-Patchwork-Id: 92252 Return-Path: Delivered-To: ouuuleilei@gmail.com Received: by 2002:a59:b0ea:0:b0:3b6:4342:cba0 with SMTP id b10csp3815442vqo; Wed, 10 May 2023 11:01:12 -0700 (PDT) X-Google-Smtp-Source: ACHHUZ5AH5qd0xqp6YO3WlWLvMd3JTYQ25jpCjtwYMLmAaxQrtsGzOdVtzmhaUTmkFPh1ccZcSn0 X-Received: by 2002:aa7:ccc6:0:b0:50b:dfe2:91 with SMTP id y6-20020aa7ccc6000000b0050bdfe20091mr16159630edt.7.1683741671962; Wed, 10 May 2023 11:01:11 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1683741671; cv=none; d=google.com; s=arc-20160816; b=HQc5R0ZXfRbxgpCg85/kMFayUDIZcfEMx6NTCuFCMoVuDmYZzJUHR1dTwN6PJ8wL37 0Kx5VlS7ioEZ9mzKjz73kvcPWt7mtnuviWM1LcgPneIdmnAX71irfIlflG+zpHbId1ot Fvgu8SjyIMOhgvSKhOX/LxRgt+2gRuX7Jil/Iv+MmihGL4ec9LKspbeShzYin84zuxKv MI+s78GwaCLPlFFVrbzzqyQ1QM5Lwawyq5Zxz63Qb7oeN5ttXh06SoDXnb2W8jwTlm5Q Fg475nbl+1k3FQW+jCgFih09qODSvgeQTdwQwQPC6r5jXvZ/MCbEzs0APMCH2ve73atR E1iQ== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=sender:errors-to:reply-to:from:list-subscribe:list-help:list-post :list-archive:list-unsubscribe:list-id:precedence :content-transfer-encoding:mime-version:message-id:date:subject:cc :to:dmarc-filter:delivered-to:dkim-signature:dkim-filter; bh=dMbsHP9kPkqSV5QOcL8iLwAxwL0k8p/J7tSdMiEdeRs=; b=TvuL1mf/tnFa86krMLhAcEpqL7fZqYIyFKxDqeyDGdAllf8oBL4UMnIaZBANq/IQWl 9pLd0QyUS5YcmTiUW9YwmdZEpbwVijuzm3WHrHK2ojZYnGA17p4peMC8RdzslfwCfE4b komSAPMYxDturVGGqn0veWDsGn85krp7mCbCU4NPZ+2O5rB9o6exupurTa2U3oB8dVFT hRM6qBsT6iVw0qs+0BFjkM8KQeyqtGPz64HrUaPUg5sFaDr/revDqyIYyFZc380Q3BlG JIhtntYB0bpJilMbVDmWHhjc6s4JlFJpsF5GP4Kc5BvUSx2LJ7uCiA1iH42CYaY/xIQa M21g== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@gcc.gnu.org header.s=default header.b=yGawwaW5; spf=pass (google.com: domain of gcc-patches-bounces+ouuuleilei=gmail.com@gcc.gnu.org designates 2620:52:3:1:0:246e:9693:128c as permitted sender) smtp.mailfrom="gcc-patches-bounces+ouuuleilei=gmail.com@gcc.gnu.org"; dmarc=pass (p=NONE sp=NONE dis=NONE) header.from=gnu.org Received: from sourceware.org (server2.sourceware.org. [2620:52:3:1:0:246e:9693:128c]) by mx.google.com with ESMTPS id v8-20020aa7d808000000b0050bc49d4e54si3305493edq.138.2023.05.10.11.01.11 for (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Wed, 10 May 2023 11:01:11 -0700 (PDT) Received-SPF: pass (google.com: domain of gcc-patches-bounces+ouuuleilei=gmail.com@gcc.gnu.org designates 2620:52:3:1:0:246e:9693:128c as permitted sender) client-ip=2620:52:3:1:0:246e:9693:128c; Authentication-Results: mx.google.com; dkim=pass header.i=@gcc.gnu.org header.s=default header.b=yGawwaW5; spf=pass (google.com: domain of gcc-patches-bounces+ouuuleilei=gmail.com@gcc.gnu.org designates 2620:52:3:1:0:246e:9693:128c as permitted sender) smtp.mailfrom="gcc-patches-bounces+ouuuleilei=gmail.com@gcc.gnu.org"; dmarc=pass (p=NONE sp=NONE dis=NONE) header.from=gnu.org Received: from server2.sourceware.org (localhost [IPv6:::1]) by sourceware.org (Postfix) with ESMTP id 87E3F385702B for ; Wed, 10 May 2023 18:01:10 +0000 (GMT) DKIM-Filter: OpenDKIM Filter v2.11.0 sourceware.org 87E3F385702B DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gcc.gnu.org; s=default; t=1683741670; bh=dMbsHP9kPkqSV5QOcL8iLwAxwL0k8p/J7tSdMiEdeRs=; h=To:CC:Subject:Date:List-Id:List-Unsubscribe:List-Archive: List-Post:List-Help:List-Subscribe:From:Reply-To:From; b=yGawwaW5O5Lsvsj9Cx6Ke70uKlDV9/DSooFCCNWs2fVjATNgzY8+mUNgnDekPBWbf 7XVszgNA0mJvY1qF0UMUIrRLzqLUIv2GCB3JF0nlomEdNjI3r33DwsPkfVCLAGCSBW YOmTHmJ5c83dQDnVtXJ3cXpkZ1lFZ21mMR19TOlg= X-Original-To: gcc-patches@gcc.gnu.org Delivered-To: gcc-patches@gcc.gnu.org Received: from mx0b-0016f401.pphosted.com (mx0a-0016f401.pphosted.com [67.231.148.174]) by sourceware.org (Postfix) with ESMTPS id 19F2E3856DC6 for ; Wed, 10 May 2023 18:00:25 +0000 (GMT) DMARC-Filter: OpenDMARC Filter v1.4.2 sourceware.org 19F2E3856DC6 Received: from pps.filterd (m0045849.ppops.net [127.0.0.1]) by mx0a-0016f401.pphosted.com (8.17.1.19/8.17.1.19) with ESMTP id 34AERZA9016043 for ; Wed, 10 May 2023 11:00:24 -0700 Received: from dc5-exch01.marvell.com ([199.233.59.181]) by mx0a-0016f401.pphosted.com (PPS) with ESMTPS id 3qgd2212yh-1 (version=TLSv1.2 cipher=ECDHE-RSA-AES256-SHA384 bits=256 verify=NOT) for ; Wed, 10 May 2023 11:00:23 -0700 Received: from DC5-EXCH01.marvell.com (10.69.176.38) by DC5-EXCH01.marvell.com (10.69.176.38) with Microsoft SMTP Server (TLS) id 15.0.1497.48; Wed, 10 May 2023 11:00:22 -0700 Received: from maili.marvell.com (10.69.176.80) by DC5-EXCH01.marvell.com (10.69.176.38) with Microsoft SMTP Server id 15.0.1497.48 via Frontend Transport; Wed, 10 May 2023 11:00:22 -0700 Received: from vpnclient.wrightpinski.org.com (unknown [10.69.242.187]) by maili.marvell.com (Postfix) with ESMTP id 376D63F7060; Wed, 10 May 2023 11:00:21 -0700 (PDT) To: CC: Andrew Pinski Subject: [PATCH] Add another new testcase Date: Wed, 10 May 2023 11:00:06 -0700 Message-ID: <20230510180006.1340377-1-apinski@marvell.com> X-Mailer: git-send-email 2.31.1 MIME-Version: 1.0 X-Proofpoint-GUID: nhCxOfKt0vFWIik1QvaWXYE4ilWVdjk1 X-Proofpoint-ORIG-GUID: nhCxOfKt0vFWIik1QvaWXYE4ilWVdjk1 X-Proofpoint-Virus-Version: vendor=baseguard engine=ICAP:2.0.254,Aquarius:18.0.942,Hydra:6.0.573,FMLib:17.11.170.22 definitions=2023-05-10_04,2023-05-05_01,2023-02-09_01 X-Spam-Status: No, score=-14.6 required=5.0 tests=BAYES_00, DKIM_SIGNED, DKIM_VALID, DKIM_VALID_AU, DKIM_VALID_EF, GIT_PATCH_0, RCVD_IN_DNSWL_LOW, SPF_HELO_NONE, SPF_NONE, TXREP, T_SCC_BODY_TEXT_LINE autolearn=ham autolearn_force=no version=3.4.6 X-Spam-Checker-Version: SpamAssassin 3.4.6 (2021-04-09) 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: , X-Patchwork-Original-From: Andrew Pinski via Gcc-patches From: Andrew Pinski Reply-To: Andrew Pinski Errors-To: gcc-patches-bounces+ouuuleilei=gmail.com@gcc.gnu.org Sender: "Gcc-patches" X-getmail-retrieved-from-mailbox: =?utf-8?q?INBOX?= X-GMAIL-THRID: =?utf-8?q?1765531107434941659?= X-GMAIL-MSGID: =?utf-8?q?1765531107434941659?= While working on improving min/max detection, this code (which is reduced from worse_state in ipa-pure-const.cc) was being miscompiled. Since there was no testcase in the testsuite yet for this, this patch adds one. Committed as obvious after testing the testcase via: make check-gcc RUNTESTFLAGS="execute.exp=20230510-1.c" gcc/testsuite/ChangeLog: * gcc.c-torture/execute/20230510-1.c: New test. --- .../gcc.c-torture/execute/20230510-1.c | 34 +++++++++++++++++++ 1 file changed, 34 insertions(+) create mode 100644 gcc/testsuite/gcc.c-torture/execute/20230510-1.c diff --git a/gcc/testsuite/gcc.c-torture/execute/20230510-1.c b/gcc/testsuite/gcc.c-torture/execute/20230510-1.c new file mode 100644 index 00000000000..ec9c9e6eae4 --- /dev/null +++ b/gcc/testsuite/gcc.c-torture/execute/20230510-1.c @@ -0,0 +1,34 @@ +/* This code shows up in worse_state in ipa-pure-const.cc: + *looping = MAX (*looping, looping2); + was miscompiling it as just `return 1` though instead of + `MAX_EXPR<*a, b>` (which should be transformed into `*a | b` + note MAX_EXPR is really `bool | bool` so we + use that to compare against here. + */ +#define bool _Bool +bool __attribute__((noipa)) f(bool *a, bool b) +{ + bool t = *a; + if (t <= b) + return b; + return t; +} +bool __attribute__((noipa)) f1(bool *a, bool b) +{ + return *a | b; +} + +int main() +{ + int i = 0; + int j = 0; + + for (i = 0; i <= 1; i++) + for (j = 0; j <= 1; j++) + { + bool a = i; + if (f(&a, j) != f1(&a, j)) + __builtin_abort(); + } + return 0; +}