From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: Received: from mail-ej1-x62b.google.com (mail-ej1-x62b.google.com [IPv6:2a00:1450:4864:20::62b]) by sourceware.org (Postfix) with ESMTPS id 0F6B93858CDA for ; Fri, 7 Oct 2022 12:25:09 +0000 (GMT) DMARC-Filter: OpenDMARC Filter v1.4.1 sourceware.org 0F6B93858CDA Authentication-Results: sourceware.org; dmarc=pass (p=none dis=none) header.from=gmail.com Authentication-Results: sourceware.org; spf=pass smtp.mailfrom=gmail.com Received: by mail-ej1-x62b.google.com with SMTP id d26so3856384eje.10 for ; Fri, 07 Oct 2022 05:25:09 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20210112; h=cc:to:subject:message-id:date:from:in-reply-to:references :mime-version:from:to:cc:subject:date:message-id:reply-to; bh=2nhZCowRQUm69yeoxjGYtmG1MG2u8A3PN+iuBYcVl1o=; b=ffwQU8ZjeIfsS9ByHwUm5K4oOMGtV9yIs8l65NIzkjOMZTXjpuATJkeiEc4wUfIzMN tMl8Scr6H7pRsjp1CWElQUFq7/r0/qcmndtfsDZYbRaQBooLrLWLiaT2bRx9bLEjInW4 +3NYKrl+O9YF0P3qUpgv6KroAyJ9FqT8jzsRCKtm49trm3Tj/YXBk70FiePHEOOoaHQ1 +DXDx7yD6DVgVKL9vodE6hXusuCUhJJ1KLCD70hi6wVxIjhH5wKXvDcuP9MNmPmKyRO+ fx5w2/+S/r5ZHuIxS14NGprn8zd3lSbsAAhJ8JqU5lpHX2QE0kWX09WEy1bPvSP+1kfT bG0Q== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20210112; h=cc:to:subject:message-id:date:from:in-reply-to:references :mime-version:x-gm-message-state:from:to:cc:subject:date:message-id :reply-to; bh=2nhZCowRQUm69yeoxjGYtmG1MG2u8A3PN+iuBYcVl1o=; b=XOFslPm/A6xg7tDdeTCnVKT5x1hutPcI50LL3UmhuB66Ntx+//WcxsutYQPHVDyi4v UhaU/u9k/yHWX2RC4ktOW8wh4OnOGY/Jjryt+yuLjRjPXvuKRlMa04SMccb0ZDiWnrEZ iRH9BA9e75P5TIGKQsRhZB+ptXfbsglDfaG8L1TBqdGhh8uu/IYGGV+x3SNl0Vrlvkoj XpmRmmlpmaWSVNwn/cJ8UierRzj9qZhhQMcY/54pGj17/VG6OEcmzuyKGIdhY1mi9434 dV3pIILwbE3i5Eu1/jcdM2DLhFrMAluY7TidKo5o62fKY6iWPuA9osrAnLw+OeG7Mr5r Yuxw== X-Gm-Message-State: ACrzQf0tcFNAfokFwG9SbOeBe/5GphbGAB0ZUziz7IkxAWz0g3Eb99W2 o4tuKUmWx8z6g86xazvmFaCuSeF/vQxNePNsUrk= X-Google-Smtp-Source: AMsMyM7HmqYAUL1EXOOcpbSv0HxU0BR+mQHx+CwYbmH3MKXUXS1HFHUFeCpJOC5ndEtTgnMBKqQWG8PFqaAZpNsxoJk= X-Received: by 2002:a17:906:5d0f:b0:78d:1bed:890f with SMTP id g15-20020a1709065d0f00b0078d1bed890fmr3895360ejt.594.1665145507724; Fri, 07 Oct 2022 05:25:07 -0700 (PDT) MIME-Version: 1.0 References: <20220930080033.70151-1-juzhe.zhong@rivai.ai> In-Reply-To: From: Richard Biener Date: Fri, 7 Oct 2022 14:24:55 +0200 Message-ID: Subject: Re: [PATCH] Add first-order recurrence autovectorization To: juzhe.zhong@rivai.ai Cc: gcc-patches@gcc.gnu.org, richard.sandiford@arm.com Content-Type: text/plain; charset="UTF-8" X-Spam-Status: No, score=-2.2 required=5.0 tests=BAYES_00,DKIM_SIGNED,DKIM_VALID,DKIM_VALID_AU,DKIM_VALID_EF,FREEMAIL_FROM,RCVD_IN_DNSWL_NONE,SPF_HELO_NONE,SPF_PASS,TXREP,WEIRD_PORT 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 Thu, Oct 6, 2022 at 3:07 PM Richard Biener wrote: > > On Thu, Oct 6, 2022 at 2:13 PM Richard Biener > wrote: > > > > On Fri, Sep 30, 2022 at 10:00 AM wrote: > > > > > > From: Ju-Zhe Zhong > > > > > > Hi, After fixing previous ICE. > > > I add full implementation (insert permutation to get correct result.) > > > > > > The gimple IR is correct now I think: > > > # t_21 = PHI <_4(6), t_12(9)> > > > # i_22 = PHI > > > # vectp_a.6_26 = PHI > > > # vect_vec_recur_.9_9 = PHI > > > # vectp_b.11_7 = PHI > > > # curr_cnt_36 = PHI > > > # loop_len_20 = PHI > > > _38 = .WHILE_LEN (loop_len_20, 32, POLY_INT_CST [4, 4]); > > > while_len_37 = _38; > > > _1 = (long unsigned int) i_22; > > > _2 = _1 * 4; > > > _3 = a_14(D) + _2; > > > vect__4.8_19 = .LEN_LOAD (vectp_a.6_26, 32B, loop_len_20, 0); > > > _4 = *_3; > > > _5 = b_15(D) + _2; > > > vect_vec_recur_.9_9 = VEC_PERM_EXPR ; > > > > > > But I encounter another ICE: > > > 0x169e0e7 process_bb > > > ../../../riscv-gcc/gcc/tree-ssa-sccvn.cc:7498 > > > 0x16a09af do_rpo_vn(function*, edge_def*, bitmap_head*, bool, bool, vn_lookup_kind) > > > ../../../riscv-gcc/gcc/tree-ssa-sccvn.cc:8109 > > > 0x16a0fe7 do_rpo_vn(function*, edge_def*, bitmap_head*) > > > ../../../riscv-gcc/gcc/tree-ssa-sccvn.cc:8205 > > > 0x179b7db execute > > > ../../../riscv-gcc/gcc/tree-vectorizer.cc:1365 > > > > > > Could you help me with this? After fixing this ICE, I think the loop vectorizer > > > can run correctly. Maybe you can test is in X86 or ARM after fixing this ICE. > > > > Sorry for the late reply, the issue is that we have > > > > vect_vec_recur_.7_7 = VEC_PERM_EXPR > { 7, 8, 9, 10, 11, 12, 13, 14 }>; > > > > thus > > > > + for (unsigned i = 0; i < ncopies; ++i) > > + { > > + gphi *phi = as_a (STMT_VINFO_VEC_STMTS (def_stmt_info)[i]); > > + tree latch = PHI_ARG_DEF_FROM_EDGE (phi, loop_latch_edge (loop)); > > + tree recur = gimple_phi_result (phi); > > + gassign *assign > > + = gimple_build_assign (recur, VEC_PERM_EXPR, recur, latch, perm); > > + gimple_assign_set_lhs (assign, recur); > > > > needs to create a new SSA name for each LHS. You shouldn't create code in > > vect_get_vec_defs_for_operand either. > > > > Let me mangle the patch a bit. > > > > The attached is what I came up with, the permutes need to be generated when > > the backedge PHI values are filled in. Missing are ncopies > 1 handling, we'd > > need to think of how the initial value and the permutes would work here, missing > > is SLP support but more importantly handling in the epilogue (so on x86 requires > > constant loop bound) > > I've added a testcase that triggers on x86_64. > > Actually I broke it, the following is more correct. So let me finish the patch. I have everything besides the epilogue handling done, I'll get to that somewhen next week. Richard. > Richard. > > > Richard.