From patchwork Wed Nov 23 14:24:44 2022 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Tamar Christina X-Patchwork-Id: 25010 Return-Path: Delivered-To: ouuuleilei@gmail.com Received: by 2002:adf:f944:0:0:0:0:0 with SMTP id q4csp2821916wrr; Wed, 23 Nov 2022 06:25:57 -0800 (PST) X-Google-Smtp-Source: AA0mqf7lLMVuTDWjug4tPYUBf3I4ii3xycG8oXK2e7VFIuTbnYp6zQHSOfFJxwqhon9m5XF2pxYO X-Received: by 2002:aa7:c58f:0:b0:469:668:3a63 with SMTP id g15-20020aa7c58f000000b0046906683a63mr23522408edq.331.1669213556734; Wed, 23 Nov 2022 06:25:56 -0800 (PST) Received: from sourceware.org (server2.sourceware.org. [8.43.85.97]) by mx.google.com with ESMTPS id m9-20020a170906848900b007829d30452asi12009253ejx.583.2022.11.23.06.25.56 for (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Wed, 23 Nov 2022 06:25:56 -0800 (PST) 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=VCmvhYKd; arc=fail (signature failed); 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 A41A93853D68 for ; Wed, 23 Nov 2022 14:25:55 +0000 (GMT) DKIM-Filter: OpenDKIM Filter v2.11.0 sourceware.org A41A93853D68 DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gcc.gnu.org; s=default; t=1669213555; bh=e/dXnxVB7wf2ylhJ6JB/AHXyCZIHcipmOSJcym8TAIM=; h=Date:To:Cc:Subject:List-Id:List-Unsubscribe:List-Archive: List-Post:List-Help:List-Subscribe:From:Reply-To:From; b=VCmvhYKdWIxh/qGrL259GWXNVzBTOldvf9bSFiEGcFSNpiJKnSVgejwKEkJD0rfel fzrMFkdsb/1nowLaDx+CUj0oaXzCgJ6gCnKB3okqbLZ4fkWV2SX41PHq6gZZKYviqy Dz/3kOwAQjgUc9tdPGAH7r2NkKGWexIBrGOxgNw8= X-Original-To: gcc-patches@gcc.gnu.org Delivered-To: gcc-patches@gcc.gnu.org Received: from EUR01-DB5-obe.outbound.protection.outlook.com (mail-eopbgr150057.outbound.protection.outlook.com [40.107.15.57]) by sourceware.org (Postfix) with ESMTPS id D7FAE3853D65 for ; Wed, 23 Nov 2022 14:25:08 +0000 (GMT) DMARC-Filter: OpenDMARC Filter v1.4.1 sourceware.org D7FAE3853D65 Received: from FR0P281CA0120.DEUP281.PROD.OUTLOOK.COM (2603:10a6:d10:a8::10) by DB9PR08MB6409.eurprd08.prod.outlook.com (2603:10a6:10:23c::15) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.20.5857.17; Wed, 23 Nov 2022 14:25:04 +0000 Received: from VI1EUR03FT004.eop-EUR03.prod.protection.outlook.com (2603:10a6:d10:a8:cafe::6b) by FR0P281CA0120.outlook.office365.com (2603:10a6:d10:a8::10) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.20.5857.17 via Frontend Transport; Wed, 23 Nov 2022 14:25:04 +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; pr=C Received: from 64aa7808-outbound-1.mta.getcheckrecipient.com (63.35.35.123) by VI1EUR03FT004.mail.protection.outlook.com (100.127.144.92) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.20.5834.8 via Frontend Transport; Wed, 23 Nov 2022 14:25:03 +0000 Received: ("Tessian outbound aeae1c7b66fd:v130"); Wed, 23 Nov 2022 14:25:03 +0000 X-CheckRecipientChecked: true X-CR-MTA-CID: cef01769d96c8498 X-CR-MTA-TID: 64aa7808 Received: from 95bbbfb76d0e.2 by 64aa7808-outbound-1.mta.getcheckrecipient.com id EAC2F101-2BC7-46AF-AA12-31C7309E0F3A.1; Wed, 23 Nov 2022 14:24:55 +0000 Received: from EUR05-VI1-obe.outbound.protection.outlook.com by 64aa7808-outbound-1.mta.getcheckrecipient.com with ESMTPS id 95bbbfb76d0e.2 (version=TLSv1.2 cipher=ECDHE-RSA-AES256-GCM-SHA384); Wed, 23 Nov 2022 14:24:55 +0000 ARC-Seal: i=1; a=rsa-sha256; s=arcselector9901; d=microsoft.com; cv=none; b=iOdW8yTDX/9M+rEkLAtLzjreTExFAe7sBuLoB75wSCI6LF/0a1Bbj7Z7PskmWzGW//uxA2Zhw+DvOznFottX/NZ1YY66batz6YMLqrm15pC/2wvBaoKldsBnn18Ku3ulXfZber51rxAttWzRWcdN27Hncj9vj0c5Et1aWowQ6Bn3JtqZHFBCo05Y2u9VTJnYvCkIA+lg4peMQbqmA0Fkf9H2nNA+UGD6PiQAuAlIJt9O3fDh2StnMvCQGUTFdZd/P6MiCaxns4gP4NNZ253W3qR2hQ7aN0ns1VLbg/1bBAr2mzscqP/omf2IBlnDmEN/IV7tGbjTRZwQvL3VFj/m7w== 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=e/dXnxVB7wf2ylhJ6JB/AHXyCZIHcipmOSJcym8TAIM=; b=NY4f92MVSDUrrG10R47zSX8Df9rAcfAtTjgWeGXXbNpvdluoV6DgqnKqBp7uRtZVh/E7mVBCw2pQy1djz8pLiRVFR+pllcl+C4kXGOsnN9zwLPNRvHyGTFOfQYkwoRz+0eXuPLdSGbLGt2Hn+Jzo1UAzYt07wp4nusLp6Ped0Rba1a7wIeDsunp8J2gLaUZpodWXy7J/FsGVCOektzOTMAQ00q39DRzBg4MGvfBvibN6RK/fL7zekUdGpvuo7KnGIubyZskOVcGpIGg/zpXk8/q9rgFQGkKfyPrLFOTnxoug4s1qApb7h+falRFxsjKUZCIJ3D65yyUul/04UkpphQ== 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 Authentication-Results-Original: dkim=none (message not signed) header.d=none;dmarc=none action=none header.from=arm.com; Received: from VI1PR08MB5325.eurprd08.prod.outlook.com (2603:10a6:803:13e::17) by AS8PR08MB10025.eurprd08.prod.outlook.com (2603:10a6:20b:630::17) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.20.5813.11; Wed, 23 Nov 2022 14:24:53 +0000 Received: from VI1PR08MB5325.eurprd08.prod.outlook.com ([fe80::bd2a:aff9:b1a0:2fc7]) by VI1PR08MB5325.eurprd08.prod.outlook.com ([fe80::bd2a:aff9:b1a0:2fc7%4]) with mapi id 15.20.5857.017; Wed, 23 Nov 2022 14:24:52 +0000 Date: Wed, 23 Nov 2022 14:24:44 +0000 To: gcc-patches@gcc.gnu.org Cc: nd@arm.com, Richard.Earnshaw@arm.com, Marcus.Shawcroft@arm.com, Kyrylo.Tkachov@arm.com, richard.sandiford@arm.com Subject: [PATCH]AArch64 sve2: Fix expansion of division [PR107830] Message-ID: Content-Disposition: inline X-ClientProxiedBy: SN7PR04CA0216.namprd04.prod.outlook.com (2603:10b6:806:127::11) To VI1PR08MB5325.eurprd08.prod.outlook.com (2603:10a6:803:13e::17) MIME-Version: 1.0 X-MS-TrafficTypeDiagnostic: VI1PR08MB5325:EE_|AS8PR08MB10025:EE_|VI1EUR03FT004:EE_|DB9PR08MB6409:EE_ X-MS-Office365-Filtering-Correlation-Id: dc630952-a9df-4d24-4ca7-08dacd5e830a x-checkrecipientrouted: true NoDisclaimer: true X-MS-Exchange-SenderADCheck: 1 X-MS-Exchange-AntiSpam-Relay: 0 X-Microsoft-Antispam-Untrusted: BCL:0; X-Microsoft-Antispam-Message-Info-Original: ISluwkDR1PEqvaCz4038Bfhz53w4rwsySkbChcgAEZd4dxF2QfqjfmCSG9EA5SV1Kt03a0/1v7PCQBitNqACCkjyrjQk1XvewGmGmRuvl3k1YJUMZkRaINY9MEa8cCEl+hMMRKoll/fYsfrOaAsTvbzQfqse6h+SkYSIqCh8l/InFAk/IRWwIkB2yhP2t5lvpZIeY1uvCd1/JTLDeT7m0F5le7u2cH3dyQ6tPPwD8/QtwXWtNvvgCrkDzRW5sgEyRh7bDCdappIFQXbWVWYSprq+TWdNJfKO7d5EEGjEXiOV7h83CqarO7/WTz+zNutvhyokFRNrDmR7bd3BbhXyOPf+l9lzj7YoOkyXrGRZ7aPXiGNt5C5xJPKs95+OyRcJBzvogdlZNjZ2svMAaU7PFUFXr3UfqzujDfMgwYmZwPOyNIlkH5Tc3ut1bRMQfW8+gQv4/BQRLsIAeQN32K7tmbAOhZhDOEmARc3qpr/QdTkKH+Tw6Md7zZouYBLC8iUtN6alomioGkfmDiEa5rHj0QdU2P9pPwOG98S/EMmwmVcFE3pUrrj+YPJQ30t0wGzYT6gMYOjbTsNQXC3iapGufYOQDSJxwA6AwubaaBo9/kGVGEq2WTCgWosusoeYjxr3b7Dm4zB5cOKCSScjn3+MzCdmGmQhH8cbekoW6Qj1BtoAaXbqrJJiMQEW2MiBK+kTkALpz+6ff40X/7LL8B8qFgyGznjV93gSUieU2tzTZ6RSUQqahi7J1obIgJeiCMoZ 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:(13230022)(4636009)(39860400002)(346002)(376002)(366004)(136003)(396003)(451199015)(6666004)(44832011)(66476007)(66556008)(66946007)(4326008)(8676002)(86362001)(316002)(4743002)(26005)(6512007)(6916009)(186003)(2616005)(235185007)(5660300002)(8936002)(44144004)(6506007)(41300700001)(33964004)(36756003)(38100700002)(2906002)(6486002)(84970400001)(478600001)(4216001)(2700100001); DIR:OUT; SFP:1101; X-MS-Exchange-Transport-CrossTenantHeadersStamped: AS8PR08MB10025 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: VI1EUR03FT004.eop-EUR03.prod.protection.outlook.com X-MS-PublicTrafficType: Email X-MS-Office365-Filtering-Correlation-Id-Prvs: e64fd6c7-382b-4079-c476-08dacd5e7c52 X-Microsoft-Antispam: BCL:0; X-Microsoft-Antispam-Message-Info: re4vI1LN7/ciAfrmaixDDopVVHHpje2nFbOOpeDwiLtQ5XO7eaneWtp4shJ/hZq6WgldLgMBb2oNLa2FgHjBa7UcyR9He5deE4WKrfFh48x6ayGsDOqnBWEwNNInrFM14IYnHIyhRSKDTTTNYV+GXRVd/3Jv69udoR4WPfKy/xTwBfCE+s0Xzwk0DfjFfhqIM3nIchd/CzifTNfY8Z3gth8EKckJobFvUiz0lfKOrJmj+7bd4TQKliMip901gEmgyijQzCOPdvwS+CE79/JNqYYRrJuKey6MM8u43Rem9hRpi1zCcQNi183lsJxPu044JAALt92nskAE3BgRHLsq+YPhLea5p1NEAmZKpqfraOy5ZFRG2PeyhAlBB7jsugyngPE4B53ALyMteeZf1av8S4i/l+iI8NpQfV0JFHJnBbYQaN0sOC51lDZwqIhkMb6FhlVoAoQx7sZKyh9+Ckh0hMRzQJL3UlbGdAhI9jrmedMEdZyGIEFA7HojqRaJAb4cv8OsZxxGQNjm81Gd0P9D1CNadI7DdhEI5KLsyTMr9gb1wPQOspw1Ny32Yze26VA43lELvyME4vBG2sWjS6KPEFOzqIHZ3hqUE1LZdsknu/NtpyAnDgLUslsmBM20aFfpZFzNknPmhee1ha9vunhEBNNRgKndS0nCMk+y4rdxXSr+r4Q9IPhF10k08CODMnPACXpRuAl4dqmMaG9o1tjCVemRPUrrmcmShkdaPHP9kvu9aSeC1JzWpYQu7Ko8bKtcSqQd9GeismfnCJB8NA69wxrXsl4K4bWFRstxoYVLn9k= 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:(13230022)(4636009)(396003)(136003)(39860400002)(376002)(346002)(451199015)(40470700004)(46966006)(36840700001)(478600001)(6486002)(2906002)(6916009)(82740400003)(44144004)(47076005)(186003)(336012)(2616005)(82310400005)(36756003)(6512007)(4743002)(40460700003)(33964004)(26005)(316002)(36860700001)(6506007)(6666004)(4326008)(70586007)(8676002)(8936002)(44832011)(5660300002)(81166007)(70206006)(235185007)(84970400001)(40480700001)(41300700001)(86362001)(356005)(4216001)(2700100001); DIR:OUT; SFP:1101; X-OriginatorOrg: arm.com X-MS-Exchange-CrossTenant-OriginalArrivalTime: 23 Nov 2022 14:25:03.3738 (UTC) X-MS-Exchange-CrossTenant-Network-Message-Id: dc630952-a9df-4d24-4ca7-08dacd5e830a 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: VI1EUR03FT004.eop-EUR03.prod.protection.outlook.com X-MS-Exchange-CrossTenant-AuthAs: Anonymous X-MS-Exchange-CrossTenant-FromEntityHeader: HybridOnPrem X-MS-Exchange-Transport-CrossTenantHeadersStamped: DB9PR08MB6409 X-Spam-Status: No, score=-12.4 required=5.0 tests=BAYES_00, DKIM_SIGNED, DKIM_VALID, FORGED_SPF_HELO, GIT_PATCH_0, KAM_DMARC_NONE, KAM_LOTSOFHASH, KAM_SHORT, RCVD_IN_DNSWL_NONE, RCVD_IN_MSPIKE_H2, SPF_HELO_PASS, SPF_NONE, TXREP, UNPARSEABLE_RELAY 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: Tamar Christina via Gcc-patches From: Tamar Christina Reply-To: Tamar Christina 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?1750297274419265053?= X-GMAIL-MSGID: =?utf-8?q?1750297274419265053?= Hi All, SVE has an actual division optab, and when using -Os we don't optimize the division away. This means that we need to distinguish between a div which we can optimize and one we cannot even during expansion. Bootstrapped Regtested on aarch64-none-linux-gnu and no issues. Ok for master? Thanks, Tamar gcc/ChangeLog: PR target/107830 * config/aarch64/aarch64.cc (aarch64_vectorize_can_special_div_by_constant): Check validity during codegen phase as well. gcc/testsuite/ChangeLog: PR target/107830 * gcc.target/aarch64/sve2/pr107830.c: New test. --- inline copy of patch -- diff --git a/gcc/config/aarch64/aarch64.cc b/gcc/config/aarch64/aarch64.cc index 4176d7b046a126664360596b6db79a43e77ff76a..bee23625807af95d5ec15ad45702961b2d7ab55d 100644 --- diff --git a/gcc/config/aarch64/aarch64.cc b/gcc/config/aarch64/aarch64.cc index 4176d7b046a126664360596b6db79a43e77ff76a..bee23625807af95d5ec15ad45702961b2d7ab55d 100644 --- a/gcc/config/aarch64/aarch64.cc +++ b/gcc/config/aarch64/aarch64.cc @@ -24322,12 +24322,15 @@ aarch64_vectorize_can_special_div_by_constant (enum tree_code code, if ((flags & VEC_ANY_SVE) && !TARGET_SVE2) return false; + wide_int val = wi::add (cst, 1); + int pow = wi::exact_log2 (val); + bool valid_p = pow == (int)(element_precision (vectype) / 2); + /* SVE actually has a div operator, we we may have gotten here through + that route. */ if (in0 == NULL_RTX && in1 == NULL_RTX) - { - wide_int val = wi::add (cst, 1); - int pow = wi::exact_log2 (val); - return pow == (int)(element_precision (vectype) / 2); - } + return valid_p; + else if (!valid_p) + return false; if (!VECTOR_TYPE_P (vectype)) return false; diff --git a/gcc/testsuite/gcc.target/aarch64/sve2/pr107830.c b/gcc/testsuite/gcc.target/aarch64/sve2/pr107830.c new file mode 100644 index 0000000000000000000000000000000000000000..6d8ee3615fdb0083dbde1e45a2826fb681726139 --- /dev/null +++ b/gcc/testsuite/gcc.target/aarch64/sve2/pr107830.c @@ -0,0 +1,13 @@ +/* { dg-do compile } */ +/* { dg-require-effective-target fopenmp } */ +/* { dg-additional-options "-Os -fopenmp" } */ + +void +f2 (int *a) +{ + unsigned int i; + +#pragma omp simd + for (i = 0; i < 4; ++i) + a[i / 3] -= 4; +} --- a/gcc/config/aarch64/aarch64.cc +++ b/gcc/config/aarch64/aarch64.cc @@ -24322,12 +24322,15 @@ aarch64_vectorize_can_special_div_by_constant (enum tree_code code, if ((flags & VEC_ANY_SVE) && !TARGET_SVE2) return false; + wide_int val = wi::add (cst, 1); + int pow = wi::exact_log2 (val); + bool valid_p = pow == (int)(element_precision (vectype) / 2); + /* SVE actually has a div operator, we we may have gotten here through + that route. */ if (in0 == NULL_RTX && in1 == NULL_RTX) - { - wide_int val = wi::add (cst, 1); - int pow = wi::exact_log2 (val); - return pow == (int)(element_precision (vectype) / 2); - } + return valid_p; + else if (!valid_p) + return false; if (!VECTOR_TYPE_P (vectype)) return false; diff --git a/gcc/testsuite/gcc.target/aarch64/sve2/pr107830.c b/gcc/testsuite/gcc.target/aarch64/sve2/pr107830.c new file mode 100644 index 0000000000000000000000000000000000000000..6d8ee3615fdb0083dbde1e45a2826fb681726139 --- /dev/null +++ b/gcc/testsuite/gcc.target/aarch64/sve2/pr107830.c @@ -0,0 +1,13 @@ +/* { dg-do compile } */ +/* { dg-require-effective-target fopenmp } */ +/* { dg-additional-options "-Os -fopenmp" } */ + +void +f2 (int *a) +{ + unsigned int i; + +#pragma omp simd + for (i = 0; i < 4; ++i) + a[i / 3] -= 4; +}