From patchwork Mon Nov 6 08:55:58 2023 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Richard Biener X-Patchwork-Id: 161898 Return-Path: Delivered-To: ouuuleilei@gmail.com Received: by 2002:a59:8f47:0:b0:403:3b70:6f57 with SMTP id j7csp2523364vqu; Mon, 6 Nov 2023 00:56:22 -0800 (PST) X-Google-Smtp-Source: AGHT+IGx/kLwPs7gX9kh0PHgYuLOilJqQpc0exYhtP6gESkT0i8Y+m3GLP7g0JCc0F2drf7ha4Xq X-Received: by 2002:a05:6214:252f:b0:66d:544d:8276 with SMTP id gg15-20020a056214252f00b0066d544d8276mr32763200qvb.54.1699260982589; Mon, 06 Nov 2023 00:56:22 -0800 (PST) ARC-Seal: i=2; a=rsa-sha256; t=1699260982; cv=pass; d=google.com; s=arc-20160816; b=FSwGz+v0hoyVcmLJ3wBIu07EY83Bzy/lmmJa85vUPqTUJNvYUDEbplH0QAr3HWHRZS pdyH9tpYmHt8/tJNCqyEqm50kejOuj71UJkYSli9LruFvA568n2rJpb0DnZqdDuiBO7/ aWys035q2gIDavatqd2jrthN3jYN9XVjzoZQPLzelxLPMAar/nAe1SjmdQTp3tJqXyT6 aik7bIjI7zja9WbeYIjmKCWW9zo7ILHcHf7p3U6iT9beKWxfa6ExPk7my631U/1Be8Zk PG2hCS4Vc7ZqyXL7ZSPdn7xBUgCbrWxGF+9tDZfy1t1yPsduxh/BeSLJ/GfLA9n3OTDI LI2A== 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 :user-agent:subject:to:from:date:dkim-signature:dkim-signature :arc-filter:dmarc-filter:delivered-to; bh=DigCcXrNOa12o5gWb2BVkpgb9WHoyeB7nIyGpi8LivU=; fh=hPrbWPhweUx4V0GV9uXJqbyAzg2ABmTz7kczrAQqMmM=; b=VtNHQ/zds+Hddt5OgCWPMmgnahVMdLpleGc/IX+q2lGwvvZOsBI+i3NsV8RFEn80Nu snMXdgVK1Xp0lmmLpbmbL4PbFumbuofwc/9znpAEpjuv8q1BDoOxY/oT2PMQJjS3XkYK jAcgQU7XiCBnJiLbkPZcuCCjMB2GPRAAH526ovHpQDZGakSRVviJCmnw0cKFYr/uVR+M hNB3KeysdC55IJOX7vkMsH3G1vQJpG04fFUL7NK4n1gd/j0+7irm3LEKgaTpWLe8nD+l FUBpMu9ylGi7BfTVI5blSly9CDuAIhkLFF6h0zKFa+81uutVlR4hV/NesOz4EWyRycLc 7Gsw== ARC-Authentication-Results: i=2; mx.google.com; dkim=pass header.i=@suse.de header.s=susede2_rsa header.b=b8DZlwRE; 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 8.43.85.97 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. [8.43.85.97]) by mx.google.com with ESMTPS id l14-20020ad4444e000000b0066d10dd4de3si5195271qvt.563.2023.11.06.00.56.22 for (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Mon, 06 Nov 2023 00:56:22 -0800 (PST) Received-SPF: pass (google.com: domain of gcc-patches-bounces+ouuuleilei=gmail.com@gcc.gnu.org designates 8.43.85.97 as permitted sender) client-ip=8.43.85.97; Authentication-Results: mx.google.com; dkim=pass header.i=@suse.de header.s=susede2_rsa header.b=b8DZlwRE; 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 8.43.85.97 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 5B5C93858439 for ; Mon, 6 Nov 2023 08:56:22 +0000 (GMT) X-Original-To: gcc-patches@gcc.gnu.org Delivered-To: gcc-patches@gcc.gnu.org Received: from smtp-out1.suse.de (smtp-out1.suse.de [IPv6:2001:67c:2178:6::1c]) by sourceware.org (Postfix) with ESMTPS id 1C1D93858D28 for ; Mon, 6 Nov 2023 08:56:00 +0000 (GMT) DMARC-Filter: OpenDMARC Filter v1.4.2 sourceware.org 1C1D93858D28 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 1C1D93858D28 Authentication-Results: server2.sourceware.org; arc=none smtp.remote-ip=2001:67c:2178:6::1c ARC-Seal: i=1; a=rsa-sha256; d=sourceware.org; s=key; t=1699260961; cv=none; b=age/Gb5AbBZSZ9gBZE9cVxOT6Upr6XalL9WpkVaZ1cQ1g5Z3ZWP2RnfGth418xV2eHAL042N4yZnLrmqzA7ot6KYqG56zIqZ/9ahCMSqViZIT1Fu/1iS/T2Ov74SjLOb4u6C5gptz9bgUaxvWtk9YuOdafS1EO5nCdsTRzv9Cxk= ARC-Message-Signature: i=1; a=rsa-sha256; d=sourceware.org; s=key; t=1699260961; c=relaxed/simple; bh=dF4A8JO5w6O/Pk/l9pGQwLm/WdLeyr5BqClnPrkE5U0=; h=DKIM-Signature:DKIM-Signature:Date:From:To:Subject:MIME-Version; b=fXCQITwgW1VKH7MzJ49x2wBOsEMdH1Hguq94mNEGSN9uxFAKtVBbb17CRISdsaVn+o6s9rdGYyV1/S7/3bc5XK35n7qV19nHP0JVths02yCAGKQzkgV2rwT50NbZnTsFE1Vobmy8NxvvwN+HmNrtlSDE9mxKu3hamNvDvParPyM= ARC-Authentication-Results: i=1; server2.sourceware.org Received: from relay2.suse.de (relay2.suse.de [149.44.160.134]) by smtp-out1.suse.de (Postfix) with ESMTP id 077C42184E for ; Mon, 6 Nov 2023 08:55:59 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=suse.de; s=susede2_rsa; t=1699260959; h=from:from:reply-to:date:date:to:to:cc:mime-version:mime-version: content-type:content-type; bh=DigCcXrNOa12o5gWb2BVkpgb9WHoyeB7nIyGpi8LivU=; b=b8DZlwREDqdDlrr4+j2+Efp3qZhdpmvz4ryXP3MoQo20PTtg7+Ph1on850X/rK+GzKWZ9S HzAEZWP5hMlMVUueGAR5Z9Xro1zyS2QAG30vumN/wplbYS69D2nkGHh0STslxLju7Zxxcq DOxz6Nm1kHlaMmoFoSNIUSGRRgpchF4= DKIM-Signature: v=1; a=ed25519-sha256; c=relaxed/relaxed; d=suse.de; s=susede2_ed25519; t=1699260959; h=from:from:reply-to:date:date:to:to:cc:mime-version:mime-version: content-type:content-type; bh=DigCcXrNOa12o5gWb2BVkpgb9WHoyeB7nIyGpi8LivU=; b=w1KCPqXpit6hpGfku5X0Ur/CzKRc/vYgRgTDNaGtksqkhDgH9tCRODCbrHu7XBxFeycyDd QqVbGRzUq1adYXCw== Received: from wotan.suse.de (wotan.suse.de [10.160.0.1]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by relay2.suse.de (Postfix) with ESMTPS id C38EC2C864 for ; Mon, 6 Nov 2023 08:55:58 +0000 (UTC) Date: Mon, 6 Nov 2023 08:55:58 +0000 (UTC) From: Richard Biener To: gcc-patches@gcc.gnu.org Subject: [PATCH] tree-optimization/112369 - strip_float_extensions and vectors User-Agent: Alpine 2.22 (LSU 394 2020-01-19) MIME-Version: 1.0 X-Spam-Status: No, score=-10.6 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: <20231106085622.5B5C93858439@sourceware.org> X-getmail-retrieved-from-mailbox: INBOX X-GMAIL-THRID: 1781804284241071024 X-GMAIL-MSGID: 1781804284241071024 The following fixes an error in strip_float_extensions when facing vector conversions. Bootstrapped and tested on x86_64-unknown-linux-gnu, pushed. PR tree-optimization/112369 * tree.cc (strip_float_extensions): Use element_precision. * gcc.dg/pr112369.c: New testcase. --- gcc/testsuite/gcc.dg/pr112369.c | 23 +++++++++++++++++++++++ gcc/tree.cc | 2 +- 2 files changed, 24 insertions(+), 1 deletion(-) create mode 100644 gcc/testsuite/gcc.dg/pr112369.c diff --git a/gcc/testsuite/gcc.dg/pr112369.c b/gcc/testsuite/gcc.dg/pr112369.c new file mode 100644 index 00000000000..677e3543f54 --- /dev/null +++ b/gcc/testsuite/gcc.dg/pr112369.c @@ -0,0 +1,23 @@ +/* { dg-do compile } */ +/* { dg-options "-O3" } */ +/* { dg-additional-options "-mavx2" { target avx2 } } */ + +struct GdkRGBA2 { + double a[4]; +}; +struct GdkRGBA3 { + float a[4]; +}; +struct GdkRGBA3 f(struct GdkRGBA2 *color) { + struct GdkRGBA3 t1; + for(int i = 0; i < 4; i++) + t1.a[i] = color->a[i]; + struct GdkRGBA3 t2; + for(int i = 0; i < 4; i++) + { + float tmp = t1.a[i]; + if (__builtin_isnan(tmp)) + t2.a[i] = tmp; + } + return t2; +} diff --git a/gcc/tree.cc b/gcc/tree.cc index cfead156ddf..9c9b057cd88 100644 --- a/gcc/tree.cc +++ b/gcc/tree.cc @@ -12138,7 +12138,7 @@ strip_float_extensions (tree exp) if (DECIMAL_FLOAT_TYPE_P (expt) != DECIMAL_FLOAT_TYPE_P (subt)) return exp; - if (TYPE_PRECISION (subt) > TYPE_PRECISION (expt)) + if (element_precision (subt) > element_precision (expt)) return exp; return strip_float_extensions (sub);