From patchwork Mon Nov 6 13:01:45 2023 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Maxim Blinov X-Patchwork-Id: 162007 Return-Path: Delivered-To: ouuuleilei@gmail.com Received: by 2002:a59:8f47:0:b0:403:3b70:6f57 with SMTP id j7csp2637628vqu; Mon, 6 Nov 2023 05:02:38 -0800 (PST) X-Google-Smtp-Source: AGHT+IFoQxshOWCGyOHRz3Q8E36WXJpPEXMclxIS8udt3YpR/vjxqexktbrn3kTL28OSVrvyjHiP X-Received: by 2002:a05:620a:2a11:b0:778:8b53:cda2 with SMTP id o17-20020a05620a2a1100b007788b53cda2mr34533204qkp.23.1699275758236; Mon, 06 Nov 2023 05:02:38 -0800 (PST) ARC-Seal: i=2; a=rsa-sha256; t=1699275758; cv=pass; d=google.com; s=arc-20160816; b=ZnN1u6qn/QhgdMmMJVdnufyZ9SMBZ6KWvmHD4pa+D+GS8ge3s9zW1iQNXeX7nvF74F uUBYyVsJZiXs0/ClQ+so02a786+wZi1GHWq5l4P/apIejHbG7fjtF+PLXBqn5Y+xMcIR 6xoiD/oHwSx9xE6b/K77o7ikaiXjbV1wU3aNm09n3TQhknPMQkD7ouniM9/s5WBirCB+ r8maZdjrgk5ooBNX6psKh2sg2FU9no1UJgGU45ZkXqIRp/dw5PckGlcH5pSmapyl5sYC uhvP78QxzDWWelx1NwO8V3cRXmyr5lePjz79g/YKwowPVIe7FbHn2IkdQA4CnPKvQfFx eJ4Q== ARC-Message-Signature: i=2; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=errors-to:list-subscribe:list-help:list-post:list-archive :list-unsubscribe:list-id:precedence:content-transfer-encoding :mime-version:message-id:date:subject:cc:to:from:dkim-signature :arc-filter:dmarc-filter:delivered-to; bh=b4EwEO/qfNl+4DXzjDuTgJlQ85LXhTebZuxpFM2FU+8=; fh=OiOsfwWbl0kwsu55Z2B7yVUnnLlL9lQartpi/q5EHLA=; b=HLojjSIKlyc2lOuIRlFn1wcjQ0cFNkIcWpCQLTffxu1FlfmeB0iVIYchdXKuxISNzh nUammuPvJ6xcQp7mKiZSjF2I2xT4qVJ0m0gfEjoXUQoYoOF4D41sKxEdIXoBrAQuL42B VLMrwUKrla+fTnh7jImSepI3HiC2I6sLfVX5i/V3zN540wIDiyvA2Y5XmMTIQHE7+Fy7 t8gm2ZLVNyF1EJ3KdBTslpfssMSq+dsxzqpyZE3OS3Qrd/2oa026U8q3GaUBEaw1lETL pWTUy6KZHCMtLzjw+c7U0WG3eO27o/JOeiTqlKNXg1wY5dZmDMgTY6prdFd12XPlmCl6 pLOw== ARC-Authentication-Results: i=2; mx.google.com; dkim=pass header.i=@gmail.com header.s=20230601 header.b=X4McKOO1; 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=QUARANTINE dis=NONE) header.from=gmail.com Received: from server2.sourceware.org (server2.sourceware.org. [2620:52:3:1:0:246e:9693:128c]) by mx.google.com with ESMTPS id f12-20020a05620a280c00b0077438d488d2si5489666qkp.405.2023.11.06.05.02.38 for (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Mon, 06 Nov 2023 05:02:38 -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=@gmail.com header.s=20230601 header.b=X4McKOO1; 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=QUARANTINE dis=NONE) header.from=gmail.com Received: from server2.sourceware.org (localhost [IPv6:::1]) by sourceware.org (Postfix) with ESMTP id 3EADF3856092 for ; Mon, 6 Nov 2023 13:02:33 +0000 (GMT) X-Original-To: gcc-patches@gcc.gnu.org Delivered-To: gcc-patches@gcc.gnu.org Received: from mail-lj1-x22d.google.com (mail-lj1-x22d.google.com [IPv6:2a00:1450:4864:20::22d]) by sourceware.org (Postfix) with ESMTPS id F3BB23857721 for ; Mon, 6 Nov 2023 13:02:02 +0000 (GMT) DMARC-Filter: OpenDMARC Filter v1.4.2 sourceware.org F3BB23857721 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 F3BB23857721 Authentication-Results: server2.sourceware.org; arc=none smtp.remote-ip=2a00:1450:4864:20::22d ARC-Seal: i=1; a=rsa-sha256; d=sourceware.org; s=key; t=1699275728; cv=none; b=H1ilRiP7ovvQJuOC+q9aSUKoAY0GOG3jyjiV4CwwQqbGqbno7Lca1oexpkxfLeFdPCZUgTu3Q7ZUT0dngKFX/2ONoL88H6k8ZrFiSCijyQP0MXhkGNZsBFF2bw44UQoNHykv8/buHWGRVAwBme1q4zpC7mfvKKs4G2C9ZjhDZNE= ARC-Message-Signature: i=1; a=rsa-sha256; d=sourceware.org; s=key; t=1699275728; c=relaxed/simple; bh=lMwuFUoS6x56QhlYsZVAb8i8PrS5/9tPOzVROVxF3rg=; h=DKIM-Signature:From:To:Subject:Date:Message-Id:MIME-Version; b=cuZ2X/lE9wUFUgeC5tLTLdX1fQ44JgZFONXR4Yx8BGEOWhnQELkNN0YfhNmEY5M9kNz6dlS9XAq/YZvIXdn1JPFU9UeiFHUyMEhFlx3LHytw88+bG9kiaWNw3e2h9p9FR7fo1qKSmoh1JP68u+5rmeTRsklDAQIZv3Dy10+Bw+M= ARC-Authentication-Results: i=1; server2.sourceware.org Received: by mail-lj1-x22d.google.com with SMTP id 38308e7fff4ca-2c514cbbe7eso62879921fa.1 for ; Mon, 06 Nov 2023 05:02:02 -0800 (PST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20230601; t=1699275721; x=1699880521; darn=gcc.gnu.org; h=content-transfer-encoding:mime-version:message-id:date:subject:cc :to:from:from:to:cc:subject:date:message-id:reply-to; bh=b4EwEO/qfNl+4DXzjDuTgJlQ85LXhTebZuxpFM2FU+8=; b=X4McKOO1AXxzv6YrGB4DGl5pxoGtSYXwF3xPDcjsetG9CBJMs58r3CLbEyI3ZtOF8T zIFQUFaMvUn5j+J2YY8SV/7ZvScARoMeSQSh3tgvo1MVaJt9kvCJB5lvtxnd5O8BUXpw lDhMcWKMs9pi7lG08A/Q32qMfB+zCdORvZf8zr2c6e0WHjSKnIOclqdBRN+CdkaV1yyv 6O1faT1NJt7oPWH60z0aA+OO4i2PYiUJBEbwTgWngJU2e1vjeGtpIt+cYiVcikcT+trn GDhShw7iu2VDXvAMarpIFMGikyv0VBD2jXA41JXKpZJCbdPW3RSkKFs0qYFZHsa1txk4 tRZA== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20230601; t=1699275721; x=1699880521; h=content-transfer-encoding:mime-version:message-id:date:subject:cc :to:from:x-gm-message-state:from:to:cc:subject:date:message-id :reply-to; bh=b4EwEO/qfNl+4DXzjDuTgJlQ85LXhTebZuxpFM2FU+8=; b=wgCk4T0+gdYPi07dWLRRLJipIU9Hkhg1enYJ/mPJaHmBsyxlEcbEmCiRyflhiQB+QB SflNJvbVwd99w5XPDWWtOjQSSzsbCmy+go9/aODa+uH1Bgbtv5qJ2YJyHL5/L9THLFG4 5g2ey9utooHdiF5OI+ztIOhx8VNSKiz+ncYAp9QplDjBwvnejUcnM9o7u8sMKwpdRTxg Bi+x3qArDEmiB5TvPc0ECHD7MskITYH5bACbamcoVfrS/0OtrKKRV4m2upxnJH97gL36 n04xNWETl+ZY7k77UwUuZoHJS4WwO3hwONAPw7IlhjNGaZDa/20a/3n+PVEf46aqdzHn fmRA== X-Gm-Message-State: AOJu0YzxnO9d6l3acAZhM2dcazksrgoBVMf8+FA9J3m8dY5OIJzR9ReH DHshLmXGuYJ9FXkb7HzcfSaD4QWIdyY= X-Received: by 2002:a2e:330f:0:b0:2c5:1623:66ab with SMTP id d15-20020a2e330f000000b002c5162366abmr23839200ljc.1.1699275720747; Mon, 06 Nov 2023 05:02:00 -0800 (PST) Received: from prime.. (host-92-19-14-210.as13285.net. [92.19.14.210]) by smtp.gmail.com with ESMTPSA id p12-20020a05600c358c00b003fe61c33df5sm12299819wmq.3.2023.11.06.05.02.00 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Mon, 06 Nov 2023 05:02:00 -0800 (PST) From: Maxim Blinov To: gcc-patches@gcc.gnu.org Cc: juzhe.zhong@rivai.ai, maxim.blinov@imgtec.com, maxim.a.blinov@gmail.com Subject: [PATCH] RISC-V: VECT: Remember to assert any_known_not_updated_vssa Date: Mon, 6 Nov 2023 13:01:45 +0000 Message-Id: <20231106130145.3265828-1-maxim.a.blinov@gmail.com> X-Mailer: git-send-email 2.34.1 MIME-Version: 1.0 X-Spam-Status: No, score=-9.7 required=5.0 tests=BAYES_00, DKIM_SIGNED, DKIM_VALID, DKIM_VALID_AU, DKIM_VALID_EF, FREEMAIL_FROM, GIT_PATCH_0, 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 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 X-getmail-retrieved-from-mailbox: INBOX X-GMAIL-THRID: 1781819777440045064 X-GMAIL-MSGID: 1781819777440045064 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. --- gcc/tree-vect-loop.cc | 5 +++++ 1 file changed, 5 insertions(+) diff --git a/gcc/tree-vect-loop.cc b/gcc/tree-vect-loop.cc index c8df2c88575..53c3a31d2a8 100644 --- a/gcc/tree-vect-loop.cc +++ b/gcc/tree-vect-loop.cc @@ -10155,6 +10155,11 @@ vectorizable_live_operation (vec_info *vinfo, = gimple_build (&stmts, CFN_VEC_EXTRACT, TREE_TYPE (vectype), vec_lhs_phi, last_index); + /* We've expanded SSA at this point, and since VEC_EXTRACT + will generate vops, make sure to tell GCC that we need to + update SSA. */ + loop_vinfo->any_known_not_updated_vssa = true; + /* Convert the extracted vector element to the scalar type. */ new_tree = gimple_convert (&stmts, lhs_type, scalar_res); }