From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: Received: from smtp-out2.suse.de (smtp-out2.suse.de [195.135.220.29]) by sourceware.org (Postfix) with ESMTPS id DFEF9385694E for ; Fri, 23 Jun 2023 08:27:59 +0000 (GMT) DMARC-Filter: OpenDMARC Filter v1.4.2 sourceware.org DFEF9385694E Authentication-Results: sourceware.org; dmarc=pass (p=none dis=none) header.from=suse.de Authentication-Results: sourceware.org; spf=pass smtp.mailfrom=suse.de Received: from imap2.suse-dmz.suse.de (imap2.suse-dmz.suse.de [192.168.254.74]) (using TLSv1.3 with cipher TLS_AES_256_GCM_SHA384 (256/256 bits) key-exchange X25519 server-signature ECDSA (P-521) server-digest SHA512) (No client certificate requested) by smtp-out2.suse.de (Postfix) with ESMTPS id 2265C1F45F for ; Fri, 23 Jun 2023 08:27:59 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=suse.de; s=susede2_rsa; t=1687508879; h=from:from:reply-to:date:date:message-id:message-id:to:to:cc: mime-version:mime-version:content-type:content-type; bh=R4Xpjp+m7akWZjVVg9tIe3M6OGTeWv4xTrZfKCKqcTw=; b=X/Rwv+IokzUkEdoJTDodtp54AFbqwFj9MomLFk8W7PzDKlERNYBEbGagoo2WZi2qn4UIwg rbdY2/Ywk2mxBDfriNEyJNJWxFKODoZVWdbwGSpqtMivAlKBtd5ZZkcNObMWlbvaf707hE 6ZKY9UVY4nAeFQTe+IIfuTFNmKRwFNA= DKIM-Signature: v=1; a=ed25519-sha256; c=relaxed/relaxed; d=suse.de; s=susede2_ed25519; t=1687508879; h=from:from:reply-to:date:date:message-id:message-id:to:to:cc: mime-version:mime-version:content-type:content-type; bh=R4Xpjp+m7akWZjVVg9tIe3M6OGTeWv4xTrZfKCKqcTw=; b=TgJPVl+aodiFRaDxQJlCkX5YpneXM9ar3gcHHgHJ/xIHsHdWgG8CGKyIVEC6LhMcQFIx6q +jRbBd0+RbXIAYBQ== Received: from imap2.suse-dmz.suse.de (imap2.suse-dmz.suse.de [192.168.254.74]) (using TLSv1.3 with cipher TLS_AES_256_GCM_SHA384 (256/256 bits) key-exchange X25519 server-signature ECDSA (P-521) server-digest SHA512) (No client certificate requested) by imap2.suse-dmz.suse.de (Postfix) with ESMTPS id 0DD281331F for ; Fri, 23 Jun 2023 08:27:59 +0000 (UTC) Received: from dovecot-director2.suse.de ([192.168.254.65]) by imap2.suse-dmz.suse.de with ESMTPSA id kuEqAo9XlWRoTQAAMHmgww (envelope-from ) for ; Fri, 23 Jun 2023 08:27:59 +0000 Date: Fri, 23 Jun 2023 10:27:58 +0200 (CEST) From: Richard Biener To: gcc-patches@gcc.gnu.org Subject: [PATCH 6/6] Use element_precision for match.pd arith conversion optimization MIME-Version: 1.0 Content-Type: text/plain; charset=US-ASCII Message-Id: <20230623082759.0DD281331F@imap2.suse-dmz.suse.de> X-Spam-Status: No, score=-11.5 required=5.0 tests=BAYES_00,DKIM_SIGNED,DKIM_VALID,DKIM_VALID_AU,DKIM_VALID_EF,GIT_PATCH_0,SPF_HELO_NONE,SPF_PASS,TXREP,T_SCC_BODY_TEXT_LINE 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: 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. Bootstrap and regtest ongoing on x86_64-unknown-linux-gnu, will push after that finished. * match.pd ((outertype)((innertype0)a+(innertype1)b) -> ((newtype)a+(newtype)b)): Use element_precision where appropriate. --- 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))) -- 2.35.3