From patchwork Wed Aug 30 22:25:11 2023 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Andrew Pinski X-Patchwork-Id: 137216 Return-Path: Delivered-To: ouuuleilei@gmail.com Received: by 2002:a59:a7d1:0:b0:3f2:4152:657d with SMTP id p17csp4811229vqm; Wed, 30 Aug 2023 15:27:22 -0700 (PDT) X-Google-Smtp-Source: AGHT+IHSEdzLqGtB0MIKirmuym7Dplyz1EBr9tokEZ89XH8ZzjiI2iWPcTHZ8VDB8LnNVHE+S8pS X-Received: by 2002:adf:ec11:0:b0:317:7441:1a4 with SMTP id x17-20020adfec11000000b00317744101a4mr2655384wrn.29.1693434441949; Wed, 30 Aug 2023 15:27:21 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1693434441; cv=none; d=google.com; s=arc-20160816; b=hMV4UZEWCfMrZcpLmBwYC13Vn+S5sAEkc9eBnmQywQ2QAhn9PuJcfHTAizphB4WBQD i/7dnTD5lSDzpicEQhEqNa43EuWBs4dLXomS16VcD2SPRJwVGl5l/WVAlsprNXfkZsp1 P2fv6rCu0pXiXhSsyrd8S0ml7Ln87CDscv4Nm4PehsWpfF0axHwZFcYt7gsFBzHgVNTn fmFMEj6WudRpZQSn+YM28B/OksnjXZRfX/DJpgI+mNUmtl6q2B4PbjrzuHVgsn7q2I4a e6J3m55c5aHpoB6R7B6g367xO5bOO/b6sQQAR0LoIEjF2uWAD3g1RZSMrZfIhdDabxcb gojA== 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=qxg6JfChFjwGEoV9qtdfpsN/PbHOZOMlGF7RTBSAGsg=; fh=XbcmRug6/SzczusyoNU1I7Lu5oY0AN2u0mWDzKoxdSs=; b=ixUbm/Q5VRYYYqumwNFD0V+LysJCq7Ir82q9XMxa3UhrIq/PnCQwzAARXyqLoBZdNm ibdG6WQ/spfCkqqLNDGXYx7ndCOSmaRgW/KuEYG6L4scOtzlMkxJ8mBdbAY4dh886AFl exHZ8MA2ahl7eou6mVzITZmui93GGtZ06WmWuPHiSiDUL2hQQFFs+81sw2UOhSZTmqJF sJZe+sK0mbVeKPfWCFLBVFIONqgbBTe/bmbtoFMLV74JsxcX5hCKFF3q94N+CwkO+IEo 5R76/OyN/cWexQug2PzVQW8TE48ltH151B2ygbNZ3Erhmh3aUG0AkkNseFUN6lrdjT1F IVtw== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@gcc.gnu.org header.s=default header.b=mnplcKn4; spf=pass (google.com: domain of gcc-patches-bounces+ouuuleilei=gmail.com@gcc.gnu.org designates 8.43.85.97 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 (ip-8-43-85-97.sourceware.org. [8.43.85.97]) by mx.google.com with ESMTPS id w13-20020aa7d28d000000b0052a3c95becesi121162edq.284.2023.08.30.15.27.21 for (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Wed, 30 Aug 2023 15:27:21 -0700 (PDT) Received-SPF: pass (google.com: domain of gcc-patches-bounces+ouuuleilei=gmail.com@gcc.gnu.org designates 8.43.85.97 as permitted sender) client-ip=8.43.85.97; Authentication-Results: mx.google.com; dkim=pass header.i=@gcc.gnu.org header.s=default header.b=mnplcKn4; spf=pass (google.com: domain of gcc-patches-bounces+ouuuleilei=gmail.com@gcc.gnu.org designates 8.43.85.97 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 97E8C3858000 for ; Wed, 30 Aug 2023 22:27:14 +0000 (GMT) DKIM-Filter: OpenDKIM Filter v2.11.0 sourceware.org 97E8C3858000 DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gcc.gnu.org; s=default; t=1693434434; bh=qxg6JfChFjwGEoV9qtdfpsN/PbHOZOMlGF7RTBSAGsg=; h=To:CC:Subject:Date:List-Id:List-Unsubscribe:List-Archive: List-Post:List-Help:List-Subscribe:From:Reply-To:From; b=mnplcKn41/vZgWbrc2EuyMc6XTNayMgM+w+5/CBvDPtHU8bLryYBocldWEptV2WwD W9R2eqQHR4qt7sxFjyB44AussGBdACjb41ic/ouTKqvoyanb6egeYR4ItgUoj7NA1E 1kt3cae3sZUMiD5tWthJtoOEvS46AawItMR6xLHo= 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 0E44D3858D20 for ; Wed, 30 Aug 2023 22:26:23 +0000 (GMT) DMARC-Filter: OpenDMARC Filter v1.4.2 sourceware.org 0E44D3858D20 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 37UINnFP004354 for ; Wed, 30 Aug 2023 15:26:23 -0700 Received: from dc5-exch01.marvell.com ([199.233.59.181]) by mx0a-0016f401.pphosted.com (PPS) with ESMTPS id 3st0fyu3mj-1 (version=TLSv1.2 cipher=ECDHE-RSA-AES256-SHA384 bits=256 verify=NOT) for ; Wed, 30 Aug 2023 15:26:22 -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, 30 Aug 2023 15:26:21 -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, 30 Aug 2023 15:26:21 -0700 Received: from vpnclient.wrightpinski.org.com (unknown [10.69.242.187]) by maili.marvell.com (Postfix) with ESMTP id E396E3F7063; Wed, 30 Aug 2023 15:26:20 -0700 (PDT) To: CC: Andrew Pinski Subject: [PATCH] MATCH: extend min_value/max_value match to vectors Date: Wed, 30 Aug 2023 15:25:11 -0700 Message-ID: <20230830222511.685346-1-apinski@marvell.com> X-Mailer: git-send-email 2.31.1 MIME-Version: 1.0 X-Proofpoint-GUID: jwJWUnEigR1ZwxVzODPCYo3XtCr9qbwN X-Proofpoint-ORIG-GUID: jwJWUnEigR1ZwxVzODPCYo3XtCr9qbwN X-Proofpoint-Virus-Version: vendor=baseguard engine=ICAP:2.0.267,Aquarius:18.0.957,Hydra:6.0.601,FMLib:17.11.176.26 definitions=2023-08-30_18,2023-08-29_01,2023-05-22_02 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_PASS, TXREP 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.30 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: INBOX X-GMAIL-THRID: 1775694713246927379 X-GMAIL-MSGID: 1775694713246927379 This simple patch extends the min_value/max_value match to vector integer types. Using uniform_integer_cst_p makes this easy. OK? Bootstrapped and tested on x86_64-linux-gnu with no regressions. The testcases pr110915-*.c are the same as pr88784-*.c except using vector types instead. PR tree-optimization/110915 gcc/ChangeLog: * match.pd (min_value, max_value): Extend to vector constants. gcc/testsuite/ChangeLog: * gcc.dg/pr110915-1.c: New test. * gcc.dg/pr110915-10.c: New test. * gcc.dg/pr110915-11.c: New test. * gcc.dg/pr110915-12.c: New test. * gcc.dg/pr110915-2.c: New test. * gcc.dg/pr110915-3.c: New test. * gcc.dg/pr110915-4.c: New test. * gcc.dg/pr110915-5.c: New test. * gcc.dg/pr110915-6.c: New test. * gcc.dg/pr110915-7.c: New test. * gcc.dg/pr110915-8.c: New test. * gcc.dg/pr110915-9.c: New test. --- gcc/match.pd | 24 ++++++++++++++-------- gcc/testsuite/gcc.dg/pr110915-1.c | 31 ++++++++++++++++++++++++++++ gcc/testsuite/gcc.dg/pr110915-10.c | 33 ++++++++++++++++++++++++++++++ gcc/testsuite/gcc.dg/pr110915-11.c | 31 ++++++++++++++++++++++++++++ gcc/testsuite/gcc.dg/pr110915-12.c | 31 ++++++++++++++++++++++++++++ gcc/testsuite/gcc.dg/pr110915-2.c | 31 ++++++++++++++++++++++++++++ gcc/testsuite/gcc.dg/pr110915-3.c | 33 ++++++++++++++++++++++++++++++ gcc/testsuite/gcc.dg/pr110915-4.c | 33 ++++++++++++++++++++++++++++++ gcc/testsuite/gcc.dg/pr110915-5.c | 32 +++++++++++++++++++++++++++++ gcc/testsuite/gcc.dg/pr110915-6.c | 32 +++++++++++++++++++++++++++++ gcc/testsuite/gcc.dg/pr110915-7.c | 32 +++++++++++++++++++++++++++++ gcc/testsuite/gcc.dg/pr110915-8.c | 32 +++++++++++++++++++++++++++++ gcc/testsuite/gcc.dg/pr110915-9.c | 33 ++++++++++++++++++++++++++++++ 13 files changed, 400 insertions(+), 8 deletions(-) create mode 100644 gcc/testsuite/gcc.dg/pr110915-1.c create mode 100644 gcc/testsuite/gcc.dg/pr110915-10.c create mode 100644 gcc/testsuite/gcc.dg/pr110915-11.c create mode 100644 gcc/testsuite/gcc.dg/pr110915-12.c create mode 100644 gcc/testsuite/gcc.dg/pr110915-2.c create mode 100644 gcc/testsuite/gcc.dg/pr110915-3.c create mode 100644 gcc/testsuite/gcc.dg/pr110915-4.c create mode 100644 gcc/testsuite/gcc.dg/pr110915-5.c create mode 100644 gcc/testsuite/gcc.dg/pr110915-6.c create mode 100644 gcc/testsuite/gcc.dg/pr110915-7.c create mode 100644 gcc/testsuite/gcc.dg/pr110915-8.c create mode 100644 gcc/testsuite/gcc.dg/pr110915-9.c diff --git a/gcc/match.pd b/gcc/match.pd index 6a7edde5736..c01362ee359 100644 --- a/gcc/match.pd +++ b/gcc/match.pd @@ -2750,16 +2750,24 @@ DEFINE_INT_AND_FLOAT_ROUND_FN (RINT) & (bitpos / BITS_PER_UNIT))); })))) (match min_value - INTEGER_CST - (if ((INTEGRAL_TYPE_P (type) - || POINTER_TYPE_P(type)) - && wi::eq_p (wi::to_wide (t), wi::min_value (type))))) + uniform_integer_cst_p + (with { + tree int_cst = uniform_integer_cst_p (t); + tree inner_type = TREE_TYPE (int_cst); + } + (if ((INTEGRAL_TYPE_P (inner_type) + || POINTER_TYPE_P (inner_type)) + && wi::eq_p (wi::to_wide (int_cst), wi::min_value (inner_type)))))) (match max_value - INTEGER_CST - (if ((INTEGRAL_TYPE_P (type) - || POINTER_TYPE_P(type)) - && wi::eq_p (wi::to_wide (t), wi::max_value (type))))) + uniform_integer_cst_p + (with { + tree int_cst = uniform_integer_cst_p (t); + tree itype = TREE_TYPE (int_cst); + } + (if ((INTEGRAL_TYPE_P (itype) + || POINTER_TYPE_P (itype)) + && wi::eq_p (wi::to_wide (int_cst), wi::max_value (itype)))))) /* x > y && x != XXX_MIN --> x > y x > y && x == XXX_MIN --> false . */ diff --git a/gcc/testsuite/gcc.dg/pr110915-1.c b/gcc/testsuite/gcc.dg/pr110915-1.c new file mode 100644 index 00000000000..2e1e871b9a0 --- /dev/null +++ b/gcc/testsuite/gcc.dg/pr110915-1.c @@ -0,0 +1,31 @@ +/* { dg-do compile } */ +/* { dg-options "-O2 -fdump-tree-ifcombine" } */ +#define vector __attribute__((vector_size(sizeof(unsigned)*2))) + +#include + +vector signed and1(vector unsigned x, vector unsigned y) +{ + /* (x > y) & (x != 0) --> x > y */ + return (x > y) & (x != 0); +} + +vector signed and2(vector unsigned x, vector unsigned y) +{ + /* (x < y) & (x != UINT_MAX) --> x < y */ + return (x < y) & (x != UINT_MAX); +} + +vector signed and3(vector signed x, vector signed y) +{ + /* (x > y) & (x != INT_MIN) --> x > y */ + return (x > y) & (x != INT_MIN); +} + +vector signed and4(vector signed x, vector signed y) +{ + /* (x < y) & (x != INT_MAX) --> x < y */ + return (x < y) & (x != INT_MAX); +} + +/* { dg-final { scan-tree-dump-not " != " "ifcombine" } } */ diff --git a/gcc/testsuite/gcc.dg/pr110915-10.c b/gcc/testsuite/gcc.dg/pr110915-10.c new file mode 100644 index 00000000000..b0644bf3123 --- /dev/null +++ b/gcc/testsuite/gcc.dg/pr110915-10.c @@ -0,0 +1,33 @@ +/* { dg-do compile } */ +/* { dg-options "-O2 -fdump-tree-optimized" } */ +#define vector __attribute__((vector_size(sizeof(unsigned)*2))) + +#include + +vector unsigned or1(vector unsigned x, vector unsigned y) +{ + /* (x <= y) | (x != 0)) --> true */ + return (x <= y) | (x != 0); +} + +vector unsigned or2(vector unsigned x, vector unsigned y) +{ + /* (x >= y) | (x != UINT_MAX) --> true */ + return (x >= y) | (x != UINT_MAX); +} + +vector signed or3(vector signed x, vector signed y) +{ + /* (x <= y) | (x != INT_MIN) --> true */ + return (x <= y) | (x != INT_MIN); +} + +vector signed or4(vector signed x, vector signed y) +{ + /* (x >= y) | (x != INT_MAX) --> true */ + return (x >= y) | (x != INT_MAX); +} + +/* { dg-final { scan-tree-dump-not " != " "optimized" } } */ +/* { dg-final { scan-tree-dump-not " <= " "optimized" } } */ +/* { dg-final { scan-tree-dump-not " >= " "optimized" } } */ diff --git a/gcc/testsuite/gcc.dg/pr110915-11.c b/gcc/testsuite/gcc.dg/pr110915-11.c new file mode 100644 index 00000000000..0288e53b16b --- /dev/null +++ b/gcc/testsuite/gcc.dg/pr110915-11.c @@ -0,0 +1,31 @@ +/* { dg-do compile } */ +/* { dg-options "-O2 -fdump-tree-ifcombine" } */ +#define vector __attribute__((vector_size(sizeof(unsigned)*2))) + +#include + +vector unsigned or1(vector unsigned x, vector unsigned y) +{ + /* (x <= y) | (x == 0) --> x <= y */ + return (x <= y) | (x == 0); +} + +vector unsigned or2(vector unsigned x, vector unsigned y) +{ + /* (x >= y) | (x == UINT_MAX) --> x >= y */ + return (x >= y) | (x == UINT_MAX); +} + +vector signed or3(vector signed x, vector signed y) +{ + /* (x <= y) | (x == INT_MIN) --> x <= y */ + return (x <= y) | (x == INT_MIN); +} + +vector signed or4(vector signed x, vector signed y) +{ + /* (x >= y) | (x == INT_MAX) --> x >= y */ + return (x >= y) | (x == INT_MAX); +} + +/* { dg-final { scan-tree-dump-not " == " "ifcombine" } } */ diff --git a/gcc/testsuite/gcc.dg/pr110915-12.c b/gcc/testsuite/gcc.dg/pr110915-12.c new file mode 100644 index 00000000000..054a077ce3e --- /dev/null +++ b/gcc/testsuite/gcc.dg/pr110915-12.c @@ -0,0 +1,31 @@ +/* { dg-do compile } */ +/* { dg-options "-O2 -fdump-tree-dce3" } */ +#define vector __attribute__((vector_size(sizeof(unsigned)*2))) + +#include + +vector unsigned or1(vector unsigned x, vector unsigned y) +{ + /* (x <= y) | (x == 0) --> x <= y */ + return (x <= y) | (x == 0); +} + +vector unsigned or2(vector unsigned x, vector unsigned y) +{ + /* (x >= y) | (x == UINT_MAX) --> x >= y */ + return (x >= y) | (x == UINT_MAX); +} + +vector signed or3(vector signed x, vector signed y) +{ + /* (x <= y) | (x == INT_MIN) --> x <= y */ + return (x <= y) | (x == INT_MIN); +} + +vector signed or4(vector signed x, vector signed y) +{ + /* (x >= y) | (x == INT_MAX) --> x >= y */ + return (x >= y) | (x == INT_MAX); +} + +/* { dg-final { scan-tree-dump-not " == " "dce3" } } */ diff --git a/gcc/testsuite/gcc.dg/pr110915-2.c b/gcc/testsuite/gcc.dg/pr110915-2.c new file mode 100644 index 00000000000..3962b152078 --- /dev/null +++ b/gcc/testsuite/gcc.dg/pr110915-2.c @@ -0,0 +1,31 @@ +/* { dg-do compile } */ +/* { dg-options "-O2 -fdump-tree-optimized" } */ +#define vector __attribute__((vector_size(sizeof(unsigned)*2))) + +#include + +vector signed and1(vector unsigned x, vector unsigned y) +{ + /* (x > y) & (x != 0) --> x > y */ + return (x > y) & (x != 0); +} + +vector signed and2(vector unsigned x, vector unsigned y) +{ + /* (x < y) & (x != UINT_MAX) --> x < y */ + return (x < y) & (x != UINT_MAX); +} + +vector signed and3(vector signed x, vector signed y) +{ + /* (x > y) & (x != INT_MIN) --> x > y */ + return (x > y) & (x != INT_MIN); +} + +vector signed and4(vector signed x, vector signed y) +{ + /* (x < y) & (x != INT_MAX) --> x < y */ + return (x < y) & (x != INT_MAX); +} + +/* { dg-final { scan-tree-dump-not " != " "optimized" } } */ diff --git a/gcc/testsuite/gcc.dg/pr110915-3.c b/gcc/testsuite/gcc.dg/pr110915-3.c new file mode 100644 index 00000000000..c6462b59526 --- /dev/null +++ b/gcc/testsuite/gcc.dg/pr110915-3.c @@ -0,0 +1,33 @@ +/* { dg-do compile } */ +/* { dg-options "-O2 -fdump-tree-ifcombine" } */ +#define vector __attribute__((vector_size(sizeof(unsigned)*2))) + +#include + +vector signed and1(vector unsigned x, vector unsigned y) +{ + /* (x > y) & (x == 0) --> false */ + return (x > y) & (x == 0); +} + +vector signed and2(vector unsigned x, vector unsigned y) +{ + /* (x < y) & (x == UINT_MAX) --> false */ + return (x < y) & (x == UINT_MAX); +} + +vector signed and3(vector signed x, vector signed y) +{ + /* (x > y) & (x == INT_MIN) --> false */ + return (x > y) & (x == INT_MIN); +} + +vector signed and4(vector signed x, vector signed y) +{ + /* (x < y) & (x == INT_MAX) --> false */ + return (x < y) & (x == INT_MAX); +} + +/* { dg-final { scan-tree-dump-not " == " "ifcombine" } } */ +/* { dg-final { scan-tree-dump-not " > " "ifcombine" } } */ +/* { dg-final { scan-tree-dump-not " < " "ifcombine" } } */ diff --git a/gcc/testsuite/gcc.dg/pr110915-4.c b/gcc/testsuite/gcc.dg/pr110915-4.c new file mode 100644 index 00000000000..5b28ccdd321 --- /dev/null +++ b/gcc/testsuite/gcc.dg/pr110915-4.c @@ -0,0 +1,33 @@ +/* { dg-do compile } */ +/* { dg-options "-O2 -fdump-tree-optimized" } */ +#define vector __attribute__((vector_size(sizeof(unsigned)*2))) + +#include + +vector signed and1(vector unsigned x, vector unsigned y) +{ + /* (x > y) & (x == 0) --> false */ + return (x > y) & (x == 0); +} + +vector signed and2(vector unsigned x, vector unsigned y) +{ + /* (x < y) & (x == UINT_MAX) --> false */ + return (x < y) & (x == UINT_MAX); +} + +vector signed and3(vector signed x, vector signed y) +{ + /* (x > y) & (x == INT_MIN) --> false */ + return (x > y) & (x == INT_MIN); +} + +vector signed and4(vector signed x, vector signed y) +{ + /* (x < y) & (x == INT_MAX) --> false */ + return (x < y) & (x == INT_MAX); +} + +/* { dg-final { scan-tree-dump-not " == " "optimized" } } */ +/* { dg-final { scan-tree-dump-not " > " "optimized" } } */ +/* { dg-final { scan-tree-dump-not " < " "optimized" } } */ diff --git a/gcc/testsuite/gcc.dg/pr110915-5.c b/gcc/testsuite/gcc.dg/pr110915-5.c new file mode 100644 index 00000000000..a8b871d5bca --- /dev/null +++ b/gcc/testsuite/gcc.dg/pr110915-5.c @@ -0,0 +1,32 @@ +/* { dg-do compile } */ +/* { dg-options "-O2 -fdump-tree-ifcombine" } */ +#define vector __attribute__((vector_size(sizeof(unsigned)*2))) + +#include + +vector signed and1(vector unsigned x, vector unsigned y) +{ + /* (x <= y) & (x == 0) --> x == 0 */ + return (x <= y) & (x == 0); +} + +vector signed and2(vector unsigned x, vector unsigned y) +{ + /* (x >= y) & (x == UINT_MAX) --> x == UINT_MAX */ + return (x >= y) & (x == UINT_MAX); +} + +vector signed and3(vector signed x, vector signed y) +{ + /* (x <= y) & (x == INT_MIN) --> x == INT_MIN */ + return (x <= y) & (x == INT_MIN); +} + +vector signed and4(vector signed x, vector signed y) +{ + /* (x >= y) & (x == INT_MAX) --> x == INT_MAX */ + return (x >= y) & (x == INT_MAX); +} + +/* { dg-final { scan-tree-dump-not " <= " "ifcombine" } } */ +/* { dg-final { scan-tree-dump-not " >= " "ifcombine" } } */ diff --git a/gcc/testsuite/gcc.dg/pr110915-6.c b/gcc/testsuite/gcc.dg/pr110915-6.c new file mode 100644 index 00000000000..a3b9cc02a4b --- /dev/null +++ b/gcc/testsuite/gcc.dg/pr110915-6.c @@ -0,0 +1,32 @@ +/* { dg-do compile } */ +/* { dg-options "-O2 -fdump-tree-optimized" } */ +#define vector __attribute__((vector_size(sizeof(unsigned)*2))) + +#include + +vector signed and1(vector unsigned x, vector unsigned y) +{ + /* (x <= y) & (x == 0) --> x == 0 */ + return (x <= y) & (x == 0); +} + +vector signed and2(vector unsigned x, vector unsigned y) +{ + /* (x >= y) & (x == UINT_MAX) --> x == UINT_MAX */ + return (x >= y) & (x == UINT_MAX); +} + +vector signed and3(vector signed x, vector signed y) +{ + /* (x <= y) & (x == INT_MIN) --> x == INT_MIN */ + return (x <= y) & (x == INT_MIN); +} + +vector signed and4(vector signed x, vector signed y) +{ + /* (x >= y) & (x == INT_MAX) --> x == INT_MAX */ + return (x >= y) & (x == INT_MAX); +} + +/* { dg-final { scan-tree-dump-not " <= " "optimized" } } */ +/* { dg-final { scan-tree-dump-not " >= " "optimized" } } */ diff --git a/gcc/testsuite/gcc.dg/pr110915-7.c b/gcc/testsuite/gcc.dg/pr110915-7.c new file mode 100644 index 00000000000..fd331e90e4a --- /dev/null +++ b/gcc/testsuite/gcc.dg/pr110915-7.c @@ -0,0 +1,32 @@ +/* { dg-do compile } */ +/* { dg-options "-O2 -fdump-tree-ifcombine" } */ +#define vector __attribute__((vector_size(sizeof(unsigned)*2))) + +#include + +vector signed or1(vector unsigned x, vector unsigned y) +{ + /* (x > y) | (x != 0) --> x != 0 */ + return (x > y) | (x != 0); +} + +vector signed or2(vector unsigned x, vector unsigned y) +{ + /* (x < y) | (x != UINT_MAX) --> x != UINT_MAX */ + return (x < y) | (x != UINT_MAX); +} + +vector signed or3(vector signed x, vector signed y) +{ + /* (x > y) | (x != INT_MIN) --> x != INT_MIN */ + return (x > y) | (x != INT_MIN); +} + +vector signed or4(vector signed x, vector signed y) +{ + /* (x < y) | (x != INT_MAX) --> x != INT_MAX */ + return (x < y) | (x != INT_MAX); +} + +/* { dg-final { scan-tree-dump-not " > " "ifcombine" } } */ +/* { dg-final { scan-tree-dump-not " < " "ifcombine" } } */ diff --git a/gcc/testsuite/gcc.dg/pr110915-8.c b/gcc/testsuite/gcc.dg/pr110915-8.c new file mode 100644 index 00000000000..fae533cbf22 --- /dev/null +++ b/gcc/testsuite/gcc.dg/pr110915-8.c @@ -0,0 +1,32 @@ +/* { dg-do compile } */ +/* { dg-options "-O2 -fdump-tree-optimized" } */ +#define vector __attribute__((vector_size(sizeof(unsigned)*2))) + +#include + +vector signed or1(vector unsigned x, vector unsigned y) +{ + /* (x > y) | (x != 0) --> x != 0 */ + return (x > y) | (x != 0); +} + +vector signed or2(vector unsigned x, vector unsigned y) +{ + /* (x < y) | (x != UINT_MAX) --> x != UINT_MAX */ + return (x < y) | (x != UINT_MAX); +} + +vector signed or3(vector signed x, vector signed y) +{ + /* (x > y) | (x != INT_MIN) --> x != INT_MIN */ + return (x > y) | (x != INT_MIN); +} + +vector signed or4(vector signed x, vector signed y) +{ + /* (x < y) | (x != INT_MAX) --> x != INT_MAX */ + return (x < y) | (x != INT_MAX); +} + +/* { dg-final { scan-tree-dump-not " > " "optimized" } } */ +/* { dg-final { scan-tree-dump-not " < " "optimized" } } */ diff --git a/gcc/testsuite/gcc.dg/pr110915-9.c b/gcc/testsuite/gcc.dg/pr110915-9.c new file mode 100644 index 00000000000..07aa08ee00b --- /dev/null +++ b/gcc/testsuite/gcc.dg/pr110915-9.c @@ -0,0 +1,33 @@ +/* { dg-do compile } */ +/* { dg-options "-O2 -fdump-tree-ifcombine" } */ +#define vector __attribute__((vector_size(sizeof(unsigned)*2))) + +#include + +vector signed or1(vector unsigned x, vector unsigned y) +{ + /* (x <= y) | (x != 0) --> true */ + return (x <= y) | (x != 0); +} + +vector signed or2(vector unsigned x, vector unsigned y) +{ + /* (x >= y) | (x != UINT_MAX) --> true */ + return (x >= y) | (x != UINT_MAX); +} + +vector signed or3(vector signed x, vector signed y) +{ + /* (x <= y) | (x != INT_MIN) --> true */ + return (x <= y) | (x != INT_MIN); +} + +vector signed or4(vector signed x, vector signed y) +{ + /* (x >= y) | (x != INT_MAX) --> true */ + return (x >= y) | (x != INT_MAX); +} + +/* { dg-final { scan-tree-dump-not " != " "ifcombine" } } */ +/* { dg-final { scan-tree-dump-not " <= " "ifcombine" } } */ +/* { dg-final { scan-tree-dump-not " >= " "ifcombine" } } */