From patchwork Thu Jan 11 14:07:45 2024 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Richard Biener X-Patchwork-Id: 187395 Return-Path: Delivered-To: ouuuleilei@gmail.com Received: by 2002:a05:7300:2411:b0:101:2151:f287 with SMTP id m17csp1474712dyi; Thu, 11 Jan 2024 06:13:44 -0800 (PST) X-Google-Smtp-Source: AGHT+IHvmEqOvsECnFLMzVBbKMhdHOuyAqlWaCnFKji3PlBfQ897+cYT+WHMa29SDaHe5uHfap/P X-Received: by 2002:a81:998f:0:b0:5f6:c117:ab55 with SMTP id q137-20020a81998f000000b005f6c117ab55mr690426ywg.5.1704982424369; Thu, 11 Jan 2024 06:13:44 -0800 (PST) ARC-Seal: i=2; a=rsa-sha256; t=1704982424; cv=pass; d=google.com; s=arc-20160816; b=Sxa4QAZ5gQFIsgwfjTbTkiURHK8zvNVrx66LTYckzSxxEaw78/aeAgB7hZ4hJlcZZi H5+xdmtc4tQiyeeHO2VL10CoDZSUrz4yw+q/X1Vm8vLp/DbJmtr7s7w8azSQr2Hem8vu tJOwbtxLHlTWtacwpzsGTN0VvZ7hPUmbvTUrvp7pc0MgVsN1SqXpIyuuNzuX5g8GQnnz iE4dmOuT507KBKUVoLTLXePRXj3h0DflEO+/NduxI5E4BbLoGoT3xpfaYgHu5ctSJejz 5mU2dD9wfLkoaOb34iwlhUkAp/lfetzfoOAIiUfpPyt8fgnWuvFuD1V/PSEzN3irEQBG 56DQ== ARC-Message-Signature: i=2; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=message-id:errors-to:list-subscribe:list-help:list-post :list-archive:list-unsubscribe:list-id:precedence:mime-version :subject:to:from:date:dkim-signature:dkim-signature:dkim-signature :dkim-signature:arc-filter:dmarc-filter:delivered-to; bh=yECpVuuh7HHjENQqDNd+N0u9fsyhZ9z5ptcuC60aKXo=; fh=hPrbWPhweUx4V0GV9uXJqbyAzg2ABmTz7kczrAQqMmM=; b=C8uq8cHrlGkirzyQXM4RPgrz0smyyxIdWRDtgKAVcTEEyNO+w+xl46+b6Jd2j/IwnT tnpoaNZmsLSnjIFLWlv9/0c1/3+2UhRsPcUJURxZPf9aOnp5EbNKlewYeKW91ZEyGXjq c5Zv7vGDcmkhQMkPZ9n+5sIhwiS9BrayzTZIRM4E1ghvrWO+t2LdBDTk9Yl45lB5/dEz 7IRah9do243rIfIfuHO6p531Uw43WLlPSOZiBK/zoQtzRbn0woQ56Bf0fn1PFryqxth7 eHJEUZe+NvZQ4IRB10PpazschzyYyth9kC13yP4160GmUtd5v8YTneqMI82qNcRk3i4I Q7sQ== ARC-Authentication-Results: i=2; mx.google.com; dkim=pass header.i=@suse.de header.s=susede2_rsa header.b=s0qJRCDg; dkim=neutral (no key) header.i=@suse.de header.s=susede2_ed25519 header.b=NvpE15zJ; dkim=pass header.i=@suse.de header.s=susede2_rsa header.b=vyMuk4Hy; dkim=neutral (no key) header.i=@suse.de; arc=pass (i=1); spf=pass (google.com: domain of gcc-patches-bounces+ouuuleilei=gmail.com@gcc.gnu.org designates 2620:52:3:1:0:246e:9693:128c as permitted sender) smtp.mailfrom="gcc-patches-bounces+ouuuleilei=gmail.com@gcc.gnu.org"; dmarc=pass (p=NONE sp=NONE dis=NONE) header.from=suse.de Received: from server2.sourceware.org (server2.sourceware.org. [2620:52:3:1:0:246e:9693:128c]) by mx.google.com with ESMTPS id k18-20020a056102005200b004678881b680si102752vsp.30.2024.01.11.06.13.44 for (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Thu, 11 Jan 2024 06:13:44 -0800 (PST) Received-SPF: pass (google.com: domain of gcc-patches-bounces+ouuuleilei=gmail.com@gcc.gnu.org designates 2620:52:3:1:0:246e:9693:128c as permitted sender) client-ip=2620:52:3:1:0:246e:9693:128c; Authentication-Results: mx.google.com; dkim=pass header.i=@suse.de header.s=susede2_rsa header.b=s0qJRCDg; dkim=neutral (no key) header.i=@suse.de header.s=susede2_ed25519 header.b=NvpE15zJ; dkim=pass header.i=@suse.de header.s=susede2_rsa header.b=vyMuk4Hy; dkim=neutral (no key) header.i=@suse.de; arc=pass (i=1); spf=pass (google.com: domain of gcc-patches-bounces+ouuuleilei=gmail.com@gcc.gnu.org designates 2620:52:3:1:0:246e:9693:128c as permitted sender) smtp.mailfrom="gcc-patches-bounces+ouuuleilei=gmail.com@gcc.gnu.org"; dmarc=pass (p=NONE sp=NONE dis=NONE) header.from=suse.de Received: from server2.sourceware.org (localhost [IPv6:::1]) by sourceware.org (Postfix) with ESMTP id 7F7D738618AB for ; Thu, 11 Jan 2024 14:13:40 +0000 (GMT) X-Original-To: gcc-patches@gcc.gnu.org Delivered-To: gcc-patches@gcc.gnu.org Received: from smtp-out2.suse.de (smtp-out2.suse.de [195.135.223.131]) by sourceware.org (Postfix) with ESMTPS id 0014B386186C for ; Thu, 11 Jan 2024 14:12:49 +0000 (GMT) DMARC-Filter: OpenDMARC Filter v1.4.2 sourceware.org 0014B386186C Authentication-Results: sourceware.org; dmarc=pass (p=none dis=none) header.from=suse.de Authentication-Results: sourceware.org; spf=pass smtp.mailfrom=suse.de ARC-Filter: OpenARC Filter v1.0.0 sourceware.org 0014B386186C Authentication-Results: server2.sourceware.org; arc=none smtp.remote-ip=195.135.223.131 ARC-Seal: i=1; a=rsa-sha256; d=sourceware.org; s=key; t=1704982371; cv=none; b=cMYuj3+4uD/wc7YAW2FLuL0VMhFm13BpRiW2YQ+udiJDOADRi6YELyY8cGts6d5I/5CRHKipXa8jBMvbvWHEg+6H3Jjku7LUQsT0XBv5oOMZtFsmgIkMBce1P6NUDIf1Y5toiFvQztaWR61yZvxQ1loepfbyLxDEmwxMVtnnvx0= ARC-Message-Signature: i=1; a=rsa-sha256; d=sourceware.org; s=key; t=1704982371; c=relaxed/simple; bh=ZBQ4M1rOeuXxjRnyYrVpQ+IfL1BHxHDJOZUIpUsB3xY=; h=DKIM-Signature:DKIM-Signature:DKIM-Signature:DKIM-Signature:Date: From:To:Subject:MIME-Version; b=Lg8P7QJL3a3aPHEJWhkovCipTn4Ej+9SJtjfR0QZzhD3xOjV8Bj+nU+f6EokQTAFIWGfv1mz5WiLwX30Gv+KPjvbjQaRRvfjL3JKE5zDhqz7XkXLeMRQMknQV5wr0enRSC6vdLRa27bYc7seQ9lDUjvXli/Tqyc3A6j6SbCwbpI= ARC-Authentication-Results: i=1; server2.sourceware.org Received: from [10.168.4.150] (unknown [10.168.4.150]) (using TLSv1.3 with cipher TLS_AES_256_GCM_SHA384 (256/256 bits) key-exchange X25519 server-signature RSA-PSS (4096 bits) server-digest SHA256) (No client certificate requested) by smtp-out2.suse.de (Postfix) with ESMTPS id DFF181FBB0 for ; Thu, 11 Jan 2024 14:12:46 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=suse.de; s=susede2_rsa; t=1704982368; h=from:from:reply-to:date:date:to:to:cc:mime-version:mime-version: content-type:content-type; bh=yECpVuuh7HHjENQqDNd+N0u9fsyhZ9z5ptcuC60aKXo=; b=s0qJRCDg3adISvaqw+Keo4dL2ZF4kFdkGaA8VxBAhYEl7aVK26bvRtCGf31eXnoVktbPqs lxyJjKX0CF3evg98+VfDbKCvh40HjaErBxlWX9S+yYxzNDhMueLSj6hm7hmZUUayWW0dgG xeTGb4X7nq81oTxJgTEA69+pv//azSE= DKIM-Signature: v=1; a=ed25519-sha256; c=relaxed/relaxed; d=suse.de; s=susede2_ed25519; t=1704982368; h=from:from:reply-to:date:date:to:to:cc:mime-version:mime-version: content-type:content-type; bh=yECpVuuh7HHjENQqDNd+N0u9fsyhZ9z5ptcuC60aKXo=; b=NvpE15zJCIVaHULhH3B5ZvXzUMzM1718a+mCARGf+usu7vNpYYjDvdWIktzEi93WJfUDsQ Bt+YFPku4NabwPBQ== DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=suse.de; s=susede2_rsa; t=1704982366; h=from:from:reply-to:date:date:to:to:cc:mime-version:mime-version: content-type:content-type; bh=yECpVuuh7HHjENQqDNd+N0u9fsyhZ9z5ptcuC60aKXo=; b=vyMuk4HyGFTfST8ff6FiNmKCJusSBBfQqHuHKg0ykMBVI84j8cn8owr5RUVutjxpZQpn7t bQ4g/bP3brHq9a05CLeTKwzmNyn8WnerMTryi6YAtoL5uqO/GOysSJ9sKtGSwtxcxUC7Iy N64Iu6j+kfvPPK3G6N/rn4RZGvTjTrA= DKIM-Signature: v=1; a=ed25519-sha256; c=relaxed/relaxed; d=suse.de; s=susede2_ed25519; t=1704982366; h=from:from:reply-to:date:date:to:to:cc:mime-version:mime-version: content-type:content-type; bh=yECpVuuh7HHjENQqDNd+N0u9fsyhZ9z5ptcuC60aKXo=; b=38jkfctKPLAWRRv3URhwE+S1ak8nDu3GDfgDqeXLYVLcwpILboZRPw72UVffvNxMe944Gg itlGzIywqov07xDw== Date: Thu, 11 Jan 2024 15:07:45 +0100 (CET) From: Richard Biener To: gcc-patches@gcc.gnu.org Subject: [PATCH] tree-optimization/113126 - vector extension compare optimization MIME-Version: 1.0 Authentication-Results: smtp-out2.suse.de; none X-Spamd-Result: default: False [2.16 / 50.00]; ARC_NA(0.00)[]; FROM_HAS_DN(0.00)[]; TO_MATCH_ENVRCPT_ALL(0.00)[]; MIME_GOOD(-0.10)[text/plain]; TO_DN_NONE(0.00)[]; RCPT_COUNT_ONE(0.00)[1]; MISSING_MID(2.50)[]; DKIM_SIGNED(0.00)[suse.de:s=susede2_rsa,suse.de:s=susede2_ed25519]; DBL_BLOCKED_OPENRESOLVER(0.00)[fold-const.cc:url]; FUZZY_BLOCKED(0.00)[rspamd.com]; RCVD_COUNT_ZERO(0.00)[0]; FROM_EQ_ENVFROM(0.00)[]; MIME_TRACE(0.00)[0:+]; BAYES_HAM(-0.24)[72.86%] X-Spam-Score: 2.16 X-Spam-Status: No, score=-10.9 required=5.0 tests=BAYES_00, DKIM_SIGNED, DKIM_VALID, DKIM_VALID_AU, DKIM_VALID_EF, GIT_PATCH_0, MISSING_MID, 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 X-BeenThere: gcc-patches@gcc.gnu.org X-Mailman-Version: 2.1.30 Precedence: list List-Id: Gcc-patches mailing list List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Errors-To: gcc-patches-bounces+ouuuleilei=gmail.com@gcc.gnu.org Message-Id: <20240111141340.7F7D738618AB@sourceware.org> X-getmail-retrieved-from-mailbox: INBOX X-GMAIL-THRID: 1787803650781223674 X-GMAIL-MSGID: 1787803650781223674 The following makes sure the resulting boolean type is the same when eliding a float extension. Bootstrapped and tested on x86_64-unknown-linux-gnu, pushed. PR tree-optimization/113126 * match.pd ((double)float CMP (double)float -> float CMP float): Make sure the boolean type is the same. * fold-const.cc (fold_binary_loc): Likewise. * gcc.dg/torture/pr113126.c: New testcase. --- gcc/fold-const.cc | 3 ++- gcc/match.pd | 9 +++++---- gcc/testsuite/gcc.dg/torture/pr113126.c | 15 +++++++++++++++ 3 files changed, 22 insertions(+), 5 deletions(-) create mode 100644 gcc/testsuite/gcc.dg/torture/pr113126.c diff --git a/gcc/fold-const.cc b/gcc/fold-const.cc index 3a9d78b0c11..585c5099a37 100644 --- a/gcc/fold-const.cc +++ b/gcc/fold-const.cc @@ -12900,7 +12900,8 @@ fold_binary_loc (location_t loc, enum tree_code code, tree type, if (element_precision (TREE_TYPE (targ1)) > element_precision (newtype)) newtype = TREE_TYPE (targ1); - if (element_precision (newtype) < element_precision (TREE_TYPE (arg0))) + if (element_precision (newtype) < element_precision (TREE_TYPE (arg0)) + && is_truth_type_for (newtype, type)) return fold_build2_loc (loc, code, type, fold_convert_loc (loc, newtype, targ0), fold_convert_loc (loc, newtype, targ1)); diff --git a/gcc/match.pd b/gcc/match.pd index 876a9d1c06e..abbd03742f9 100644 --- a/gcc/match.pd +++ b/gcc/match.pd @@ -6792,11 +6792,12 @@ DEFINE_INT_AND_FLOAT_ROUND_FN (RINT) && exact_real_truncate (TYPE_MODE (double_type_node), &orig)) type1 = double_type_node; } - tree newtype - = (element_precision (TREE_TYPE (@00)) > element_precision (type1) - ? TREE_TYPE (@00) : type1); + tree newtype + = (element_precision (TREE_TYPE (@00)) > element_precision (type1) + ? TREE_TYPE (@00) : type1); } - (if (element_precision (TREE_TYPE (@0)) > element_precision (newtype)) + (if (element_precision (TREE_TYPE (@0)) > element_precision (newtype) + && is_truth_type_for (newtype, type)) (cmp (convert:newtype @00) (convert:newtype @10)))))))) diff --git a/gcc/testsuite/gcc.dg/torture/pr113126.c b/gcc/testsuite/gcc.dg/torture/pr113126.c new file mode 100644 index 00000000000..4aa38e0a255 --- /dev/null +++ b/gcc/testsuite/gcc.dg/torture/pr113126.c @@ -0,0 +1,15 @@ +/* { dg-do compile } */ + +typedef float __attribute__((__vector_size__ (8))) F; +typedef double __attribute__((__vector_size__ (16))) G; + +F f; +G g; + +F +foo (void) +{ + G h = __builtin_convertvector (f, G); + g = h <= h; + return f; +}