From patchwork Wed Dec 13 08:44:07 2023 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Jakub Jelinek X-Patchwork-Id: 177819 Return-Path: Delivered-To: ouuuleilei@gmail.com Received: by 2002:a05:7300:3b04:b0:fb:cd0c:d3e with SMTP id c4csp7631578dys; Wed, 13 Dec 2023 00:44:40 -0800 (PST) X-Google-Smtp-Source: AGHT+IH19rHKCubi8EPtrs5ODA8/d66bIy7NuOzE2Qqsmw/lbk5teYdPtBnlzV041gD86YJ6EkQm X-Received: by 2002:a05:6214:154c:b0:67a:a721:ec21 with SMTP id t12-20020a056214154c00b0067aa721ec21mr5438851qvw.101.1702457079927; Wed, 13 Dec 2023 00:44:39 -0800 (PST) ARC-Seal: i=2; a=rsa-sha256; t=1702457079; cv=pass; d=google.com; s=arc-20160816; b=NaJeHYXN6BR3sOiMDeCs1BKC04lsBsoYiFNcFA7CSDMZLE68whFAGiysUVnXO64Fzg vtxTZV9HGdiP7hDIDhvovbmnhafcSYCXpKmbmvXlMRGUvEuASKsb4IvlxG0bevnDkDeU ZlJQiNtwFfZ4eOnZgv553FFPkoJVQU57uB/RRfM2WnHWEYzNvfc+/SCxUTQd1aIwpSjt IfmAPbTw1k2bKAJSG3T3nED8YXhDDOW3GqfUrq5HXk6HnrSFjjnBsIczDMxyEWvNxTLQ 5GAemr2RvQa02O8jDRyy1PYDgl46RW9u6/Ws0TGja+oJp+OS5+hQLqbf2dMIha7dPJwN H0Fg== ARC-Message-Signature: i=2; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=errors-to:reply-to:list-subscribe:list-help:list-post:list-archive :list-unsubscribe:list-id:precedence:content-disposition :mime-version:message-id:subject:cc:to:from:date:dkim-signature :arc-filter:dmarc-filter:delivered-to; bh=Jm3dNg1JLlWvdvyzBHj3Wy6WnZ5QHOT9hml4Wq3Y2WQ=; fh=Sumi7UGVVY0GzlCcoxP/I2lPIv2cWAA+7toE9bDwbbU=; b=EDQItFStK6BGqh44ltgkCbz83bSmhbSLVvcBoKZ+G3NF6XHl7SY1iPZvj289ErKfDr QfXZtxqejXFuTCMV4zN7wyUn5i3D3OykBa+6zHOVh+EEwDKDqmgaTsE0jv5+UvB6uUUt uNbXmQ8eC6szaAHDrWF0gmL5QyjMLx34DJ8R2sKXU9yoaWWArCvSP9w+PeN0YXPxLU4j Z/lsHmDT/hfKN+soXFpf0yD6fmYQDHIgNoBqsbE5/3Xz8MGtYQvbwMvdxu74bfmj4Vib 1BPsebF/QL8im0c8rQfc2yWJsnqTrmDNcxgt/XZsrVx76Em35rTyudkewDuvKL7+thFR IzOA== ARC-Authentication-Results: i=2; mx.google.com; dkim=pass header.i=@redhat.com header.s=mimecast20190719 header.b=Q0aHIB5D; 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=redhat.com Received: from server2.sourceware.org (server2.sourceware.org. [8.43.85.97]) by mx.google.com with ESMTPS id qd21-20020ad44815000000b0067a940ca483si1127211qvb.165.2023.12.13.00.44.39 for (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Wed, 13 Dec 2023 00:44:39 -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=@redhat.com header.s=mimecast20190719 header.b=Q0aHIB5D; 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=redhat.com Received: from server2.sourceware.org (localhost [IPv6:::1]) by sourceware.org (Postfix) with ESMTP id CB66F3857007 for ; Wed, 13 Dec 2023 08:44:38 +0000 (GMT) X-Original-To: gcc-patches@gcc.gnu.org Delivered-To: gcc-patches@gcc.gnu.org Received: from us-smtp-delivery-124.mimecast.com (us-smtp-delivery-124.mimecast.com [170.10.133.124]) by sourceware.org (Postfix) with ESMTPS id 1C3E93858D39 for ; Wed, 13 Dec 2023 08:44:15 +0000 (GMT) DMARC-Filter: OpenDMARC Filter v1.4.2 sourceware.org 1C3E93858D39 Authentication-Results: sourceware.org; dmarc=pass (p=none dis=none) header.from=redhat.com Authentication-Results: sourceware.org; spf=pass smtp.mailfrom=redhat.com ARC-Filter: OpenARC Filter v1.0.0 sourceware.org 1C3E93858D39 Authentication-Results: server2.sourceware.org; arc=none smtp.remote-ip=170.10.133.124 ARC-Seal: i=1; a=rsa-sha256; d=sourceware.org; s=key; t=1702457056; cv=none; b=tUBtP7+GpUoq4BcMtkfMUGKXFftop3R+eIMgUJGZvKodmb8dfIrlNPL01YX70OWTdFF/PTXlxtxzHkgcE8U4fF+I4/H+O3gWkF1IywWuJFnNhYQZh2AgL/QN3TCkMWbX0aAJGs5IAH236Y6xBhZ9VPuOslq8GcKMf9ykL/17xoE= ARC-Message-Signature: i=1; a=rsa-sha256; d=sourceware.org; s=key; t=1702457056; c=relaxed/simple; bh=CdTsjf6RF/mkeO0aChT3LTKB5fpyxSO/AFJ/q/VHq+s=; h=DKIM-Signature:Date:From:To:Subject:Message-ID:MIME-Version; b=XEMjO3y+mEUIFPb3NyJNNPu5U+vELjDA02+0P4PB7Qv25raR+WDg3dmN3f27CSZaUTyCF8KSSZUNqwDRn9JCZqyjXHDCvJ1U1ydvcOBYECGFglK55B5syMPGO/MQlBnjdpFviOm8+8Sg8kd/jTDh2mmoK2wxkCV3vYQLWgyGlkc= ARC-Authentication-Results: i=1; server2.sourceware.org DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=redhat.com; s=mimecast20190719; t=1702457054; h=from:from:reply-to:reply-to:subject:subject:date:date: message-id:message-id:to:to:cc:cc:mime-version:mime-version: content-type:content-type; bh=Jm3dNg1JLlWvdvyzBHj3Wy6WnZ5QHOT9hml4Wq3Y2WQ=; b=Q0aHIB5D2WmL3gZS2I/+Gv9jC9FoO/10Tevf+CpYv93Mb4sq7DV4cjPF+j8N8I7e8nNitg B1AlvG+lviQ6rBe76KCqfyHod68VbVBYW7zkzJfc58IQ37S7027YB6JNlkjcCAYup+TpwS 75zbBT4jXZoVNmx29/m1f4+XaLVkaNI= Received: from mimecast-mx02.redhat.com (mx-ext.redhat.com [66.187.233.73]) by relay.mimecast.com with ESMTP with STARTTLS (version=TLSv1.3, cipher=TLS_AES_256_GCM_SHA384) id us-mta-224-hTfDnv8vMKS69feIMJ7swQ-1; Wed, 13 Dec 2023 03:44:11 -0500 X-MC-Unique: hTfDnv8vMKS69feIMJ7swQ-1 Received: from smtp.corp.redhat.com (int-mx04.intmail.prod.int.rdu2.redhat.com [10.11.54.4]) (using TLSv1.3 with cipher TLS_AES_256_GCM_SHA384 (256/256 bits) key-exchange X25519 server-signature RSA-PSS (2048 bits) server-digest SHA256) (No client certificate requested) by mimecast-mx02.redhat.com (Postfix) with ESMTPS id 111803816B6C; Wed, 13 Dec 2023 08:44:11 +0000 (UTC) Received: from tucnak.zalov.cz (unknown [10.39.192.92]) by smtp.corp.redhat.com (Postfix) with ESMTPS id C90F12026D66; Wed, 13 Dec 2023 08:44:10 +0000 (UTC) Received: from tucnak.zalov.cz (localhost [127.0.0.1]) by tucnak.zalov.cz (8.17.1/8.17.1) with ESMTPS id 3BD8i8ot2489595 (version=TLSv1.3 cipher=TLS_AES_256_GCM_SHA384 bits=256 verify=NOT); Wed, 13 Dec 2023 09:44:08 +0100 Received: (from jakub@localhost) by tucnak.zalov.cz (8.17.1/8.17.1/Submit) id 3BD8i7vo2489594; Wed, 13 Dec 2023 09:44:07 +0100 Date: Wed, 13 Dec 2023 09:44:07 +0100 From: Jakub Jelinek To: Uros Bizjak , Hongtao Liu Cc: gcc-patches@gcc.gnu.org Subject: [PATCH] i386: Fix ICE on __builtin_ia32_pabsd128 without lhs [PR112962] Message-ID: MIME-Version: 1.0 X-Scanned-By: MIMEDefang 3.4.1 on 10.11.54.4 X-Mimecast-Spam-Score: 0 X-Mimecast-Originator: redhat.com Content-Disposition: inline X-Spam-Status: No, score=-3.6 required=5.0 tests=BAYES_00, DKIMWL_WL_HIGH, DKIM_SIGNED, DKIM_VALID, DKIM_VALID_AU, DKIM_VALID_EF, KAM_SHORT, RCVD_IN_DNSWL_NONE, RCVD_IN_MSPIKE_H3, RCVD_IN_MSPIKE_WL, SPF_HELO_NONE, SPF_NONE, 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: , Reply-To: Jakub Jelinek Errors-To: gcc-patches-bounces+ouuuleilei=gmail.com@gcc.gnu.org X-getmail-retrieved-from-mailbox: INBOX X-GMAIL-THRID: 1785155635197864420 X-GMAIL-MSGID: 1785155635197864420 Hi! The following patch fixes ICE on the testcase in similar way to how other folded builtins are handled in ix86_gimple_fold_builtin when they don't have a lhs; these builtins are const or pure, so normally DCE would remove them later, but with -O0 that isn't guaranteed to happen, and during expansion if they are marked TREE_SIDE_EFFECTS it might still be attempted to be expanded. This removes them right away during the folding. Initially I wanted to also change all gsi_replace last args in that function to true, but Andrew pointed to PR107209, so I've kept them as is. Bootstrapped/regtested on x86_64-linux and i686-linux, ok for trunk? 2023-12-13 Jakub Jelinek PR target/112962 * config/i386/i386.cc (ix86_gimple_fold_builtin): For shifts and abs without lhs replace with nop. * gcc.target/i386/pr112962.c: New test. Jakub --- gcc/config/i386/i386.cc.jj 2023-12-12 13:06:05.864509295 +0100 +++ gcc/config/i386/i386.cc 2023-12-13 00:02:28.543600557 +0100 @@ -19377,7 +19377,10 @@ ix86_gimple_fold_builtin (gimple_stmt_it do_shift: gcc_assert (n_args >= 2); if (!gimple_call_lhs (stmt)) - break; + { + gsi_replace (gsi, gimple_build_nop (), false); + return true; + } arg0 = gimple_call_arg (stmt, 0); arg1 = gimple_call_arg (stmt, 1); elems = TYPE_VECTOR_SUBPARTS (TREE_TYPE (arg0)); @@ -19523,7 +19526,10 @@ ix86_gimple_fold_builtin (gimple_stmt_it case IX86_BUILTIN_PABSD256_MASK: gcc_assert (n_args >= 1); if (!gimple_call_lhs (stmt)) - break; + { + gsi_replace (gsi, gimple_build_nop (), false); + return true; + } arg0 = gimple_call_arg (stmt, 0); elems = TYPE_VECTOR_SUBPARTS (TREE_TYPE (arg0)); /* For masked ABS, only optimize if the mask is all ones. */ --- gcc/testsuite/gcc.target/i386/pr112962.c.jj 2023-12-12 11:56:56.735917531 +0100 +++ gcc/testsuite/gcc.target/i386/pr112962.c 2023-12-12 11:56:39.406157222 +0100 @@ -0,0 +1,11 @@ +/* PR target/112962 */ +/* { dg-do compile } */ +/* { dg-options "-fexceptions -mssse3" } */ + +typedef int __attribute__((__vector_size__ (16))) V; + +void +foo (void) +{ + __builtin_ia32_pabsd128 ((V) {}); +}