From patchwork Wed Apr 5 08:58:08 2023 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Jakub Jelinek X-Patchwork-Id: 79512 Return-Path: Delivered-To: ouuuleilei@gmail.com Received: by 2002:a59:b0ea:0:b0:3b6:4342:cba0 with SMTP id b10csp152337vqo; Wed, 5 Apr 2023 01:59:01 -0700 (PDT) X-Google-Smtp-Source: AKy350bx9EMTQv9cjiIvFCJKL8PLxCJN72YTKbbgiVjz8RLcRrg1bzkEcDGXIljsmJAbGFJHnVRN X-Received: by 2002:a17:906:9717:b0:924:d90a:6f97 with SMTP id k23-20020a170906971700b00924d90a6f97mr2088720ejx.13.1680685141498; Wed, 05 Apr 2023 01:59:01 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1680685141; cv=none; d=google.com; s=arc-20160816; b=QYjCqSfKmhKmmKMW66TYeFkPMqPFP2OZ7Fk8X3cIrnrNAT1+PVtWXzXO2xwwojprXy l9hSCSq4FfYd8n6GXVFcsZ15mV2nD9ru/OJFM2orbibld27981JToIJSgiDY8aA1RtLj E7FQddGc7YqWcsKXHGgI5g0GnXtPKKASUsb7ByJ7MwDr/302ld2O7I/eoRDKVGcCAtff aggEya5QVT7kMPRMu4a0JHRHNuDwHmayVfO3zSKZ/65oOnxco3DyqzS3sjkoS3MkR2ON 55IW/WS5V8TOz+Cf9z0q/qG82qi6iYNRI4mnAYZX9kzA106+bno8ISLsBYsMu6nmKxjV aEpw== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=sender:errors-to:reply-to:from:list-subscribe:list-help:list-post :list-archive:list-unsubscribe:list-id:precedence :content-disposition:mime-version:message-id:subject:cc:to:date :dmarc-filter:delivered-to:dkim-signature:dkim-filter; bh=Unpzjn1naFGmXFW1ql6eic3jLX7XECtxULKeLP0l3mY=; b=QlZAuc/s2hlUOh+K6nOHU3fjxK1M1HT6f3RxOCB6Rr6IsSfjBpK9KYWHKWzeaAacJj ZCOVMX8d0aX2yA7/OR1MgctL9I+12GcFN5Ns/ElRALdo91/NDnqIX+189C3Q6Cxr53m6 ItVPxq5hh6ZugrRLWWW42S8mrKQSgFKGg4KhayTsqLv+mgUQurKwiGOjDPbiEnWiypeG W5QeGk29VlSadxKa6it4FjFkxeZQ2ca12q7vxyQawc/2j76GfhRU3ggbQz+16/Q2qywz 7b3EEiePjjb51L9OG+t6DmWqkbLPydB9iwCalcOR181whZjs08PtKbTdbLO0VRhpEQyt i93A== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@gcc.gnu.org header.s=default header.b=x7F9GtnK; 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=gnu.org Received: from sourceware.org (server2.sourceware.org. [8.43.85.97]) by mx.google.com with ESMTPS id z18-20020a170906271200b0092be82bf914si2723161ejc.863.2023.04.05.01.59.01 for (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Wed, 05 Apr 2023 01:59:01 -0700 (PDT) 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=@gcc.gnu.org header.s=default header.b=x7F9GtnK; 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=gnu.org Received: from server2.sourceware.org (localhost [IPv6:::1]) by sourceware.org (Postfix) with ESMTP id 500F93858C2C for ; Wed, 5 Apr 2023 08:59:00 +0000 (GMT) DKIM-Filter: OpenDKIM Filter v2.11.0 sourceware.org 500F93858C2C DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gcc.gnu.org; s=default; t=1680685140; bh=Unpzjn1naFGmXFW1ql6eic3jLX7XECtxULKeLP0l3mY=; h=Date:To:Cc:Subject:List-Id:List-Unsubscribe:List-Archive: List-Post:List-Help:List-Subscribe:From:Reply-To:From; b=x7F9GtnKtXqw3y41Ovj79Cxq9mFpOf2nP7AYe4kaNY+eZFTzh1NydHhJ2oBEMjQyw RYLEnyHCDJlcFs/tG1Gg6qihUNOPBgEZaOeqbOpKX1haqkhjtVfmuyQqkL/wL1tXtD 5rIdRhIpAc8lv3EL+bw+94r8M4q9TJeH1NzvXy34= 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.129.124]) by sourceware.org (Postfix) with ESMTPS id 215153858CDA for ; Wed, 5 Apr 2023 08:58:17 +0000 (GMT) DMARC-Filter: OpenDMARC Filter v1.4.2 sourceware.org 215153858CDA Received: from mimecast-mx02.redhat.com (mimecast-mx02.redhat.com [66.187.233.88]) by relay.mimecast.com with ESMTP with STARTTLS (version=TLSv1.2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id us-mta-387-9JWj-PZsMOSWGEbx4NTjcA-1; Wed, 05 Apr 2023 04:58:13 -0400 X-MC-Unique: 9JWj-PZsMOSWGEbx4NTjcA-1 Received: from smtp.corp.redhat.com (int-mx10.intmail.prod.int.rdu2.redhat.com [10.11.54.10]) (using TLSv1.2 with cipher AECDH-AES256-SHA (256/256 bits)) (No client certificate requested) by mimecast-mx02.redhat.com (Postfix) with ESMTPS id 1D79988B7A0; Wed, 5 Apr 2023 08:58:13 +0000 (UTC) Received: from tucnak.zalov.cz (unknown [10.39.192.16]) by smtp.corp.redhat.com (Postfix) with ESMTPS id CF1DD400F4F; Wed, 5 Apr 2023 08:58:12 +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 3358wA3p3972231 (version=TLSv1.3 cipher=TLS_AES_256_GCM_SHA384 bits=256 verify=NOT); Wed, 5 Apr 2023 10:58:10 +0200 Received: (from jakub@localhost) by tucnak.zalov.cz (8.17.1/8.17.1/Submit) id 3358w9PN3972230; Wed, 5 Apr 2023 10:58:09 +0200 Date: Wed, 5 Apr 2023 10:58:08 +0200 To: Richard Biener , Jeff Law Cc: gcc-patches@gcc.gnu.org Subject: [PATCH] tree-vect-generic: Fix up ICE with SSA_NAME_OCCURS_IN_ABNORMAL_PHI [PR109392] Message-ID: MIME-Version: 1.0 X-Scanned-By: MIMEDefang 3.1 on 10.11.54.10 X-Mimecast-Spam-Score: 0 X-Mimecast-Originator: redhat.com Content-Disposition: inline X-Spam-Status: No, score=-3.3 required=5.0 tests=BAYES_00, DKIMWL_WL_HIGH, DKIM_SIGNED, DKIM_VALID, DKIM_VALID_AU, DKIM_VALID_EF, RCVD_IN_DNSWL_NONE, RCVD_IN_MSPIKE_H2, SPF_HELO_NONE, SPF_NONE, TXREP 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.29 Precedence: list List-Id: Gcc-patches mailing list List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , X-Patchwork-Original-From: Jakub Jelinek via Gcc-patches From: Jakub Jelinek Reply-To: Jakub Jelinek Errors-To: gcc-patches-bounces+ouuuleilei=gmail.com@gcc.gnu.org Sender: "Gcc-patches" X-getmail-retrieved-from-mailbox: =?utf-8?q?INBOX?= X-GMAIL-THRID: =?utf-8?q?1762326102923785005?= X-GMAIL-MSGID: =?utf-8?q?1762326102923785005?= Hi! tree_vect_extract uses gimple-fold/match.pd to attempt to simplify the BIT_FIELD_REF immediately. Unfortunately, maybe_push_res_to_seq has: /* Play safe and do not allow abnormals to be mentioned in newly created statements. */ for (unsigned int i = 0; i < num_ops; ++i) if (TREE_CODE (ops[i]) == SSA_NAME && SSA_NAME_OCCURS_IN_ABNORMAL_PHI (ops[i])) return NULL_TREE; if (num_ops > 0 && COMPARISON_CLASS_P (ops[0])) for (unsigned int i = 0; i < 2; ++i) if (TREE_CODE (TREE_OPERAND (ops[0], i)) == SSA_NAME && SSA_NAME_OCCURS_IN_ABNORMAL_PHI (TREE_OPERAND (ops[0], i))) return NULL_TREE; and so can fail in presence of SSA_NAME_OCCURS_IN_ABNORMAL_PHI SSA_NAMEs, where we then trigger the assert that maybe_push_res_to_seq doesn't return NULL. The above is perfectly reasonable when trying to actually simplify something that has been already created and let us just punt, but in the tree_vect_extract case we have to build something always. The following patch fixes it by building the BIT_FIELD_REF manually in that case if the build+simplification failed. Bootstrapped/regtested on x86_64-linux and i686-linux, ok for trunk? 2023-04-05 Jakub Jelinek PR tree-optimization/109392 * tree-vect-generic.cc (tree_vec_extract): If maybe_push_res_to_seq fails, build BIT_FIELD_REF insn without trying to simplify it. * gcc.dg/pr109392.c: New test. Jakub --- gcc/tree-vect-generic.cc.jj 2023-03-23 10:02:18.997935620 +0100 +++ gcc/tree-vect-generic.cc 2023-04-04 14:28:32.977729134 +0200 @@ -174,7 +174,16 @@ tree_vec_extract (gimple_stmt_iterator * opr.resimplify (NULL, follow_all_ssa_edges); gimple_seq stmts = NULL; tree res = maybe_push_res_to_seq (&opr, &stmts); - gcc_assert (res); + if (!res) + { + /* This can happen if SSA_NAME_OCCURS_IN_ABNORMAL_PHI are + used. Build BIT_FIELD_REF manually otherwise. */ + t = build3 (BIT_FIELD_REF, type, t, bitsize, bitpos); + res = make_ssa_name (type); + gimple *g = gimple_build_assign (res, t); + gsi_insert_before (gsi, g, GSI_SAME_STMT); + return res; + } gsi_insert_seq_before (gsi, stmts, GSI_SAME_STMT); return res; } --- gcc/testsuite/gcc.dg/pr109392.c.jj 2023-04-04 14:36:03.096109943 +0200 +++ gcc/testsuite/gcc.dg/pr109392.c 2023-04-04 14:35:39.784452751 +0200 @@ -0,0 +1,15 @@ +/* PR tree-optimization/109392 */ +/* { dg-do compile } */ +/* { dg-options "-O2 -Wno-psabi" } */ + +typedef short __attribute__ ((__vector_size__ (64))) V; +V v, w; +void bar (void) __attribute__((returns_twice)); + +V +foo (V a, V b) +{ + bar (); + b &= v < b; + return (V) { foo (b, w)[3], (V) {}[3] }; +}