From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: Received: from mail-il1-x12a.google.com (mail-il1-x12a.google.com [IPv6:2607:f8b0:4864:20::12a]) by sourceware.org (Postfix) with ESMTPS id 687D43858D37 for ; Thu, 9 Nov 2023 16:26:39 +0000 (GMT) DMARC-Filter: OpenDMARC Filter v1.4.2 sourceware.org 687D43858D37 Authentication-Results: sourceware.org; dmarc=pass (p=none dis=none) header.from=gmail.com Authentication-Results: sourceware.org; spf=pass smtp.mailfrom=gmail.com ARC-Filter: OpenARC Filter v1.0.0 sourceware.org 687D43858D37 Authentication-Results: server2.sourceware.org; arc=none smtp.remote-ip=2607:f8b0:4864:20::12a ARC-Seal: i=1; a=rsa-sha256; d=sourceware.org; s=key; t=1699547200; cv=none; b=wmTQY6BYJoCyQ2UgUvs6svD6HZb8bbjQsaPgb9d+P9KrUdk5f/5LezxgMXS7xEqZw2VN326H9epXcKaw0FBJp1UkT2APkqbrIyvWuKoZaxx06OXrIr+2WJtdY7mt3CcGmThvj19ju1Nb1cyxbNH00B8yFIHyOs0T7gh1ouM5q3k= ARC-Message-Signature: i=1; a=rsa-sha256; d=sourceware.org; s=key; t=1699547200; c=relaxed/simple; bh=cjA4YwindySqDn8B5MEBO97gbsTrAszj9OeQMZ8Ns9Q=; h=DKIM-Signature:Message-ID:Date:MIME-Version:Subject:To:From; b=vH+eb0U3De1lCBAg2OXQz+xMs7d7i6VGzX+endcuhLlTqaHuKRFxbBl33vhwTmM7eCsenC8V8UmMcUCheG+4087imT4R5tmdPSso0/wLgjvnUQC31yqYr3jnwBn4YiGRgkAt2nmHsG3ETSd8zdrUeiAVvmTuHjfCZa66udUdXAw= ARC-Authentication-Results: i=1; server2.sourceware.org Received: by mail-il1-x12a.google.com with SMTP id e9e14a558f8ab-35932aa21a3so4009615ab.2 for ; Thu, 09 Nov 2023 08:26:39 -0800 (PST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20230601; t=1699547198; x=1700151998; darn=gcc.gnu.org; h=content-transfer-encoding:in-reply-to:from:references:cc:to :content-language:subject:user-agent:mime-version:date:message-id :from:to:cc:subject:date:message-id:reply-to; bh=kS0CIRxOFNqn//UUTr8CptBic798KfehddMfESBxltY=; b=Cf/PCv/Nn0pLatVKjVJ53UTYtxMrfCZekCS9ucbPuY6WmHYJBqiPU0fcDQg64NtdvH qrvpLlcTugXEc3fw6T64tVKWzDvDsJK2m1jdBEYvuTdBWMHNFgcjlDBAEcTW556Xz03P Nd6jqecxzgWSXVeVLW1hjnMzRB3ABhOHqq3tgd1uoW7u9aXZ4Tm15UYYk1NXKK9HIXXI T0uKlk83ODLWjjQRaIXoIAPzQsIGkXcAy6YkOj1q/KBVrxbGje1ENvxUPKArA61fjQc6 ug0q+bdyInZLDJwglX/HAUrrqTJO13tgy1tYKuxCUavRCGZRn8gANWJa4Gt2SLH5fVTX bS9A== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20230601; t=1699547198; x=1700151998; h=content-transfer-encoding:in-reply-to:from:references:cc:to :content-language:subject:user-agent:mime-version:date:message-id :x-gm-message-state:from:to:cc:subject:date:message-id:reply-to; bh=kS0CIRxOFNqn//UUTr8CptBic798KfehddMfESBxltY=; b=bhfjYQRu+EPaQqkvPyScEZHQ6XxEoxqGcsa/3MXRYYepTAhUBShVaxDNXADDGaGOeW HSaIK376gzykCUCyTiqdjXAUcJ/OyqJ1Lab65SkDVPTc43UG41tw6GUGCw880ZQdLXtt sAaPHyBvlphHOM1oQsd9q86ABP6j1V0DmzFSSgjxGqQYt1ZaRzBdKbgXC68U353Mtth2 fnzabLf8tg11f/d9WuMFTz4k7xu2H27fLLKV1wlhboqZRu4yd7uZQ2NkrNzlv6xMrBPP T/qZWtfVWvWyQG4s6GVq6yJm2+0Y1/jp+iKnVUwMZ7c9W2+E59n3eMcY2lpr9/jfCm/s ubJg== X-Gm-Message-State: AOJu0YxNYqn2iOQHpAKjsAHUgicglM6+ozPHuOGhisvP2rQu8WBBKHND fioS22i3qW/Whk5U2p2m80Q= X-Google-Smtp-Source: AGHT+IEBxTO7VYNKJDJvZyWtgkZZRGxW/ghWzxWsUfp0pGMS/exAat8kBzGfAtAe3Yo6YZImBjjXLw== X-Received: by 2002:a05:6e02:194e:b0:359:cc3e:cad with SMTP id x14-20020a056e02194e00b00359cc3e0cadmr5799266ilu.5.1699547198317; Thu, 09 Nov 2023 08:26:38 -0800 (PST) Received: from [172.31.0.109] ([136.36.130.248]) by smtp.gmail.com with ESMTPSA id i10-20020a056e020d8a00b003590b126f15sm4443523ilj.72.2023.11.09.08.26.36 (version=TLS1_3 cipher=TLS_AES_128_GCM_SHA256 bits=128/128); Thu, 09 Nov 2023 08:26:37 -0800 (PST) Message-ID: <49b16edf-c2d8-4ac8-a7f4-8261f52041d6@gmail.com> Date: Thu, 9 Nov 2023 09:26:35 -0700 MIME-Version: 1.0 User-Agent: Mozilla Thunderbird Subject: Re: [PATCH] RISC-V: VECT: Remember to assert any_known_not_updated_vssa Content-Language: en-US To: Maxim Blinov , gcc-patches@gcc.gnu.org Cc: juzhe.zhong@rivai.ai, maxim.blinov@imgtec.com References: <20231106130145.3265828-1-maxim.a.blinov@gmail.com> From: Jeff Law In-Reply-To: <20231106130145.3265828-1-maxim.a.blinov@gmail.com> Content-Type: text/plain; charset=UTF-8; format=flowed Content-Transfer-Encoding: 7bit X-Spam-Status: No, score=-2.3 required=5.0 tests=BAYES_00,DKIM_SIGNED,DKIM_VALID,DKIM_VALID_AU,DKIM_VALID_EF,FREEMAIL_FROM,KAM_SHORT,RCVD_IN_DNSWL_NONE,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: On 11/6/23 06:01, Maxim Blinov wrote: > From: Maxim Blinov > > This patch is based on and intended for the vendors/riscv/gcc-13-with-riscv-opts branch - please apply if looks OK. > > Fixes the following ICEs that I'm seeing: > > FAIL: gcc.dg/vect/O3-pr49087.c (internal compiler error: in vect_transform_loops, at tree-vectorizer.cc:1032) > FAIL: gcc.dg/vect/no-scevccp-pr86725-1.c (internal compiler error: in vect_transform_loops, at tree-vectorizer.cc:1032) > FAIL: gcc.dg/vect/no-scevccp-pr86725-2.c (internal compiler error: in vect_transform_loops, at tree-vectorizer.cc:1032) > FAIL: gcc.dg/vect/no-scevccp-pr86725-3.c (internal compiler error: in vect_transform_loops, at tree-vectorizer.cc:1032) > FAIL: gcc.dg/vect/no-scevccp-pr86725-4.c (internal compiler error: in vect_transform_loops, at tree-vectorizer.cc:1032) > FAIL: gcc.dg/vect/pr94443.c (internal compiler error: in vect_transform_loops, at tree-vectorizer.cc:1032) > FAIL: gcc.dg/vect/pr94443.c -flto -ffat-lto-objects (internal compiler error: in vect_transform_loops, at tree-vectorizer.cc:1032) > FAIL: gcc.dg/vect/slp-50.c (internal compiler error: in vect_transform_loops, at tree-vectorizer.cc:1032) > FAIL: gcc.dg/vect/slp-50.c -flto -ffat-lto-objects (internal compiler error: in vect_transform_loops, at tree-vectorizer.cc:1032) > FAIL: gcc.dg/vect/vect-cond-13.c (internal compiler error: in vect_transform_loops, at tree-vectorizer.cc:1032) > FAIL: gcc.dg/vect/vect-cond-13.c -flto -ffat-lto-objects (internal compiler error: in vect_transform_loops, at tree-vectorizer.cc:1032) > FAIL: gcc.dg/vect/vect-live-6.c (internal compiler error: in vect_transform_loops, at tree-vectorizer.cc:1032) > FAIL: gcc.dg/vect/vect-live-6.c -flto -ffat-lto-objects (internal compiler error: in vect_transform_loops, at tree-vectorizer.cc:1032) > FAIL: gcc.target/riscv/rvv/autovec/partial/live-1.c (internal compiler error: in vect_transform_loops, at tree-vectorizer.cc:1032) > FAIL: gcc.target/riscv/rvv/autovec/partial/live-2.c (internal compiler error: in vect_transform_loops, at tree-vectorizer.cc:1032) > > -- >8 -- > > When we create a VEC_EXPAND gimple stmt: > > /* SCALAR_RES = VEC_EXTRACT . */ > tree scalar_res > = gimple_build (&stmts, CFN_VEC_EXTRACT, TREE_TYPE (vectype), > vec_lhs_phi, last_index); > > Under the hood we are really just creating a GIMPLE_CALL stmt. Later > on, when we `gsi_insert_seq_before` our stmts: > > if (stmts) > { > gimple_stmt_iterator exit_gsi = gsi_after_labels (exit_bb); > gsi_insert_seq_before (&exit_gsi, stmts, GSI_SAME_STMT); > > We eventually run into tree-ssa-operands.cc:1147: > > operands_scanner (fn, stmt).build_ssa_operands (); > > Since VEC_EXPAND is *not* marked with ECF_NOVOPS, ECF_CONST, or > ECF_PURE flags in internal-fn.def, when > `operand_scanner::parse_ssa_operands` comes across our > VEC_EXTRACT-type GIMPLE_CALL, it generates a `gimple_vop()` artificial > variable. > > `operand_scanner::finalize_ssa_defs` then picks this up, so our final > stmt goes from > > _73 = .VEC_EXTRACT (vect_last_9.56_71, _72); > > to > > # .MEM = VDEF <> > _73 = .VEC_EXTRACT (vect_last_9.56_71, _72); > > But more importantly it marks us as `ssa_renaming_needed`, in > tree-ssa-operands.cc:420: > > /* If we have a non-SSA_NAME VDEF, mark it for renaming. */ > if (gimple_vdef (stmt) > && TREE_CODE (gimple_vdef (stmt)) != SSA_NAME) > { > fn->gimple_df->rename_vops = 1; > fn->gimple_df->ssa_renaming_needed = 1; > } > > This then proceeds to crash the compiler when we are about to leave > `vect_transform_loops`: > > if (need_ssa_update_p (cfun)) > { > gcc_assert (loop_vinfo->any_known_not_updated_vssa); > fun->gimple_df->ssa_renaming_needed = false; > todo |= TODO_update_ssa_only_virtuals; > } > > Since, > > - `need_ssa_update_p (cfun)` is true (it was set when we generated a > memory vdef) > - `loop_vinfo->any_known_not_updated_vssa` is false > > As the code currently stands, creating a gimple stmt containing a > VEC_EXTRACT should always generate a memory vdef, therefore we should > remember to mark `loop_vinfo->any_known_not_updated_vssa` afterwards. > > gcc/ChangeLog: > > * tree-vect-loop.cc (vectorizable_live_operation): Remember to > assert loop_vinfo->any_known_not_updated_vssa if we are inserting > a call to VEC_EXPAND. Just to avoid any doubt -- with the internal-fn.def patch I cherry picked earlier this week to the branch, this is no longer needed, right? jeff