From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: Received: by sourceware.org (Postfix, from userid 1666) id 3A611385842E; Fri, 23 Jun 2023 09:23:46 +0000 (GMT) DKIM-Filter: OpenDKIM Filter v2.11.0 sourceware.org 3A611385842E DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gcc.gnu.org; s=default; t=1687512226; bh=vd7FDsQ4pMRnlM02GC2Fq1ky7SjSx28rkMZgf7kS11w=; h=From:To:Subject:Date:From; b=G8FCuEgknT8vKesLiDjsQlcxjOFwqmfDstMsXEUT/zJ81BF1B4o5C5h7RF+w6n7Cl z9q14HQZqKnGSt24IVPXkExWw7oKhWFLb9u7kMPu6BqbiZriSSCYgV0DULJV+Cfil3 eAmwSMFMdo7IAU07QF1gT9QRxrwiBkS/8BhySzEo= MIME-Version: 1.0 Content-Transfer-Encoding: 7bit Content-Type: text/plain; charset="utf-8" From: Richard Biener To: gcc-cvs@gcc.gnu.org Subject: [gcc r14-2041] Use element_precision for match.pd arith conversion optimization X-Act-Checkin: gcc X-Git-Author: Richard Biener X-Git-Refname: refs/heads/master X-Git-Oldrev: 6b32400e19a702137fd11571d199f725add0daf6 X-Git-Newrev: 1fe09b90f856ba27c3e44dda156b28adb5d4d8ea Message-Id: <20230623092346.3A611385842E@sourceware.org> Date: Fri, 23 Jun 2023 09:23:46 +0000 (GMT) List-Id: https://gcc.gnu.org/g:1fe09b90f856ba27c3e44dda156b28adb5d4d8ea commit r14-2041-g1fe09b90f856ba27c3e44dda156b28adb5d4d8ea Author: Richard Biener Date: Fri Jun 23 10:20:45 2023 +0200 Use element_precision for match.pd arith conversion optimization The simplification (outertype)((innertype0)a+(innertype1)b) to ((newtype)a+(newtype)b) ends up using TYPE_PRECISION to check whether it can elide a conversion but in some paths there can be VECTOR_TYPEs where this instead compares the number of lanes. The following fixes the missed optimizations and uses element_precision in those places. * match.pd ((outertype)((innertype0)a+(innertype1)b) -> ((newtype)a+(newtype)b)): Use element_precision where appropriate. Diff: --- gcc/match.pd | 8 ++++---- 1 file changed, 4 insertions(+), 4 deletions(-) diff --git a/gcc/match.pd b/gcc/match.pd index 85d562a531d..48b76e6a051 100644 --- a/gcc/match.pd +++ b/gcc/match.pd @@ -7428,9 +7428,9 @@ DEFINE_INT_AND_FLOAT_ROUND_FN (RINT) && newtype == type && types_match (newtype, type)) (op (convert:newtype @1) (convert:newtype @2)) - (with { if (TYPE_PRECISION (ty1) > TYPE_PRECISION (newtype)) + (with { if (element_precision (ty1) > element_precision (newtype)) newtype = ty1; - if (TYPE_PRECISION (ty2) > TYPE_PRECISION (newtype)) + if (element_precision (ty2) > element_precision (newtype)) newtype = ty2; } /* Sometimes this transformation is safe (cannot change results through affecting double rounding @@ -7453,9 +7453,9 @@ DEFINE_INT_AND_FLOAT_ROUND_FN (RINT) exponent range for the product or ratio of two values representable in the TYPE to be within the range of normal values of ITYPE. */ - (if (TYPE_PRECISION (newtype) < TYPE_PRECISION (itype) + (if (element_precision (newtype) < element_precision (itype) && (flag_unsafe_math_optimizations - || (TYPE_PRECISION (newtype) == TYPE_PRECISION (type) + || (element_precision (newtype) == element_precision (type) && real_can_shorten_arithmetic (TYPE_MODE (itype), TYPE_MODE (type)) && !excess_precision_type (newtype)))