From patchwork Thu Jul 6 06:51:35 2023 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: "juzhe.zhong@rivai.ai" X-Patchwork-Id: 116526 Return-Path: Delivered-To: ouuuleilei@gmail.com Received: by 2002:a59:9f45:0:b0:3ea:f831:8777 with SMTP id v5csp2359150vqx; Wed, 5 Jul 2023 23:52:11 -0700 (PDT) X-Google-Smtp-Source: APBJJlET9rD3HZeD2sUxqSMv2QBbLZfmzDL3pIQPtEE9ayx/BXBE9s3nwXuoAL1U63pCacYoEtCP X-Received: by 2002:a17:907:970d:b0:992:b66e:72f9 with SMTP id jg13-20020a170907970d00b00992b66e72f9mr824065ejc.69.1688626331575; Wed, 05 Jul 2023 23:52:11 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1688626331; cv=none; d=google.com; s=arc-20160816; b=Qzuv8mdrYZQ+p15IZ/CfpUauQeyja7SBM1HiYNYyhVg0FbKoYYgZtv+QOabRLklTn6 3nWXM/5uM4eNrIlYmD9aGV10GpH+kRR9uT05X4nksbKJACfnF8VZsbbDMTl43FR0w7EC qwi4ob2mg+aDZsXq7yM7rLSN31HP9tAA9EPm1aNBUgSnLfF6NPOjJOPcN4YBFcRgw1nX CfR7x4dGs4yWxSAs8TsEXAgQomh8Pbkvb0sEVA+wicYABS4gAWOEE6ZwHQNIoGuHoTot SuHk7CJ6JG9Tf4mvZfg7mb/jb1hjNf5PSmGKnNxlRCEC4Q5OYSw1XrB7pYwmVKrh/JtJ VbJA== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=sender:errors-to:list-subscribe:list-help:list-post:list-archive :list-unsubscribe:list-id:precedence:feedback-id :content-transfer-encoding:mime-version:message-id:date:subject:cc :to:from:dmarc-filter:delivered-to; bh=9GjMAy5npw+JWbTpL2tjGBCOHiSzZSsEerBtFWjVRms=; fh=CHbn33ss3MXGFqXGZpS89+qfBQv2oFkoJCJQmHw6RIo=; b=LarGjneBO/IaiZvUZqneM6pzUikgyAlaZQnLwza7bmJ/UmWWxk47o2ioAw+jb/3WZl OOgpeFRDTle8g1AtSjd6IShI6zZdx4Hk/PbITL96QHOpgqTlTtRa2OvP7tVrAF9ic/mI uwjaRawnzoQD3xMzwKd+GVL0/khzOdJ9KisILhoeJR2DHI4GmquVm1VCaUFCJ5HMzoXD M7u1cLrstEqr2pnzh//0lwEekpPYCDAQXsYnxiWrqt/EwLxmVKClzDtkyiI1kDySWQOb wD7pDPe/qz0578ykVROMVTM9uhpLj7yAp5Qtc6zcmFS3Cgo76iBrUbozhuqB9Pc4n1p9 IeUg== ARC-Authentication-Results: i=1; mx.google.com; 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" Received: from server2.sourceware.org (server2.sourceware.org. [2620:52:3:1:0:246e:9693:128c]) by mx.google.com with ESMTPS id sd10-20020a170906ce2a00b009873cbdd6cfsi385909ejb.706.2023.07.05.23.52.11 for (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Wed, 05 Jul 2023 23:52:11 -0700 (PDT) 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; 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" Received: from server2.sourceware.org (localhost [IPv6:::1]) by sourceware.org (Postfix) with ESMTP id 5027338555AF for ; Thu, 6 Jul 2023 06:52:07 +0000 (GMT) X-Original-To: gcc-patches@gcc.gnu.org Delivered-To: gcc-patches@gcc.gnu.org Received: from smtpbguseast1.qq.com (smtpbguseast1.qq.com [54.204.34.129]) by sourceware.org (Postfix) with ESMTPS id 0B81C385771F for ; Thu, 6 Jul 2023 06:51:42 +0000 (GMT) DMARC-Filter: OpenDMARC Filter v1.4.2 sourceware.org 0B81C385771F Authentication-Results: sourceware.org; dmarc=none (p=none dis=none) header.from=rivai.ai Authentication-Results: sourceware.org; spf=pass smtp.mailfrom=rivai.ai X-QQ-mid: bizesmtp72t1688626298t7e1fg4k Received: from rios-cad5.localdomain ( [58.60.1.11]) by bizesmtp.qq.com (ESMTP) with id ; Thu, 06 Jul 2023 14:51:36 +0800 (CST) X-QQ-SSF: 01400000000000G0T000000A0000000 X-QQ-FEAT: CR3LFp2JE4nrKbfE4lrquYFli9inl4HU2mVC5CzELm4pTB8A60RfVTk0J6X23 pmfBWqm5wQ6Sd8TXb3FmojnQ3EKX6EXZiJu+YPwEH+N8lGSMrhD2P8Y4zbfX3uVDMTpE3An ciHSJ0mI17rugESFEsnHTmRQYh+w6FPOJLjZP9HYcFjbhsHtcPdqJQuybsYQ2ZKVg+0lTuJ vXY7Tq4MKpgKyQ6bQnHUDs4T8DwQ/c12aBDJupBxjFYgXcyx4QRd/Mvqq5Hk7Y8YugUiu1F W6H8VdT7jRpcbjYkLWG6p2/1dTkx8wpezUKWNZFUX+PvNv/n3ISiG+6y6hML68ByurqN2dg MRpG7TTsBqPkEqFpwHWhZuJ9Vk8/WdpMT3ZSV3gO3GkA8wN3Yvwoe9j2D1VwzXMjuNvQ75P X-QQ-GoodBg: 2 X-BIZMAIL-ID: 9980193252672963884 From: juzhe.zhong@rivai.ai To: gcc-patches@gcc.gnu.org Cc: richard.sandiford@arm.com, rguenther@suse.de, Ju-Zhe Zhong Subject: [PATCH V2] VECT: Fix ICE of variable stride on strieded load/store with SELECT_VL loop control. Date: Thu, 6 Jul 2023 14:51:35 +0800 Message-Id: <20230706065135.3448078-1-juzhe.zhong@rivai.ai> X-Mailer: git-send-email 2.36.3 MIME-Version: 1.0 X-QQ-SENDSIZE: 520 Feedback-ID: bizesmtp:rivai.ai:qybglogicsvrgz:qybglogicsvrgz7a-one-0 X-Spam-Status: No, score=-12.2 required=5.0 tests=BAYES_00, GIT_PATCH_0, KAM_DMARC_STATUS, RCVD_IN_DNSWL_NONE, RCVD_IN_MSPIKE_H4, RCVD_IN_MSPIKE_WL, SPF_HELO_PASS, 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.29 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 Sender: "Gcc-patches" X-getmail-retrieved-from-mailbox: =?utf-8?q?INBOX?= X-GMAIL-THRID: =?utf-8?q?1770653043800043972?= X-GMAIL-MSGID: =?utf-8?q?1770653043800043972?= From: Ju-Zhe Zhong Hi, Richi. Sorry for making mistake on LEN_MASK_GATHER_LOAD/LEN_MASK_SCATTER_STORE with SELECT_VL loop control. Consider this following case: #define TEST_LOOP(DATA_TYPE, BITS) \ void __attribute__ ((noinline, noclone)) \ f_##DATA_TYPE##_##BITS (DATA_TYPE *restrict dest, DATA_TYPE *restrict src, \ INDEX##BITS stride, INDEX##BITS n) \ { \ for (INDEX##BITS i = 0; i < n; ++i) \ dest[i] += src[i * stride]; \ } When "stride" is a constant, current flow works fine. However, when "stride" is a variable. It causes an ICE: # vectp_src.67_85 = PHI ... _96 = .SELECT_VL (ivtmp_94, 4); ... ivtmp_78 = ((sizetype) _39 * (sizetype) _96) * 4; vect__11.69_87 = .LEN_MASK_GATHER_LOAD (vectp_src.67_85, _84, 4, { 0, 0, 0, 0 }, { -1, -1, -1, -1 }, _96, 0); ... vectp_src.67_86 = vectp_src.67_85 + ivtmp_78; Becase the IR: ivtmp_78 = ((sizetype) _39 * (sizetype) _96) * 4; Instead, I split the IR into: step_stride = _39 step = step_stride * 4 ivtmp_78 = step * _96 Thanks. gcc/ChangeLog: * tree-vect-stmts.cc (vect_get_strided_load_store_ops): Fix ICE. --- gcc/tree-vect-stmts.cc | 6 ++---- 1 file changed, 2 insertions(+), 4 deletions(-) diff --git a/gcc/tree-vect-stmts.cc b/gcc/tree-vect-stmts.cc index c10a4be60eb..10e71178ce7 100644 --- a/gcc/tree-vect-stmts.cc +++ b/gcc/tree-vect-stmts.cc @@ -3176,10 +3176,8 @@ vect_get_strided_load_store_ops (stmt_vec_info stmt_info, = fold_build2 (MULT_EXPR, sizetype, fold_convert (sizetype, unshare_expr (DR_STEP (dr))), loop_len); - tree bump = make_temp_ssa_name (sizetype, NULL, "ivtmp"); - gassign *assign = gimple_build_assign (bump, tmp); - gsi_insert_before (gsi, assign, GSI_SAME_STMT); - *dataref_bump = bump; + *dataref_bump = force_gimple_operand_gsi (gsi, tmp, true, NULL_TREE, true, + GSI_SAME_STMT); } else {