From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: Received: from EUR05-DB8-obe.outbound.protection.outlook.com (mail-db8eur05on2052.outbound.protection.outlook.com [40.107.20.52]) by sourceware.org (Postfix) with ESMTPS id 32DBA3858403 for ; Thu, 25 Nov 2021 09:08:09 +0000 (GMT) DMARC-Filter: OpenDMARC Filter v1.4.1 sourceware.org 32DBA3858403 Received: from AS8P250CA0006.EURP250.PROD.OUTLOOK.COM (2603:10a6:20b:330::11) by GV1PR08MB7380.eurprd08.prod.outlook.com (2603:10a6:150:24::7) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.20.4690.26; Thu, 25 Nov 2021 09:08:02 +0000 Received: from AM5EUR03FT063.eop-EUR03.prod.protection.outlook.com (2603:10a6:20b:330:cafe::db) by AS8P250CA0006.outlook.office365.com (2603:10a6:20b:330::11) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.20.4713.22 via Frontend Transport; Thu, 25 Nov 2021 09:08:02 +0000 X-MS-Exchange-Authentication-Results: spf=pass (sender IP is 63.35.35.123) smtp.mailfrom=arm.com; dkim=pass (signature was verified) header.d=armh.onmicrosoft.com;dmarc=pass action=none header.from=arm.com; Received-SPF: Pass (protection.outlook.com: domain of arm.com designates 63.35.35.123 as permitted sender) receiver=protection.outlook.com; client-ip=63.35.35.123; helo=64aa7808-outbound-1.mta.getcheckrecipient.com; Received: from 64aa7808-outbound-1.mta.getcheckrecipient.com (63.35.35.123) by AM5EUR03FT063.mail.protection.outlook.com (10.152.16.226) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.20.4713.19 via Frontend Transport; Thu, 25 Nov 2021 09:08:02 +0000 Received: ("Tessian outbound c61f076cbd30:v110"); Thu, 25 Nov 2021 09:08:02 +0000 X-CR-MTA-TID: 64aa7808 Received: from 08e687c18c67.1 by 64aa7808-outbound-1.mta.getcheckrecipient.com id CAA7B7C1-C0F8-46D0-A0ED-7E889169FAFC.1; Thu, 25 Nov 2021 09:07:56 +0000 Received: from EUR05-AM6-obe.outbound.protection.outlook.com by 64aa7808-outbound-1.mta.getcheckrecipient.com with ESMTPS id 08e687c18c67.1 (version=TLSv1.2 cipher=ECDHE-RSA-AES256-GCM-SHA384); Thu, 25 Nov 2021 09:07:56 +0000 ARC-Seal: i=1; a=rsa-sha256; s=arcselector9901; d=microsoft.com; cv=none; b=ZqbYi4itMs3/NygcB7E8ceRtpr1HqB5XSbAlUDIDoAjmX6nFKLH7ffFGlst8v2bHxEp2dIMF+0lWX5FbBqmNkoRcHYvpVFe9aM5v6jf9KcyuY/91HIy4FSnvl68OU7rjpAzTKulP/sR96FlPp2pQ8zv49AlS/6Px052CGyG0goJhw3kEgugqtukq7vRUDU1TmIWLodUMr4+8WkIY5dug1LqAWkVoK52MDFQfRCPpvLyV8zPxbT2hnUxxJPQ9TfPTdw5y4bIol256oW2ieu2Br8ntLtOCa1NfcgLIO91NidOczOyLdu6m9dCwvU2SiEL/DgpoFFiUZpbq3i7hZY2VJw== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=microsoft.com; s=arcselector9901; h=From:Date:Subject:Message-ID:Content-Type:MIME-Version:X-MS-Exchange-AntiSpam-MessageData-ChunkCount:X-MS-Exchange-AntiSpam-MessageData-0:X-MS-Exchange-AntiSpam-MessageData-1; bh=wglRQN1M6A10oXN+8ZBQKfC/39dBuuC1XwleeGiO2V0=; b=Wpg9nVg6akdFbBI9WlPR1lR8M1wX4GWWILxXNDMploRDjsmoMWx1Uw66xml40MbOhz/mYBo75tLQDiEP/jsBViNteXynXCHFn3u8HcA6FQjobbTuPxfam/hNo3RtONFQq0Ds4wef6qlIoYCJlLRIbsM0ssybuN0wp/WxfU2NgM1ynbL5vJ7AJH9dceICL4rcNDxlmjYN6I3RuZ4iWvaJeUGhql7oQbSkt8w3NCxoaJ5JEoa0RzI5ByiilsWxhUrt4tXDLhOeohgN2//zB7twSuHlGqS3sQpVRCkUWMlvTJ9zLyXTMNkvf4AtnNzdufkIO6STyvN8EsVCtyA/WItjcA== ARC-Authentication-Results: i=1; mx.microsoft.com 1; spf=pass smtp.mailfrom=arm.com; dmarc=pass action=none header.from=arm.com; dkim=pass header.d=arm.com; arc=none Received: from VI1PR08MB5325.eurprd08.prod.outlook.com (2603:10a6:803:13e::17) by VE1PR08MB5007.eurprd08.prod.outlook.com (2603:10a6:803:10c::32) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.20.4713.22; Thu, 25 Nov 2021 09:07:54 +0000 Received: from VI1PR08MB5325.eurprd08.prod.outlook.com ([fe80::12a:3d2c:81ff:8fcc]) by VI1PR08MB5325.eurprd08.prod.outlook.com ([fe80::12a:3d2c:81ff:8fcc%7]) with mapi id 15.20.4713.026; Thu, 25 Nov 2021 09:07:54 +0000 From: Tamar Christina To: Jakub Jelinek , Richard Biener CC: "gcc-patches@gcc.gnu.org" Subject: RE: [PATCH] match.pd: Fix up the recent bitmask_inv_cst_vector_p simplification [PR103417] Thread-Topic: [PATCH] match.pd: Fix up the recent bitmask_inv_cst_vector_p simplification [PR103417] Thread-Index: AQHX4dUUpNeqi+rY+k+D3E+M0VjZcawT8uyw Date: Thu, 25 Nov 2021 09:07:54 +0000 Message-ID: References: <20211125081834.GX2646553@tucnak> In-Reply-To: <20211125081834.GX2646553@tucnak> Accept-Language: en-US Content-Language: en-US X-MS-Has-Attach: X-MS-TNEF-Correlator: x-ts-tracking-id: CF5996731B2615478F77F2C8D6245982.0 x-checkrecipientchecked: true Authentication-Results-Original: dkim=none (message not signed) header.d=none;dmarc=none action=none header.from=arm.com; x-ms-publictraffictype: Email X-MS-Office365-Filtering-Correlation-Id: 3f625571-58d3-4585-8b23-08d9aff3158c x-ms-traffictypediagnostic: VE1PR08MB5007:|GV1PR08MB7380: X-Microsoft-Antispam-PRVS: x-checkrecipientrouted: true nodisclaimer: true x-ms-oob-tlc-oobclassifiers: OLM:3173;OLM:3173; X-MS-Exchange-SenderADCheck: 1 X-MS-Exchange-AntiSpam-Relay: 0 X-Microsoft-Antispam-Untrusted: BCL:0; X-Microsoft-Antispam-Message-Info-Original: BScTqePj4lc/dSaPd1KWgBrCi4+xOgzX+iIaqeqQtWidbKiB7IkxiIfJa4DRyh7nr+kNeP5p4EPJagc4ZbS3sJKChVCw32/adglN+lJaiEal3/mavFxGzWsIQNgpXUz6t5z/ZYARql/WOtPMLcZnHVErW49hGAvqP8Lv2tOE/ihB7UzBtP7hzDajNN4uLa0rd18n1N02YilDbKSzlsDvlwDEV8oiJLd19CPdcIYAs/XseApCTAPXW6ypdBaQ5VP9SayOPhRQ5QwQ1rkxDF3tYLfJoAT+rBq7Tp/YmH9X8LEiXgSiu1Nb1Ts4NworbnlrVaKDYqL5/XqbbwN6tgvcumar4whw25DHt0mllpVohe+wZtBEwcq0+jqXChGuspcElEhZAvW3/H0cJBUfn9AppJKJSbxp/A8ig2hc+XdCvze6zpdKiXcRkh6ON1YDIW57LoOCGSilB+7FDD3u4om11shxP8f2kusG/KqlP4IsZzLe3HYZ5SIG4VkyNqjXYGrdEhKgo1Do7oEhv2WEY5A5cSqtD7FV4l1ML7fBeojWAj+pBuUzGUDAlZFKTno2v1Nr3W1m7izqgHNlSH8GE8RP3Phh3bwl5PhBJYYCF03BLWWg8y19wvoAcxPRHVALSgkzEb3sNpWd6UETx5Cfczz7uII1uPwNrjTu//33iSo5AQzhlUQIe3O8Tm/16lt8M+8FZIBN2V4uomjpPzj5jB7qyIH5zVRZq0S8RmiX1qlzDZhQuj1zmtui2BgVF1Y8gHhb7wOGrxwVQt+w4E9NAErt3Pq+vfS5LQ18wEdU31j0RIyAs25mISXX30jJxcRlZjP8VSLMcY+uIb6kLq+Cs5Awsg== X-Forefront-Antispam-Report-Untrusted: CIP:255.255.255.255; CTRY:; LANG:en; SCL:1; SRV:; IPV:NLI; SFV:NSPM; H:VI1PR08MB5325.eurprd08.prod.outlook.com; PTR:; CAT:NONE; SFS:(4636009)(366004)(7696005)(33656002)(38070700005)(122000001)(186003)(66446008)(83380400001)(38100700002)(8676002)(316002)(508600001)(53546011)(6506007)(4326008)(9686003)(55016003)(64756008)(66946007)(2906002)(84970400001)(86362001)(52536014)(76116006)(5660300002)(66476007)(71200400001)(8936002)(4001150100001)(110136005)(26005)(66556008); DIR:OUT; SFP:1101; Content-Type: text/plain; charset="us-ascii" Content-Transfer-Encoding: quoted-printable MIME-Version: 1.0 X-MS-Exchange-Transport-CrossTenantHeadersStamped: VE1PR08MB5007 Original-Authentication-Results: dkim=none (message not signed) header.d=none;dmarc=none action=none header.from=arm.com; X-EOPAttributedMessage: 0 X-MS-Exchange-Transport-CrossTenantHeadersStripped: AM5EUR03FT063.eop-EUR03.prod.protection.outlook.com X-MS-Office365-Filtering-Correlation-Id-Prvs: 5349f028-b3fa-4411-b1c8-08d9aff3110e X-Microsoft-Antispam: BCL:0; X-Microsoft-Antispam-Message-Info: RAHV6nt5F2pMyslKNPF+PflYdwCbxjTNe+cc0L0kr5JgEShLfBwLqL937rysaAyC6dvysdXLlcj/9yM7inrSzjqTfTJVzwmo9LGuTazaRrqNnIlIY1rhXL1FRqvd4zHLTuQChmRO1yxP9iK9OSOKUT4oXtJcdCsf4A4SexFTOZ8N+NmSo1qlvG+bCi46WQyCtAqcCMuTJI4kAp3JTWPg76pqvKks6QRLBriDZuiog93pznuL5zicuQqhseeYjMDCITkMccPHlm7+qRh6l/VYq3WLDbxVmxRmn6+bPjjUNFkS5RB5OOrXq8/glJunzPB4wgV4e74QQ3aoqc+qEPxYpPBxg01RGS/G1PAwoSfy1tSCkdp4yvdJAqn/FfIuWBdgqNYgbcyRdfgP5Sbp0H1XqKDOmoV7NiwyL2BHsVcRiKhl37LYl+GXlOQzJlnBdMW8jZF3zs7Tsz3DrCmJYwUqPaEwfNjC3qhDvWL0lP/qeejDKXlBd7QjI0R3+gUp2PDFf+O7+0TVhHbW0SIicUDPBcAAUG2Hb74pm488PFONguDfJSXw/rW47dICSiisrKJxsJBUyX0d1A/mmRhzs7o6D8Lo4aO2VawW8K7Yo249yIebIlnI6PPTe9Mq5gQbdSCl+ny6fLi3CJqlxFSC+xlJZWSDAuZW0y4AbhSfr1Xl0a89WVCJALU9iKLZ47GVvMjduKbiAbkfSdIp7bKMHQc2h5vYwZcOybqs7WxLxX1W4dU53EvdgjlXuRTQvP0U6ZLaTb1postSLUtBva+xfM2ZO4xTwR0IafVpx0xe31TbaGwgkLly5Kncb8ElaRV7sCA5dIpMV6XDnhi5YTGFp5jlKw== X-Forefront-Antispam-Report: CIP:63.35.35.123; CTRY:IE; LANG:en; SCL:1; SRV:; IPV:CAL; SFV:NSPM; H:64aa7808-outbound-1.mta.getcheckrecipient.com; PTR:ec2-63-35-35-123.eu-west-1.compute.amazonaws.com; CAT:NONE; SFS:(4636009)(36840700001)(46966006)(70206006)(53546011)(86362001)(70586007)(508600001)(52536014)(47076005)(186003)(2906002)(36860700001)(316002)(26005)(84970400001)(4001150100001)(356005)(83380400001)(336012)(82310400004)(81166007)(110136005)(7696005)(8936002)(9686003)(8676002)(6506007)(33656002)(55016003)(4326008)(5660300002); DIR:OUT; SFP:1101; X-OriginatorOrg: arm.com X-MS-Exchange-CrossTenant-OriginalArrivalTime: 25 Nov 2021 09:08:02.2322 (UTC) X-MS-Exchange-CrossTenant-Network-Message-Id: 3f625571-58d3-4585-8b23-08d9aff3158c X-MS-Exchange-CrossTenant-Id: f34e5979-57d9-4aaa-ad4d-b122a662184d X-MS-Exchange-CrossTenant-OriginalAttributedTenantConnectingIp: TenantId=f34e5979-57d9-4aaa-ad4d-b122a662184d; Ip=[63.35.35.123]; Helo=[64aa7808-outbound-1.mta.getcheckrecipient.com] X-MS-Exchange-CrossTenant-AuthSource: AM5EUR03FT063.eop-EUR03.prod.protection.outlook.com X-MS-Exchange-CrossTenant-AuthAs: Anonymous X-MS-Exchange-CrossTenant-FromEntityHeader: HybridOnPrem X-MS-Exchange-Transport-CrossTenantHeadersStamped: GV1PR08MB7380 X-Spam-Status: No, score=-7.6 required=5.0 tests=BAYES_00, DKIM_SIGNED, DKIM_VALID, RCVD_IN_MSPIKE_H2, SPF_HELO_PASS, SPF_PASS, TXREP, UNPARSEABLE_RELAY autolearn=ham autolearn_force=no version=3.4.4 X-Spam-Checker-Version: SpamAssassin 3.4.4 (2020-01-24) 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-List-Received-Date: Thu, 25 Nov 2021 09:08:11 -0000 > -----Original Message----- > From: Jakub Jelinek > Sent: Thursday, November 25, 2021 8:19 AM > To: Richard Biener > Cc: Tamar Christina ; gcc-patches@gcc.gnu.org > Subject: [PATCH] match.pd: Fix up the recent bitmask_inv_cst_vector_p > simplification [PR103417] >=20 > Hi! >=20 > The following testcase is miscompiled since the r12-5489-g0888d6bbe97e10 > changes. > The simplification triggers on > (x & 4294967040U) >=3D 0U > and turns it into: > x <=3D 255U > which is incorrect, it should fold to 1 because unsigned >=3D 0U is alway= s true > and normally the > /* Non-equality compare simplifications from fold_binary */ > (if (wi::to_wide (cst) =3D=3D min) > (if (cmp =3D=3D GE_EXPR) > { constant_boolean_node (true, type); }) simplification folds tha= t, but > this simplification was done earlier. >=20 > The simplification correctly doesn't include lt which has the same reason= why > it shouldn't be handled, we'll fold it to 0 elsewhere. >=20 > But, IMNSHO while it isn't incorrect to handle le and gt there, it is > unnecessary. Because (x & cst) <=3D 0U and (x & cst) > 0U should never a= ppear, > again in > /* Non-equality compare simplifications from fold_binary */ we have a > simplification for it: > (if (cmp =3D=3D LE_EXPR) > (eq @2 @1)) > (if (cmp =3D=3D GT_EXPR) > (ne @2 @1)))) > This is done for > (cmp (convert?@2 @0) uniform_integer_cst_p@1) and so should be done > for both integers and vectors. > As the bitmask_inv_cst_vector_p simplification only handles eq and ne for > signed types, I think it can be simplified to just following patch. >=20 > Bootstrapped/regtested on x86_64-linux and i686-linux, ok for trunk? >=20 > I wonder if (for cst (VECTOR_CST INTEGER_CST) is good for the best size o= f *- > match.c, wouldn't accepting just CONSTANT_CLASS_P@1 and then just say in > bitmask_inv_cst_vector_p return NULL_TREE if it isn't INTEGER_CST or > VECTOR_CST? >=20 > Also, without/with this patch I see on i686-linux (can be reproduced with > RUNTESTFLAGS=3D"--target_board=3Dunix/-m32/-mno-sse dg.exp=3D'bic-bitmask= * > signbit-2*'" > too): > FAIL: gcc.dg/bic-bitmask-10.c scan-tree-dump dce7 "<=3D\\\\s*.+{ 255,.+}" > FAIL: gcc.dg/bic-bitmask-11.c scan-tree-dump dce7 ">\\\\s*.+{ 255,.+}" > FAIL: gcc.dg/bic-bitmask-12.c scan-tree-dump dce7 "<=3D\\\\s*.+{ 255,.+}" > FAIL: gcc.dg/bic-bitmask-2.c scan-tree-dump-times dce7 > "<=3D\\\\s*.+{ 255,.+}" 1 > FAIL: gcc.dg/bic-bitmask-23.c (test for excess errors) > FAIL: gcc.dg/bic-bitmask-23.c scan-tree-dump dce7 "<=3D\\\\s*.+{ 255, 15,= 1, > 65535 }" > FAIL: gcc.dg/bic-bitmask-3.c scan-tree-dump-times dce7 > "<=3D\\\\s*.+{ 255,.+}" 1 > FAIL: gcc.dg/bic-bitmask-4.c scan-tree-dump-times dce7 "=3D\\\\s*.+{ 1,.+= }" 1 > FAIL: gcc.dg/bic-bitmask-5.c scan-tree-dump-times dce7 ">\\\\s*.+{ 255,.+= }" > 1 > FAIL: gcc.dg/bic-bitmask-6.c scan-tree-dump-times dce7 > "<=3D\\\\s*.+{ 255,.+}" 1 > FAIL: gcc.dg/bic-bitmask-8.c scan-tree-dump-times dce7 ">\\\\s*.+{ 1,.+}"= 1 > FAIL: gcc.dg/bic-bitmask-9.c scan-tree-dump dce7 > "&\\\\s*.+{ 4294967290,.+}" > FAIL: gcc.dg/signbit-2.c scan-tree-dump optimized "\\\\s+>\\\\s+{ 0(, 0)+= }" > Those tests use vect_int effective target, but AFAIK that can be used onl= y in > *.dg/vect/ because it relies on vect.exp enabling options to support > vectorization on the particular target (e.g. for i686-linux that -msse2). > I think there isn't other way to get the DEFAULT_VECTCFLAGS into dg- > options other than having the test driven by vect.exp. Yeah, I now see that vect_int is different from some of the other effective= target checks like the SVE one. I'll move the ones testing the vector code to vect and leave the scalars wh= ere they are. Thanks, Tamar >=20 > And, finally, I've noticed incorrect formatting in the new > bitmask_inv_cst_vector_p routine: > do { > if (idx > 0) > cst =3D vector_cst_elt (t, idx); > ... > builder.quick_push (newcst); > } while (++idx < nelts); > It should be > do > { > if (idx > 0) > cst =3D vector_cst_elt (t, idx); > ... > builder.quick_push (newcst); > } > while (++idx < nelts); >=20 > 2021-11-25 Jakub Jelinek >=20 > PR tree-optimization/103417 > * match.pd ((X & Y) CMP 0): Only handle eq and ne. Commonalize > common tests. >=20 > * gcc.c-torture/execute/pr103417.c: New test. >=20 > --- gcc/match.pd.jj 2021-11-24 11:46:03.191918052 +0100 > +++ gcc/match.pd 2021-11-24 22:33:43.852575772 +0100 > @@ -5214,20 +5214,16 @@ (define_operator_list SYNC_FETCH_AND_AND > /* Transform comparisons of the form (X & Y) CMP 0 to X CMP2 Z > where ~Y + 1 =3D=3D pow2 and Z =3D ~Y. */ (for cst (VECTOR_CST INTE= GER_CST) > - (for cmp (le eq ne ge gt) > - icmp (le le gt le gt) > - (simplify > - (cmp (bit_and:c@2 @0 cst@1) integer_zerop) > - (with { tree csts =3D bitmask_inv_cst_vector_p (@1); } > - (switch > - (if (csts && TYPE_UNSIGNED (TREE_TYPE (@1)) > - && (VECTOR_TYPE_P (TREE_TYPE (@1)) || single_use (@2))) > - (icmp @0 { csts; })) > - (if (csts && !TYPE_UNSIGNED (TREE_TYPE (@1)) > - && (cmp =3D=3D EQ_EXPR || cmp =3D=3D NE_EXPR) > - && (VECTOR_TYPE_P (TREE_TYPE (@1)) || single_use (@2))) > + (for cmp (eq ne) > + icmp (le gt) > + (simplify > + (cmp (bit_and:c@2 @0 cst@1) integer_zerop) > + (with { tree csts =3D bitmask_inv_cst_vector_p (@1); } > + (if (csts && (VECTOR_TYPE_P (TREE_TYPE (@1)) || single_use (@2))) > + (if (TYPE_UNSIGNED (TREE_TYPE (@1))) > + (icmp @0 { csts; }) > (with { tree utype =3D unsigned_type_for (TREE_TYPE (@1)); } > - (icmp (convert:utype @0) { csts; })))))))) > + (icmp (convert:utype @0) { csts; })))))))) >=20 > /* -A CMP -B -> B CMP A. */ > (for cmp (tcc_comparison) > --- gcc/testsuite/gcc.c-torture/execute/pr103417.c.jj 2021-11-24 > 22:36:00.732626424 +0100 > +++ gcc/testsuite/gcc.c-torture/execute/pr103417.c 2021-11-24 > 22:35:43.964865218 +0100 > @@ -0,0 +1,11 @@ > +/* PR tree-optimization/103417 */ > + > +struct { int a : 8; int b : 24; } c =3D { 0, 1 }; > + > +int > +main () > +{ > + if (c.b && !c.b) > + __builtin_abort (); > + return 0; > +} >=20 > Jakub