From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: Received: from EUR05-VI1-obe.outbound.protection.outlook.com (mail-vi1eur05on2086.outbound.protection.outlook.com [40.107.21.86]) by sourceware.org (Postfix) with ESMTPS id 076813858CDB for ; Wed, 1 Mar 2023 18:17:22 +0000 (GMT) DMARC-Filter: OpenDMARC Filter v1.4.2 sourceware.org 076813858CDB 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=AYvy4LrlyjraQqgH88cYDmbxA62fYKnmM+abY2zQ8rQ=; b=mgqRbSY8lH+kklZ8UqgxraRb3mod1jtYMEOyb8UDu1/rYe4mszG6pKsQXIocjEZZ3vF6eyCRRb/p7zCqWZdO+eipdLJozomlDxSwqjTBv5fIXTZmBmS5kbqCDjEqd41orRzqepREhjhktFgsJ7TVua/ACitFWgGxvZbKR7pvWTE= Received: from DB6PR07CA0196.eurprd07.prod.outlook.com (2603:10a6:6:42::26) by DB9PR08MB6490.eurprd08.prod.outlook.com (2603:10a6:10:25a::7) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.20.6156.17; Wed, 1 Mar 2023 18:17:18 +0000 Received: from DBAEUR03FT024.eop-EUR03.prod.protection.outlook.com (2603:10a6:6:42:cafe::c) by DB6PR07CA0196.outlook.office365.com (2603:10a6:6:42::26) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.20.6156.18 via Frontend Transport; Wed, 1 Mar 2023 18:17:18 +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 DBAEUR03FT024.mail.protection.outlook.com (100.127.142.163) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.20.6156.18 via Frontend Transport; Wed, 1 Mar 2023 18:17:18 +0000 Received: ("Tessian outbound 55ffa3012b8f:v135"); Wed, 01 Mar 2023 18:17:18 +0000 X-CR-MTA-TID: 64aa7808 Received: from 9d3dcd7669a0.3 by 64aa7808-outbound-1.mta.getcheckrecipient.com id 6019FB33-2579-4145-8389-AA4D8B47A1E0.1; Wed, 01 Mar 2023 18:17:08 +0000 Received: from EUR02-VI1-obe.outbound.protection.outlook.com by 64aa7808-outbound-1.mta.getcheckrecipient.com with ESMTPS id 9d3dcd7669a0.3 (version=TLSv1.2 cipher=ECDHE-RSA-AES256-GCM-SHA384); Wed, 01 Mar 2023 18:17:07 +0000 ARC-Seal: i=1; a=rsa-sha256; s=arcselector9901; d=microsoft.com; cv=none; b=f+c2b67/y2eFXU2C5nS2wtAlgk5xAY2XSJc7tSFTaJ8zY1ixH9TOPWYRVpRIyHkhFlU+tl/Wtr3j+tADg56fBapePRQe7zI6bX0Ibpj+015tFmX0i26gBuuc7iNpRTjt2M7352ikZmXUsSKi2p+8X0sq+9JLL4B2cVtpq7e3cv88xH7G5Zick5vGUko5swiDy85RdqwOyrynKnH7+hrkYVNg1J/T9XoQTFpvdvue0VRj8UuGOOlnOsAiHxtJNnSLDBd5fKePGyTbxO+YFtSc5vfdAmoXX5XcxG2RXf1DtuaTsvJ5isljOQu4SKWQKZ4NRnyeHguZtnURCj+7dg6i0A== 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=AYvy4LrlyjraQqgH88cYDmbxA62fYKnmM+abY2zQ8rQ=; b=baDA1gb0NR79IlNNge9JV6dDil0rLm9W3VMQ2uxN+JMexgm1CYVkoPKZ+jLHb8jnkCEHeOt4wA7Ecph02QnFlfH0mk352bABjrcMZVyI71EUUpnrLPZvVcEEyywT6obEsGSRIomWyW4pwxzd5AN93Ic4PeKswOe6io9hD4ZK2ytW6NpYai12W9AgbclVsKa/f8JplEB4Q0B4cxikiUfo+1q3WykJpUqyj+MeWfT08KACW/hG379GAwtGM8/lmg4O1+e3s5frHlStx8YZ0pDTRuI12GUd7OnIESuXLMv7Y652qtetq3gijKdmP1JNhXQ3lFulp7opNElL6iXBB06+pA== 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 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=AYvy4LrlyjraQqgH88cYDmbxA62fYKnmM+abY2zQ8rQ=; b=mgqRbSY8lH+kklZ8UqgxraRb3mod1jtYMEOyb8UDu1/rYe4mszG6pKsQXIocjEZZ3vF6eyCRRb/p7zCqWZdO+eipdLJozomlDxSwqjTBv5fIXTZmBmS5kbqCDjEqd41orRzqepREhjhktFgsJ7TVua/ACitFWgGxvZbKR7pvWTE= Received: from VI1PR08MB5325.eurprd08.prod.outlook.com (2603:10a6:803:13e::17) by AS2PR08MB10268.eurprd08.prod.outlook.com (2603:10a6:20b:648::12) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.20.6156.18; Wed, 1 Mar 2023 18:16:53 +0000 Received: from VI1PR08MB5325.eurprd08.prod.outlook.com ([fe80::210c:d369:23f7:84fe]) by VI1PR08MB5325.eurprd08.prod.outlook.com ([fe80::210c:d369:23f7:84fe%9]) with mapi id 15.20.6156.017; Wed, 1 Mar 2023 18:16:52 +0000 From: Tamar Christina To: Andrew Carlotti , Andrew MacLeod CC: Richard Biener , Richard Sandiford , Tamar Christina via Gcc-patches , nd , "jlaw@ventanamicro.com" Subject: RE: [PATCH 1/2]middle-end: Fix wrong overmatching of div-bitmask by using new optabs [PR108583] Thread-Topic: [PATCH 1/2]middle-end: Fix wrong overmatching of div-bitmask by using new optabs [PR108583] Thread-Index: AQHZPKpK/SYCPI4EDky3xQ0ADEnbFq7IMBSsgAABFlCAACYcToAAAIfAgAAHedGAAACH4IAACHVAgAAA0cCAABQEOYAABjyAgAAoTgCAA/r5IIADVoOwgAA4L4CAAAy+gIAAEL0AgAAObICACt6YgIAAFf6ggAAJP4CAAOkEEIAAiYWAgAly74CAAAjncA== Date: Wed, 1 Mar 2023 18:16:49 +0000 Message-ID: References: <77142b9b-7af8-eb04-e596-6dd2f97aff9a@redhat.com> <9378f3fb-0538-45fd-5066-1920de50e6c9@redhat.com> <46f59672-9e6b-81a0-fccc-a4aa0c9c31b2@redhat.com> In-Reply-To: Accept-Language: en-US Content-Language: en-US X-MS-Has-Attach: X-MS-TNEF-Correlator: x-ts-tracking-id: 523C8DE7A752E0418F7F9B95B82DF205.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-traffictypediagnostic: VI1PR08MB5325:EE_|AS2PR08MB10268:EE_|DBAEUR03FT024:EE_|DB9PR08MB6490:EE_ X-MS-Office365-Filtering-Correlation-Id: 77102190-a1c6-443d-70a2-08db1a81317e 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: 0+V0MJ+33hm6owxATzrTWme3i432M7U3J35p/ivimd0u+LdcHisGbKfe2zUZpF+8WD7Cm7ccQhjEhleMY5GYFsA/pcieRUJGQ+72FwdjT45uKj6+xvrzQlQpM8nIjTZ8utUTTsReEIbkwfBJiBsNP6RKmOIDoVH4OhTBfhFQnuiVzjGNt9vlJB97bftAD0ypPqMjzdKmpN527o3KNTQn5Z5Nk9qkdRADjODMA/ZcHdfpRFuiWT18/MuwG6ME32Q7k0baNiHEe9u8KiYxpqalpGlTzQ46CpZYwpR1BzuSSEhF93+EzMT+MxFP7fIj8SZdBJiSROBOcHMY7rNvSdyRXIrZUhv3v1PyB59tBsrzZRpNWdMdCWOm6T1xX1kaLMIH8gTPVqTVO3y24HJCDp5w+8ONFVKCNAFEXSXK8khviuOKUwkeHQ9Z5phvCuk8aOefi+QY2UAhSMnht1Jg5qHImVnDak/oQiv2Ehg6D+n0UtWZ4pl9h52qEkclrUVA/II3Ru7L5YiDMcRxiAHkMT5EK+dPDbXVdnrhK6tbEQ5KDQmMm8SkBe12kX3bbjkPkuNC9RVWDoL9HElUPmvaH4IhQWVU/QSTkz3n97KPftkAX9be2BBHof2NrA+mNNu6RVdSz0rz4RK5PLM4foBvQReoHTN2ckiEuMFi42bA+L9vCglRZ4Krazf4wN7k5oPXrxMKtHwDGjo0C1FLlyBZQ4Bn2A== 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:(13230025)(4636009)(346002)(136003)(396003)(376002)(39860400002)(366004)(451199018)(122000001)(38100700002)(38070700005)(86362001)(33656002)(41300700001)(2906002)(30864003)(52536014)(66476007)(66446008)(64756008)(66946007)(55016003)(66556008)(4326008)(5660300002)(8936002)(8676002)(76116006)(6506007)(53546011)(26005)(186003)(9686003)(83380400001)(110136005)(316002)(6666004)(7696005)(71200400001)(478600001)(54906003);DIR:OUT;SFP:1101; Content-Type: text/plain; charset="iso-8859-1" Content-Transfer-Encoding: quoted-printable MIME-Version: 1.0 X-MS-Exchange-Transport-CrossTenantHeadersStamped: AS2PR08MB10268 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: DBAEUR03FT024.eop-EUR03.prod.protection.outlook.com X-MS-PublicTrafficType: Email X-MS-Office365-Filtering-Correlation-Id-Prvs: 57dae0de-b6fa-415a-5fa7-08db1a812041 X-Microsoft-Antispam: BCL:0; X-Microsoft-Antispam-Message-Info: DWzdp/z+fWz2R4K5IwtYRCulsjp+kB0WLoUBmYfXmEtltCz+Vs6dhIBIoCqZBp0wahiaXK0JP6RVW3vPcaM0+kOyv+m478C75mdrftX4TZE3yGu1HcpuAzgsb+w7UFjL6voKVXP/KfY13iRi34tvzl3ByfP0u0OUNr42qa+YYQYw5Fe3iiA1tzo3Eq/ndGy8pHurRLymBpzL1wgIc5H1LIoMP9sBvmXMnX5qC6/p84k9huAUP0P1UjDS4D3h6kUFe6DTYXdnY6uWQIxcyDMgNUqlpoWcMaA1JxNcUnoApmOHIFkIX0U9NzOmXHxFmAo0va8I40cVKuDioGN3doz5tRIlYs78M68yR2ObDPrutudo8r7dj8fo6lL/YP+dHLP38XX6t/sH906RztBbQoQ78w76mWQvemGRk17O3A5D89ET8aJv3lyTOHAmmsqtUkLQrCN/1ybFVLrUhNiB5QEqpezJTWddculm5XBXwdBb4CD+a1zADJd24G1JpNkxUYdSLEARFmwrHoEZJggurtrKbyKA7GmGDKdpH0u0rOqcW5jKoNeJIfym/qhX8vQzqb5Rc9pSySAYQzlB6Rjg7MdxHdbXzdw2Xe746nog1s2UnzcHRoX9ztA5XgYklNgqnhT4VnLlTrFpOyVKrMxH4us8at8hhLQwM+1Cy5cJqJG0eO7201JH0KzggAFxupE7yKcIjps0+wcStYD5Q7oMQcs+tQ== 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:(13230025)(4636009)(346002)(39860400002)(136003)(396003)(376002)(451199018)(46966006)(40470700004)(36840700001)(52536014)(8936002)(36860700001)(30864003)(81166007)(82740400003)(5660300002)(82310400005)(4326008)(41300700001)(8676002)(70586007)(70206006)(55016003)(54906003)(7696005)(110136005)(478600001)(33656002)(40460700003)(107886003)(2906002)(47076005)(83380400001)(6666004)(336012)(356005)(53546011)(40480700001)(26005)(316002)(86362001)(186003)(6506007)(9686003);DIR:OUT;SFP:1101; X-OriginatorOrg: arm.com X-MS-Exchange-CrossTenant-OriginalArrivalTime: 01 Mar 2023 18:17:18.6530 (UTC) X-MS-Exchange-CrossTenant-Network-Message-Id: 77102190-a1c6-443d-70a2-08db1a81317e 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: DBAEUR03FT024.eop-EUR03.prod.protection.outlook.com X-MS-Exchange-CrossTenant-AuthAs: Anonymous X-MS-Exchange-CrossTenant-FromEntityHeader: HybridOnPrem X-MS-Exchange-Transport-CrossTenantHeadersStamped: DB9PR08MB6490 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,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 List-Id: > -----Original Message----- > From: Andrew Carlotti > Sent: Wednesday, March 1, 2023 4:58 PM > To: Andrew MacLeod > Cc: Tamar Christina ; Richard Biener > ; Richard Sandiford ; > Tamar Christina via Gcc-patches ; nd > ; jlaw@ventanamicro.com > Subject: Re: [PATCH 1/2]middle-end: Fix wrong overmatching of div-bitmask > by using new optabs [PR108583] >=20 > On Thu, Feb 23, 2023 at 11:39:51AM -0500, Andrew MacLeod via Gcc- > patches wrote: > > > > > > Inheriting from operator_mult is also going to be hazardous because it > > also has an op1_range and op2_range...=EF=BF=BD you should at least def= ine > > those and return VARYING to avoid other issues.=EF=BF=BD Same thing app= lies > > to widen_plus I think, and it has relation processing and other things > > as well.=EF=BF=BD Your widen operands are not what those classes expect= , so > > I think you probably just want a fresh range operator. > > > > It also looks like the mult operation is sign/zero extending both > > upper bounds, and neither lower bound..=EF=BF=BD=EF=BF=BD I think that = should be > > the LH upper and lower bound? > > > > I've attached a second patch=EF=BF=BD (newversion.patch) which incorpor= ates > > my fix, the fix to the sign of only op1's bounds,=EF=BF=BD as well as a > > simplification of the classes to not inherit from > > operator_mult/plus..=EF=BF=BD=EF=BF=BD I think this still does what you= want?=EF=BF=BD > > and it wont get you into unexpected trouble later :-) > > > > let me know if this is still doing what you are expecting... > > > > Andrew > > >=20 > Hi, >=20 > This patch still uses the wrong signedness for some of the extensions in > WIDEN_MULT_EXPR. It currently bases it's promotion decisions on whether > there is any signed argument, and whether the result is signed - i.e.: >=20 > Patch extends as: > UUU UU > UUS -> USU > USU SU > USS SU wrong > SUU US wrong > SUS -> SSU > SSU SS wrong > SSS SS >=20 > The documentation in tree.def is unclear about whether the output > signedness is linked to the input signedness, but at least the SSU case s= eems > valid, and is mishandled here. Hi, Thanks for the concern, but I don't think those "wrong" cases are valid. There's only one explicit carve-out for this mismatch that I'm aware of whi= ch is for constants that fit in the source type. convert_mult_to_widen doesn't a= ccept them otherwise. For every other mismatched sign it will fold an explicit convert into the s= equence to ensure all three types match. i.e.=20 long unsigned d1(int x, int y) { return (long unsigned)x * y; } Requires a cast. long unsigned d1(int x, int y) { return (long unsigned)x * 4; } Does not, and long unsigned d1(int x, int y) { return (long unsigned)x * -4; } Does not fit and so is not accepted. The reason it can happen is that the = unsigned cast on a positive constant is discarded. Further more, the operation that introduces this widening only looks at the= sign of the left most operand and that of the result. So this is correctly handling the normal cases and the abnormal ones the co= mpiler introduces as specific optimizations. Tamar. >=20 > I think it would be clearer and simpler to have four (or three) different= versions > for each combnation of signedness of the input operands. This could be > implemented without extra code duplication by creating four different > instances of an operator_widen_mult class (perhaps extending a > range_operator_mixed_sign class), with the signedness indicated by two > additional class members. >=20 > The documentation for WIDEN_PLUS_EXPR (and several other expressions > added in the same commit) is completely missing. If the signs are require= d to > be matching, then this should be clarified; otherwise it would need the s= ame > special handling as WIDEN_MULT_EXPR. >=20 > Andrew >=20 > > diff --git a/gcc/gimple-range-op.cc b/gcc/gimple-range-op.cc index > > d9dfdc56939..824e0338f34 100644 > > --- a/gcc/gimple-range-op.cc > > +++ b/gcc/gimple-range-op.cc > > @@ -179,6 +179,8 @@ > gimple_range_op_handler::gimple_range_op_handler (gimple *s) > > // statements. > > if (is_a (m_stmt)) > > maybe_builtin_call (); > > + else > > + maybe_non_standard (); > > } > > > > // Calculate what we can determine of the range of this unary @@ > > -764,6 +766,36 @@ public: > > } > > } op_cfn_parity; > > > > +// Set up a gimple_range_op_handler for any nonstandard function > > +which can be // supported via range-ops. > > + > > +void > > +gimple_range_op_handler::maybe_non_standard () { > > + if (gimple_code (m_stmt) =3D=3D GIMPLE_ASSIGN) > > + switch (gimple_assign_rhs_code (m_stmt)) > > + { > > + case WIDEN_MULT_EXPR: > > + { > > + m_valid =3D true; > > + m_op1 =3D gimple_assign_rhs1 (m_stmt); > > + m_op2 =3D gimple_assign_rhs2 (m_stmt); > > + bool signed1 =3D TYPE_SIGN (TREE_TYPE (m_op1)) =3D=3D SIGNED; > > + bool signed2 =3D TYPE_SIGN (TREE_TYPE (m_op2)) =3D=3D SIGNED; > > + if (signed2 && !signed1) > > + std::swap (m_op1, m_op2); > > + > > + if (signed1 || signed2) > > + m_int =3D ptr_op_widen_mult_signed; > > + else > > + m_int =3D ptr_op_widen_mult_unsigned; > > + break; > > + } > > + default: > > + break; > > + } > > +} > > + > > // Set up a gimple_range_op_handler for any built in function which > > can be // supported via range-ops. > > > > diff --git a/gcc/gimple-range-op.h b/gcc/gimple-range-op.h index > > 743b858126e..1bf63c5ce6f 100644 > > --- a/gcc/gimple-range-op.h > > +++ b/gcc/gimple-range-op.h > > @@ -41,6 +41,7 @@ public: > > relation_trio =3D TRIO_VARYING); > > private: > > void maybe_builtin_call (); > > + void maybe_non_standard (); > > gimple *m_stmt; > > tree m_op1, m_op2; > > }; > > diff --git a/gcc/range-op.cc b/gcc/range-op.cc index > > 5c67bce6d3a..7cd19a92d00 100644 > > --- a/gcc/range-op.cc > > +++ b/gcc/range-op.cc > > @@ -1556,6 +1556,34 @@ operator_plus::op2_range (irange &r, tree type, > > return op1_range (r, type, lhs, op1, rel.swap_op1_op2 ()); } > > > > +class operator_widen_plus : public range_operator { > > +public: > > + virtual void wi_fold (irange &r, tree type, > > + const wide_int &lh_lb, > > + const wide_int &lh_ub, > > + const wide_int &rh_lb, > > + const wide_int &rh_ub) const; > > +} op_widen_plus; > > + > > +void > > +operator_widen_plus::wi_fold (irange &r, tree type, > > + const wide_int &lh_lb, const wide_int &lh_ub, > > + const wide_int &rh_lb, const wide_int &rh_ub) const { > > + wi::overflow_type ov_lb, ov_ub; > > + signop s =3D TYPE_SIGN (type); > > + > > + wide_int lh_wlb =3D wide_int::from (lh_lb, wi::get_precision (lh_lb= ) * 2, s); > > + wide_int rh_wlb =3D wide_int::from (rh_lb, wi::get_precision (rh_lb= ) * 2, s); > > + wide_int lh_wub =3D wide_int::from (lh_ub, wi::get_precision (lh_ub= ) * 2, s); > > + wide_int rh_wub =3D wide_int::from (rh_ub, wi::get_precision (rh_ub= ) > > + * 2, s); > > + > > + wide_int new_lb =3D wi::add (lh_wlb, rh_wlb, s, &ov_lb); > > + wide_int new_ub =3D wi::add (lh_wub, rh_wub, s, &ov_ub); > > + > > + r =3D int_range<2> (type, new_lb, new_ub); } > > > > class operator_minus : public range_operator { @@ -2031,6 +2059,70 > > @@ operator_mult::wi_fold (irange &r, tree type, > > } > > } > > > > +class operator_widen_mult_signed : public range_operator { > > +public: > > + virtual void wi_fold (irange &r, tree type, > > + const wide_int &lh_lb, > > + const wide_int &lh_ub, > > + const wide_int &rh_lb, > > + const wide_int &rh_ub) > > + const; > > +} op_widen_mult_signed; > > +range_operator *ptr_op_widen_mult_signed =3D &op_widen_mult_signed; > > + > > +void > > +operator_widen_mult_signed::wi_fold (irange &r, tree type, > > + const wide_int &lh_lb, > > + const wide_int &lh_ub, > > + const wide_int &rh_lb, > > + const wide_int &rh_ub) const { > > + signop s =3D TYPE_SIGN (type); > > + > > + wide_int lh_wlb =3D wide_int::from (lh_lb, wi::get_precision (lh_lb) > > + * 2, SIGNED); wide_int lh_wub =3D wide_int::from (lh_ub, > > + wi::get_precision (lh_ub) * 2, SIGNED); wide_int rh_wlb =3D > > + wide_int::from (rh_lb, wi::get_precision (rh_lb) * 2, s); wide_int > > + rh_wub =3D wide_int::from (rh_ub, wi::get_precision (rh_ub) * 2, s); > > + > > + /* We don't expect a widening multiplication to be able to overflow = but > range > > + calculations for multiplications are complicated. After widening= the > > + operands lets call the base class. */ > > + return op_mult.wi_fold (r, type, lh_wlb, lh_wub, rh_wlb, rh_wub); } > > + > > + > > +class operator_widen_mult_unsigned : public range_operator { > > +public: > > + virtual void wi_fold (irange &r, tree type, > > + const wide_int &lh_lb, > > + const wide_int &lh_ub, > > + const wide_int &rh_lb, > > + const wide_int &rh_ub) > > + const; > > +} op_widen_mult_unsigned; > > +range_operator *ptr_op_widen_mult_unsigned =3D > &op_widen_mult_unsigned; > > + > > +void > > +operator_widen_mult_unsigned::wi_fold (irange &r, tree type, > > + const wide_int &lh_lb, > > + const wide_int &lh_ub, > > + const wide_int &rh_lb, > > + const wide_int &rh_ub) const { > > + signop s =3D TYPE_SIGN (type); > > + > > + wide_int lh_wlb =3D wide_int::from (lh_lb, wi::get_precision (lh_lb) > > + * 2, UNSIGNED); wide_int lh_wub =3D wide_int::from (lh_ub, > > + wi::get_precision (lh_ub) * 2, UNSIGNED); wide_int rh_wlb =3D > > + wide_int::from (rh_lb, wi::get_precision (rh_lb) * 2, s); wide_int > > + rh_wub =3D wide_int::from (rh_ub, wi::get_precision (rh_ub) * 2, s); > > + > > + /* We don't expect a widening multiplication to be able to overflow = but > range > > + calculations for multiplications are complicated. After widening= the > > + operands lets call the base class. */ > > + return op_mult.wi_fold (r, type, lh_wlb, lh_wub, rh_wlb, rh_wub); } > > > > class operator_div : public cross_product_operator { @@ -4473,6 > > +4565,7 @@ integral_table::integral_table () > > set (GT_EXPR, op_gt); > > set (GE_EXPR, op_ge); > > set (PLUS_EXPR, op_plus); > > + set (WIDEN_PLUS_EXPR, op_widen_plus); > > set (MINUS_EXPR, op_minus); > > set (MIN_EXPR, op_min); > > set (MAX_EXPR, op_max); > > diff --git a/gcc/range-op.h b/gcc/range-op.h index > > f00b747f08a..5fe463234ae 100644 > > --- a/gcc/range-op.h > > +++ b/gcc/range-op.h > > @@ -311,4 +311,6 @@ private: > > // This holds the range op table for floating point operations. > > extern floating_op_table *floating_tree_table; > > > > +extern range_operator *ptr_op_widen_mult_signed; extern > > +range_operator *ptr_op_widen_mult_unsigned; > > #endif // GCC_RANGE_OP_H