From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: Received: from EUR05-AM6-obe.outbound.protection.outlook.com (mail-am6eur05on2073.outbound.protection.outlook.com [40.107.22.73]) by sourceware.org (Postfix) with ESMTPS id 97345385DC19 for ; Fri, 30 Jun 2023 08:26:32 +0000 (GMT) DMARC-Filter: OpenDMARC Filter v1.4.2 sourceware.org 97345385DC19 Authentication-Results: sourceware.org; dmarc=pass (p=none dis=none) header.from=arm.com Authentication-Results: sourceware.org; spf=pass smtp.mailfrom=arm.com DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=armh.onmicrosoft.com; s=selector2-armh-onmicrosoft-com; h=From:Date:Subject:Message-ID:Content-Type:MIME-Version:X-MS-Exchange-SenderADCheck; bh=BL3OVEmuL9ZE1MSaIDKwmGzTiVknVIVy15r5+buhRp0=; b=lIWdH68woC/wb7Hz7puoOfBQjtQGiUGI5cAZyxj2HcWOY58zDAFAa7zX+9MnQ7hPCt+AOZLfSOf1W+JxhMlNcT9SrrmehUqyvkV67XhHdScT0RiEpTy6TBJN84kj5w9h7YQkWeKCxcKDeCUqXT+jTgjoHdcZGrsgy/2vU6AfzWs= Received: from DUZPR01CA0295.eurprd01.prod.exchangelabs.com (2603:10a6:10:4b7::11) by DU0PR08MB8301.eurprd08.prod.outlook.com (2603:10a6:10:40f::20) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.20.6521.26; Fri, 30 Jun 2023 08:26:29 +0000 Received: from DBAEUR03FT046.eop-EUR03.prod.protection.outlook.com (2603:10a6:10:4b7:cafe::11) by DUZPR01CA0295.outlook.office365.com (2603:10a6:10:4b7::11) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.20.6544.22 via Frontend Transport; Fri, 30 Jun 2023 08:26:29 +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 DBAEUR03FT046.mail.protection.outlook.com (100.127.142.67) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.20.6544.22 via Frontend Transport; Fri, 30 Jun 2023 08:26:29 +0000 Received: ("Tessian outbound 7c913606c6e6:v142"); Fri, 30 Jun 2023 08:26:29 +0000 X-CheckRecipientChecked: true X-CR-MTA-CID: 8e69731e70c77768 X-CR-MTA-TID: 64aa7808 Received: from 4451325f8775.1 by 64aa7808-outbound-1.mta.getcheckrecipient.com id 8B8B4437-A5FC-48C6-BA86-99622BD21376.1; Fri, 30 Jun 2023 08:26:23 +0000 Received: from EUR05-AM6-obe.outbound.protection.outlook.com by 64aa7808-outbound-1.mta.getcheckrecipient.com with ESMTPS id 4451325f8775.1 (version=TLSv1.2 cipher=ECDHE-RSA-AES256-GCM-SHA384); Fri, 30 Jun 2023 08:26:23 +0000 ARC-Seal: i=1; a=rsa-sha256; s=arcselector9901; d=microsoft.com; cv=none; b=hx1W25eP6O4kyE/Ld/+bw5eLjxM2xxIDPRwZdnRwhyLDRHFbPC1fzvVpEkn8rj0iXsOcDwkHTmxd936yOIpT4I6RNP05UywgVhh5ui5H7odnyTxTAA69UhDoJvCePBXT+yF1kS2BdCLtBr4LJnP51wAnGWusN5q7v2WZrO9zcuRd3FgCxr53nc9V46nUQNtRYO5XyRT52bMkeIdbuGpC+ceWxVZDl8MtBDB5BD08S9roLsmJ/a2gcD2qOtjqG83ddGSE9pn6xCNKuR5ZhwWtAAzyrY3x3o+D8XXMvrkU0InuD9EOfCg8wKuJMLELQL11eyCYl0dM29MK1Mkfh+xS6A== 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=BL3OVEmuL9ZE1MSaIDKwmGzTiVknVIVy15r5+buhRp0=; b=i+/LiXyVgqZC6QgBDQojaGhR5jOUQX2EbCHKRuBtxHrF/RjZSeeJhFOL6epmuv1bAemUO/G+ETlhhte3GbZWTbmQ+5/S8YjtCZsez0TkxbdNhBCA94AcwWMP5ePxHg6wV0jxTFqwS3IHYIRsgif25Kxy16J6kO2ehoXKGRsQq4ByeOE3nq4cvvmDQHBTwEQp0FvkKCJ0lX907+ZHYZuLLTEwHD4LqE542cVW784RYTvE39z35zY7sG4BSU+ayxknaUPgusD9Ws7RSzibTAuKzDyKF8MgYI+KQSNe+4Ai2cVaUFCbEpbthxL/KTpZKVU+CgbPXcT9XfHte7u1fFTcbQ== ARC-Authentication-Results: i=1; mx.microsoft.com 1; spf=pass (sender ip is 40.67.248.234) smtp.rcpttodomain=armh.onmicrosoft.com smtp.mailfrom=arm.com; dmarc=pass (p=none sp=none pct=100) action=none header.from=arm.com; dkim=none (message not signed); arc=none DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=armh.onmicrosoft.com; s=selector2-armh-onmicrosoft-com; h=From:Date:Subject:Message-ID:Content-Type:MIME-Version:X-MS-Exchange-SenderADCheck; bh=BL3OVEmuL9ZE1MSaIDKwmGzTiVknVIVy15r5+buhRp0=; b=lIWdH68woC/wb7Hz7puoOfBQjtQGiUGI5cAZyxj2HcWOY58zDAFAa7zX+9MnQ7hPCt+AOZLfSOf1W+JxhMlNcT9SrrmehUqyvkV67XhHdScT0RiEpTy6TBJN84kj5w9h7YQkWeKCxcKDeCUqXT+jTgjoHdcZGrsgy/2vU6AfzWs= Received: from AS9PR05CA0247.eurprd05.prod.outlook.com (2603:10a6:20b:493::11) by PAWPR08MB9685.eurprd08.prod.outlook.com (2603:10a6:102:2e6::22) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.20.6521.24; Fri, 30 Jun 2023 08:26:21 +0000 Received: from AM7EUR03FT027.eop-EUR03.prod.protection.outlook.com (2603:10a6:20b:493:cafe::9c) by AS9PR05CA0247.outlook.office365.com (2603:10a6:20b:493::11) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.20.6544.22 via Frontend Transport; Fri, 30 Jun 2023 08:26:20 +0000 X-MS-Exchange-Authentication-Results: spf=pass (sender IP is 40.67.248.234) smtp.mailfrom=arm.com; dkim=none (message not signed) header.d=none;dmarc=pass action=none header.from=arm.com; Received-SPF: Pass (protection.outlook.com: domain of arm.com designates 40.67.248.234 as permitted sender) receiver=protection.outlook.com; client-ip=40.67.248.234; helo=nebula.arm.com; pr=C Received: from nebula.arm.com (40.67.248.234) by AM7EUR03FT027.mail.protection.outlook.com (100.127.140.124) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_128_GCM_SHA256) id 15.20.6544.22 via Frontend Transport; Fri, 30 Jun 2023 08:26:20 +0000 Received: from AZ-NEU-EX02.Emea.Arm.com (10.251.26.5) by AZ-NEU-EX04.Arm.com (10.251.24.32) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_128_GCM_SHA256) id 15.1.2507.27; Fri, 30 Jun 2023 08:26:18 +0000 Received: from AZ-NEU-EX03.Arm.com (10.251.24.31) by AZ-NEU-EX02.Emea.Arm.com (10.251.26.5) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_128_GCM_SHA256) id 15.1.2507.27; Fri, 30 Jun 2023 08:26:18 +0000 Received: from e119885.cambridge.arm.com (10.2.78.55) by mail.arm.com (10.251.24.31) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_128_GCM_SHA256) id 15.1.2507.27 via Frontend Transport; Fri, 30 Jun 2023 08:26:18 +0000 From: Oluwatamilore Adebayo To: CC: , , Subject: [PATCH 1/2] Mid engine setup [SU]ABDL Date: Fri, 30 Jun 2023 09:26:11 +0100 Message-ID: <20230630082611.112557-1-oluwatamilore.adebayo@arm.com> X-Mailer: git-send-email 2.25.1 In-Reply-To: <20230630082308.112217-1-oluwatamilore.adebayo@arm.com> References: <20230630082308.112217-1-oluwatamilore.adebayo@arm.com> MIME-Version: 1.0 Content-Transfer-Encoding: 8bit Content-Type: text/plain X-EOPAttributedMessage: 1 X-MS-TrafficTypeDiagnostic: AM7EUR03FT027:EE_|PAWPR08MB9685:EE_|DBAEUR03FT046:EE_|DU0PR08MB8301:EE_ X-MS-Office365-Filtering-Correlation-Id: 94fba844-1533-427c-5d27-08db7943b428 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: FMW9Qh88FkmPaJma6y/bmw2rIVf5q5OD0+VINyBtITjmUM+CxLjNfcTRIbx5scgR0Gyl96Vc/PTVKBXr1ZWgAJUwRRmrEjxGLx8SRqBn8T4nXK/JX93Tp0BPhELZ/Ks9SESCs+PSGQ9y1M1tWJuHysPqv4jEeLVLXInub/gcJCZ+V9CseF4BNU/CDKy5PJxR656WgU4Zexd2Hxx18GzMLEevVR6HwFpCpVjRFtoS7fnyFIyFe1eZOkLJ+laQYe3Ui5ZQ2ckryp3g0qVYP/D740rzYGLgKWPfGbX5x46nDb9jlhd+5oZs9cNWFWc7pWyMm2CcMO2GV/d+iOExGGMHnXDy26ejIP40VF61EjWjauC6EKBvusnziegve+tFxjwquKdi5exSqHjcJgqPYg9rfj7yev9fbAM4wN14QAniH/o1Nl+uGxB7GaGkJajzFk1ZzKoWW8LPr2+0Q7YEtHciJ01kea4U+rrtm0vOcmWrIentKkIjVTuy/1Ujutn/sVsQmw7QCD6ucwmmCQADSRFp71a0Hz4WJ53nFUiKLYz0spxhfD10zVvGk1uBzdsBp7b17opcEFFqhhae+EhjjmBqWx7BNQOR92XDGIJPSDPFwfpnh/HFVX4QpJLToWeMAv0bjIXp97Gqky43dQGrbEtqbLZ0JyO16YWkYxzNaVMG1GBu5BxHomwznzuWZZ5CMMsWjlPBowlFTFMcBWBhhNQGNA+qp0WnQinWXtbuKXTuw/Iicro15pD7mMlbHc6ZZ6ClXvtxrjblcGM7bfI7iUhjTA== X-Forefront-Antispam-Report-Untrusted: CIP:40.67.248.234;CTRY:IE;LANG:en;SCL:1;SRV:;IPV:NLI;SFV:NSPM;H:nebula.arm.com;PTR:InfoDomainNonexistent;CAT:NONE;SFS:(13230028)(4636009)(136003)(376002)(396003)(39860400002)(346002)(451199021)(40470700004)(36840700001)(46966006)(26005)(36756003)(7049001)(2906002)(82310400005)(36860700001)(47076005)(336012)(83380400001)(54906003)(478600001)(2616005)(426003)(7696005)(45080400002)(6666004)(37006003)(1076003)(186003)(30864003)(44832011)(6862004)(6200100001)(356005)(40460700003)(70206006)(316002)(82740400003)(81166007)(70586007)(5660300002)(41300700001)(40480700001)(4326008)(86362001)(8676002)(8936002)(36900700001);DIR:OUT;SFP:1101; X-MS-Exchange-Transport-CrossTenantHeadersStamped: PAWPR08MB9685 X-MS-Exchange-Transport-CrossTenantHeadersStripped: DBAEUR03FT046.eop-EUR03.prod.protection.outlook.com X-MS-PublicTrafficType: Email X-MS-Office365-Filtering-Correlation-Id-Prvs: ccf7a8ef-1958-44b6-7e44-08db7943af00 X-Microsoft-Antispam: BCL:0; X-Microsoft-Antispam-Message-Info: /eSxlJ6NnSybeR7mCWdUIlnfYNg0ulvArOxG4rwcUxhZO/zZtEBVCpvz4VEd4hkXEdOEbDN3T7OtYoK6QmMQTY/+oUcZrMiIHXvSXTZFTz0AVOxb0f9SGgRmGT5iR+CDmvABghIz/tlx/K1pL9C7c1KaQXrLkQP1ctpdiENoBpxoDDpWjavpouxF8QOudl7ehjgzDVSzS8Z2qgzfMEVsSXsnmus0sfX0FTnEp8L4NLsv7b5j49No1PQAOde5cHfJAgW5J6mJYAfMzNzViVwxDtgkqa0JahZnuYsDtMS1vBVmJPJ5whocaWz35FDFpdU+8JpUntedi9uD6nS+zJ8RHhxYCAmR4p59y8FWmc+SrLJSAcB6ZrXvjDkNzjgvr9NVphCJbCV2EfhqQtgOq97GBeYSn8hgZjpwcFZjP+hSwnvexLDrWs2h/XKvewz+JZJAe3SNvq3v/tWNtqOO3AsrcdLxZQE3aOie0i9xiw3trwRrN4iTLvN/dhwjOHBXtJ0M7M14uUTYbNndVtb95Ic+/4N2UV42Rk8wN/LCULSwwQO+Vp3OLga26M2g/yW5ne4XT+YG5S60aIXyRNbRo71q2G0MyJDt+ucubTMIIY0Oa8LHTwln+o6C7rqDYs9naqG98ZkfFtfxcDxezMiYiXYsVA9vjrVXmfUW2yPRiy5Wf1u9O93E55QMmJ1vf9kefKWQUrQE6JwiRAZeM8mXI9ljzg22865VpOGRFoUxficD1TnBUcv8fi1ztXp64yDDOa4p 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:(13230028)(4636009)(136003)(346002)(396003)(376002)(39860400002)(451199021)(46966006)(40470700004)(36840700001)(1076003)(44832011)(70586007)(4326008)(70206006)(316002)(8936002)(36756003)(5660300002)(6862004)(8676002)(478600001)(2906002)(40460700003)(426003)(7049001)(36860700001)(40480700001)(86362001)(30864003)(37006003)(54906003)(41300700001)(6200100001)(26005)(82310400005)(7696005)(45080400002)(186003)(47076005)(336012)(2616005)(81166007)(6666004)(82740400003)(83380400001);DIR:OUT;SFP:1101; X-OriginatorOrg: arm.com X-MS-Exchange-CrossTenant-OriginalArrivalTime: 30 Jun 2023 08:26:29.5214 (UTC) X-MS-Exchange-CrossTenant-Network-Message-Id: 94fba844-1533-427c-5d27-08db7943b428 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: DBAEUR03FT046.eop-EUR03.prod.protection.outlook.com X-MS-Exchange-CrossTenant-AuthAs: Anonymous X-MS-Exchange-CrossTenant-FromEntityHeader: HybridOnPrem X-MS-Exchange-Transport-CrossTenantHeadersStamped: DU0PR08MB8301 X-Spam-Status: No, score=-11.5 required=5.0 tests=BAYES_00,DKIM_SIGNED,DKIM_VALID,FORGED_SPF_HELO,GIT_PATCH_0,KAM_DMARC_NONE,KAM_LOTSOFHASH,RCVD_IN_DNSWL_NONE,RCVD_IN_MSPIKE_H2,SPF_HELO_PASS,SPF_NONE,TXREP,T_SCC_BODY_TEXT_LINE,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 List-Id: From: oluade01 This updates vect_recog_abd_pattern to recognize the widening variant of absolute difference (ABDL, ABDL2). gcc/ChangeLog: * internal-fn.cc (widening_fn_p, decomposes_to_hilo_fn_p): Add IFN_VEC_WIDEN_ABD to the switch statement. * internal-fn.def (VEC_WIDEN_ABD): New internal hilo optab. * optabs.def (vec_widen_sabd_optab, vec_widen_sabd_hi_optab, vec_widen_sabd_lo_optab, vec_widen_sabd_odd_even, vec_widen_sabd_even_optab, vec_widen_uabd_optab, vec_widen_uabd_hi_optab, vec_widen_uabd_lo_optab, vec_widen_uabd_odd_even, vec_widen_uabd_even_optab): New optabs. * tree-vect-patterns.cc (vect_recog_abd_pattern): Update to to build a VEC_WIDEN_ABD call if the input precision is smaller than the precision of the output. (vect_recog_widen_abd_pattern): Should an ABD expression be found preceeding an extension, replace the two with a VEC_WIDEN_ABD. --- gcc/doc/md.texi | 17 ++++ gcc/internal-fn.def | 5 + gcc/optabs.def | 10 ++ gcc/tree-vect-patterns.cc | 190 ++++++++++++++++++++++++++++---------- 4 files changed, 174 insertions(+), 48 deletions(-) diff --git a/gcc/doc/md.texi b/gcc/doc/md.texi index e11b10d2fca11016232921bc85e47975f700e6c6..f518d9ed6e170b2e2b9557fffed2cf47aa02633d 100644 --- a/gcc/doc/md.texi +++ b/gcc/doc/md.texi @@ -5617,6 +5617,23 @@ signed/unsigned elements of size S@. Subtract the high/low elements of 2 from 1 and widen the resulting elements. Put the N/2 results of size 2*S in the output vector (operand 0). +@cindex @code{vec_widen_sabd_hi_@var{m}} instruction pattern +@cindex @code{vec_widen_sabd_lo_@var{m}} instruction pattern +@cindex @code{vec_widen_sabd_odd_@var{m}} instruction pattern +@cindex @code{vec_widen_sabd_even_@var{m}} instruction pattern +@cindex @code{vec_widen_uabd_hi_@var{m}} instruction pattern +@cindex @code{vec_widen_uabd_lo_@var{m}} instruction pattern +@cindex @code{vec_widen_uabd_odd_@var{m}} instruction pattern +@cindex @code{vec_widen_uabd_even_@var{m}} instruction pattern +@item @samp{vec_widen_uabd_hi_@var{m}}, @samp{vec_widen_uabd_lo_@var{m}} +@itemx @samp{vec_widen_uabd_odd_@var{m}}, @samp{vec_widen_uabd_even_@var{m}} +@itemx @samp{vec_widen_sabd_hi_@var{m}}, @samp{vec_widen_sabd_lo_@var{m}} +@itemx @samp{vec_widen_sabd_odd_@var{m}}, @samp{vec_widen_sabd_even_@var{m}} +Signed/Unsigned widening absolute difference. Operands 1 and 2 are +vectors with N signed/unsigned elements of size S@. Find the absolute +difference between operands 1 and 2 and widen the resulting elements. +Put the N/2 results of size 2*S in the output vector (operand 0). + @cindex @code{vec_addsub@var{m}3} instruction pattern @item @samp{vec_addsub@var{m}3} Alternating subtract, add with even lanes doing subtract and odd diff --git a/gcc/internal-fn.def b/gcc/internal-fn.def index 116965f4830cec8f60642ff011a86b6562e2c509..d67274d68b49943a88c531e903fd03b42343ab97 100644 --- a/gcc/internal-fn.def +++ b/gcc/internal-fn.def @@ -352,6 +352,11 @@ DEF_INTERNAL_WIDENING_OPTAB_FN (VEC_WIDEN_MINUS, first, vec_widen_ssub, vec_widen_usub, binary) +DEF_INTERNAL_WIDENING_OPTAB_FN (VEC_WIDEN_ABD, + ECF_CONST | ECF_NOTHROW, + first, + vec_widen_sabd, vec_widen_uabd, + binary) DEF_INTERNAL_OPTAB_FN (VEC_FMADDSUB, ECF_CONST, vec_fmaddsub, ternary) DEF_INTERNAL_OPTAB_FN (VEC_FMSUBADD, ECF_CONST, vec_fmsubadd, ternary) diff --git a/gcc/optabs.def b/gcc/optabs.def index 35b835a6ac56d72417dac8ddfd77a8a7e2475e65..68dfa1550f791a2fe833012157601ecfa68f1e09 100644 --- a/gcc/optabs.def +++ b/gcc/optabs.def @@ -418,6 +418,11 @@ OPTAB_D (vec_widen_sadd_hi_optab, "vec_widen_sadd_hi_$a") OPTAB_D (vec_widen_sadd_lo_optab, "vec_widen_sadd_lo_$a") OPTAB_D (vec_widen_sadd_odd_optab, "vec_widen_sadd_odd_$a") OPTAB_D (vec_widen_sadd_even_optab, "vec_widen_sadd_even_$a") +OPTAB_D (vec_widen_sabd_optab, "vec_widen_sabd_$a") +OPTAB_D (vec_widen_sabd_hi_optab, "vec_widen_sabd_hi_$a") +OPTAB_D (vec_widen_sabd_lo_optab, "vec_widen_sabd_lo_$a") +OPTAB_D (vec_widen_sabd_odd_optab, "vec_widen_sabd_odd_$a") +OPTAB_D (vec_widen_sabd_even_optab, "vec_widen_sabd_even_$a") OPTAB_D (vec_widen_sshiftl_hi_optab, "vec_widen_sshiftl_hi_$a") OPTAB_D (vec_widen_sshiftl_lo_optab, "vec_widen_sshiftl_lo_$a") OPTAB_D (vec_widen_umult_even_optab, "vec_widen_umult_even_$a") @@ -436,6 +441,11 @@ OPTAB_D (vec_widen_uadd_hi_optab, "vec_widen_uadd_hi_$a") OPTAB_D (vec_widen_uadd_lo_optab, "vec_widen_uadd_lo_$a") OPTAB_D (vec_widen_uadd_odd_optab, "vec_widen_uadd_odd_$a") OPTAB_D (vec_widen_uadd_even_optab, "vec_widen_uadd_even_$a") +OPTAB_D (vec_widen_uabd_optab, "vec_widen_uabd_$a") +OPTAB_D (vec_widen_uabd_hi_optab, "vec_widen_uabd_hi_$a") +OPTAB_D (vec_widen_uabd_lo_optab, "vec_widen_uabd_lo_$a") +OPTAB_D (vec_widen_uabd_odd_optab, "vec_widen_uabd_odd_$a") +OPTAB_D (vec_widen_uabd_even_optab, "vec_widen_uabd_even_$a") OPTAB_D (vec_addsub_optab, "vec_addsub$a3") OPTAB_D (vec_fmaddsub_optab, "vec_fmaddsub$a4") OPTAB_D (vec_fmsubadd_optab, "vec_fmsubadd$a4") diff --git a/gcc/tree-vect-patterns.cc b/gcc/tree-vect-patterns.cc index e2392113bff4065c909aefc760b4c48978b73a5a..7a0c65563ec1ecccdfc91d38bc32a044d0767a83 100644 --- a/gcc/tree-vect-patterns.cc +++ b/gcc/tree-vect-patterns.cc @@ -1404,15 +1404,28 @@ vect_recog_sad_pattern (vec_info *vinfo, gcall *abd_stmt = dyn_cast (abs_stmt_vinfo->stmt); if (!abd_stmt || !gimple_call_internal_p (abd_stmt) - || gimple_call_internal_fn (abd_stmt) != IFN_ABD) + || gimple_call_num_args (abd_stmt) != 2) return NULL; tree abd_oprnd0 = gimple_call_arg (abd_stmt, 0); tree abd_oprnd1 = gimple_call_arg (abd_stmt, 1); - if (!vect_look_through_possible_promotion (vinfo, abd_oprnd0, &unprom[0]) - || !vect_look_through_possible_promotion (vinfo, abd_oprnd1, - &unprom[1])) + if (gimple_call_internal_fn (abd_stmt) == IFN_ABD) + { + if (!vect_look_through_possible_promotion (vinfo, abd_oprnd0, + &unprom[0]) + || !vect_look_through_possible_promotion (vinfo, abd_oprnd1, + &unprom[1])) + return NULL; + } + else if (gimple_call_internal_fn (abd_stmt) == IFN_VEC_WIDEN_ABD) + { + unprom[0].op = abd_oprnd0; + unprom[0].type = TREE_TYPE (abd_oprnd0); + unprom[1].op = abd_oprnd1; + unprom[1].type = TREE_TYPE (abd_oprnd1); + } + else return NULL; half_type = unprom[0].type; @@ -1442,16 +1455,19 @@ vect_recog_sad_pattern (vec_info *vinfo, /* Function vect_recog_abd_pattern - Try to find the following ABsolute Difference (ABD) pattern: + Try to find the following ABsolute Difference (ABD) or + widening ABD (WIDEN_ABD) pattern: - VTYPE x, y, out; - type diff; - loop i in range: - S1 diff = x[i] - y[i] - S2 out[i] = ABS_EXPR ; + TYPE1 x; + TYPE2 y; + TYPE3 x_cast = (TYPE3) x; // widening or no-op + TYPE3 y_cast = (TYPE3) y; // widening or no-op + TYPE3 diff = x_cast - y_cast; + TYPE4 diff_cast = (TYPE4) diff; // widening or no-op + TYPE5 abs = ABS(U)_EXPR ; - where 'type' is a integer and 'VTYPE' is a vector of integers - the same size as 'type' + WIDEN_ABD exists to optimize the case where TYPE4 is at least + twice as wide as TYPE3. Input: @@ -1459,30 +1475,18 @@ vect_recog_sad_pattern (vec_info *vinfo, Output: - * TYPE_out: The type of the output of this pattern + * TYPE_OUT: The type of the output of this pattern * Return value: A new stmt that will be used to replace the sequence of - stmts that constitute the pattern; either SABD or UABD: - SABD_EXPR - UABD_EXPR + stmts that constitute the pattern, principally: + out = IFN_ABD (x, y) + out = IFN_WIDEN_ABD (x, y) */ static gimple * vect_recog_abd_pattern (vec_info *vinfo, stmt_vec_info stmt_vinfo, tree *type_out) { - /* Look for the following patterns - X = x[i] - Y = y[i] - DIFF = X - Y - DAD = ABS_EXPR - out[i] = DAD - - In which - - X, Y, DIFF, DAD all have the same type - - x, y, out are all vectors of the same type - */ - gassign *last_stmt = dyn_cast (STMT_VINFO_STMT (stmt_vinfo)); if (!last_stmt) return NULL; @@ -1496,54 +1500,83 @@ vect_recog_abd_pattern (vec_info *vinfo, unprom, &diff_stmt)) return NULL; - tree abd_type = out_type, vectype; - tree abd_oprnds[2]; - bool extend = false; + tree abd_in_type, abd_out_type; + if (half_type) { - vectype = get_vectype_for_scalar_type (vinfo, half_type); - abd_type = half_type; - extend = TYPE_PRECISION (abd_type) < TYPE_PRECISION (out_type); + abd_in_type = half_type; + abd_out_type = abd_in_type; } else { unprom[0].op = gimple_assign_rhs1 (diff_stmt); unprom[1].op = gimple_assign_rhs2 (diff_stmt); - tree signed_out = signed_type_for (out_type); - vectype = get_vectype_for_scalar_type (vinfo, signed_out); + abd_in_type = signed_type_for (out_type); + abd_out_type = abd_in_type; } - vect_pattern_detected ("vect_recog_abd_pattern", last_stmt); + tree vectype_in = get_vectype_for_scalar_type (vinfo, abd_in_type); + if (!vectype_in) + return NULL; - if (!vectype - || !direct_internal_fn_supported_p (IFN_ABD, vectype, + internal_fn ifn = IFN_ABD; + tree vectype_out = vectype_in; + + if (TYPE_PRECISION (out_type) >= TYPE_PRECISION (abd_in_type) * 2 + && stmt_vinfo->min_output_precision >= TYPE_PRECISION (abd_in_type) * 2) + { + tree mid_type + = build_nonstandard_integer_type (TYPE_PRECISION (abd_in_type) * 2, + TYPE_UNSIGNED (abd_in_type)); + tree mid_vectype = get_vectype_for_scalar_type (vinfo, mid_type); + + code_helper dummy_code; + int dummy_int; + auto_vec dummy_vec; + if (mid_vectype + && supportable_widening_operation (vinfo, IFN_VEC_WIDEN_ABD, + stmt_vinfo, mid_vectype, + vectype_in, + &dummy_code, &dummy_code, + &dummy_int, &dummy_vec)) + { + ifn = IFN_VEC_WIDEN_ABD; + abd_out_type = mid_type; + vectype_out = mid_vectype; + } + } + + if (ifn == IFN_ABD + && !direct_internal_fn_supported_p (ifn, vectype_in, OPTIMIZE_FOR_SPEED)) return NULL; + vect_pattern_detected ("vect_recog_abd_pattern", last_stmt); + + tree abd_oprnds[2]; vect_convert_inputs (vinfo, stmt_vinfo, 2, abd_oprnds, - TREE_TYPE (vectype), unprom, vectype); + abd_in_type, unprom, vectype_in); *type_out = get_vectype_for_scalar_type (vinfo, out_type); - tree abd_result = vect_recog_temp_ssa_var (abd_type, NULL); - gcall *abd_stmt = gimple_build_call_internal (IFN_ABD, 2, + tree abd_result = vect_recog_temp_ssa_var (abd_out_type, NULL); + gcall *abd_stmt = gimple_build_call_internal (ifn, 2, abd_oprnds[0], abd_oprnds[1]); gimple_call_set_lhs (abd_stmt, abd_result); gimple_set_location (abd_stmt, gimple_location (last_stmt)); - if (!extend) - return abd_stmt; - gimple *stmt = abd_stmt; - if (!TYPE_UNSIGNED (abd_type)) + if (TYPE_PRECISION (abd_in_type) == TYPE_PRECISION (abd_out_type) + && TYPE_PRECISION (abd_out_type) < TYPE_PRECISION (out_type) + && !TYPE_UNSIGNED (abd_out_type)) { - tree unsign = unsigned_type_for (abd_type); + tree unsign = unsigned_type_for (abd_out_type); tree unsign_vectype = get_vectype_for_scalar_type (vinfo, unsign); stmt = vect_convert_output (vinfo, stmt_vinfo, unsign, stmt, unsign_vectype); } - return vect_convert_output (vinfo, stmt_vinfo, out_type, stmt, vectype); + return vect_convert_output (vinfo, stmt_vinfo, out_type, stmt, vectype_out); } /* Recognize an operation that performs ORIG_CODE on widened inputs, @@ -1703,6 +1736,66 @@ vect_recog_widen_minus_pattern (vec_info *vinfo, stmt_vec_info last_stmt_info, &subtype); } +/* Try to detect abd on widened inputs, converting IFN_ABD + to IFN_VEC_WIDEN_ABD. */ +static gimple * +vect_recog_widen_abd_pattern (vec_info *vinfo, stmt_vec_info stmt_vinfo, + tree *type_out) +{ + gassign *last_stmt = dyn_cast (STMT_VINFO_STMT (stmt_vinfo)); + if (!last_stmt || !CONVERT_EXPR_CODE_P (gimple_assign_rhs_code (last_stmt))) + return NULL; + + tree last_rhs = gimple_assign_rhs1 (last_stmt); + + tree in_type = TREE_TYPE (last_rhs); + tree out_type = TREE_TYPE (gimple_assign_lhs (last_stmt)); + if (TYPE_PRECISION (in_type) * 2 != TYPE_PRECISION (out_type) + || !TYPE_UNSIGNED (in_type)) + return NULL; + + vect_unpromoted_value unprom; + tree op = vect_look_through_possible_promotion (vinfo, last_rhs, &unprom); + if (!op || TYPE_PRECISION (TREE_TYPE (op)) != TYPE_PRECISION (in_type)) + return NULL; + + stmt_vec_info abd_pattern_vinfo = vect_get_internal_def (vinfo, op); + if (!abd_pattern_vinfo) + return NULL; + + abd_pattern_vinfo = vect_stmt_to_vectorize (abd_pattern_vinfo); + gcall *abd_stmt = dyn_cast (STMT_VINFO_STMT (abd_pattern_vinfo)); + if (!abd_stmt + || !gimple_call_internal_p (abd_stmt) + || gimple_call_internal_fn (abd_stmt) != IFN_ABD) + return NULL; + + tree vectype_in = get_vectype_for_scalar_type (vinfo, in_type); + tree vectype_out = get_vectype_for_scalar_type (vinfo, out_type); + + code_helper dummy_code; + int dummy_int; + auto_vec dummy_vec; + if (!supportable_widening_operation (vinfo, IFN_VEC_WIDEN_ABD, stmt_vinfo, + vectype_out, vectype_in, + &dummy_code, &dummy_code, + &dummy_int, &dummy_vec)) + return NULL; + + vect_pattern_detected ("vect_recog_widen_abd_pattern", last_stmt); + + *type_out = vectype_out; + + tree abd_oprnd0 = gimple_call_arg (abd_stmt, 0); + tree abd_oprnd1 = gimple_call_arg (abd_stmt, 1); + tree widen_abd_result = vect_recog_temp_ssa_var (out_type, NULL); + gcall *widen_abd_stmt = gimple_build_call_internal (IFN_VEC_WIDEN_ABD, 2, + abd_oprnd0, abd_oprnd1); + gimple_call_set_lhs (widen_abd_stmt, widen_abd_result); + gimple_set_location (widen_abd_stmt, gimple_location (last_stmt)); + return widen_abd_stmt; +} + /* Function vect_recog_ctz_ffs_pattern Try to find the following pattern: @@ -6670,6 +6763,7 @@ static vect_recog_func vect_vect_recog_func_ptrs[] = { { vect_recog_mask_conversion_pattern, "mask_conversion" }, { vect_recog_widen_plus_pattern, "widen_plus" }, { vect_recog_widen_minus_pattern, "widen_minus" }, + { vect_recog_widen_abd_pattern, "widen_abd" }, /* These must come after the double widening ones. */ }; -- 2.25.1