Currently, SLP vectorizer do not care about loops and their trip count. It may lead to inefficient vectorization in some cases. Patch adds loop nest-aware tree building and cost estimation. When it comes to tree building, it now checks that tree do not span across different loop nests. The nodes from other loop nests are immediate buildvector nodes. The cost model adds the knowledge about loop trip count. If it is unknown, the default value is used, controlled by the -slp-cost-loop-min-trip-count=<value> option. The cost of the vector nodes in the loop is multiplied by the number of iteration (trip count), because each vector node will be executed the trip count number of times. This allows better cost estimation. Original Reviewers: jdenny-ornl, vporpo, hiraditya, RKSimon Original PR: https://github.com/llvm/llvm-project/pull/150450 Recommit after revert in c7bd3062f1dac975cf9b706f457b3c55b4bf57ff and in 4e500bd0015042b0cd4b7c87b81caeea06072d24 Reviewers: Pull Request: https://github.com/llvm/llvm-project/pull/187391
38 lines
1.8 KiB
LLVM
38 lines
1.8 KiB
LLVM
; NOTE: Assertions have been autogenerated by utils/update_test_checks.py
|
|
; RUN: opt -mtriple=riscv64 -mcpu=sifive-x280 -passes=slp-vectorizer -S -slp-threshold=-11 < %s | FileCheck %s
|
|
|
|
define float @test(ptr %call78) {
|
|
; CHECK-LABEL: @test(
|
|
; CHECK-NEXT: entry:
|
|
; CHECK-NEXT: br label [[FOR_BODY194:%.*]]
|
|
; CHECK: for.body194:
|
|
; CHECK-NEXT: [[INDVARS_IV132:%.*]] = phi i64 [ 0, [[ENTRY:%.*]] ], [ 0, [[FOR_BODY194]] ]
|
|
; CHECK-NEXT: [[CURRENTW_031:%.*]] = phi ptr [ [[CALL78:%.*]], [[ENTRY]] ], [ [[PREVIOUSW_030:%.*]], [[FOR_BODY194]] ]
|
|
; CHECK-NEXT: [[PREVIOUSW_030]] = phi ptr [ null, [[ENTRY]] ], [ [[CURRENTW_031]], [[FOR_BODY194]] ]
|
|
; CHECK-NEXT: store float 0.000000e+00, ptr [[CURRENTW_031]], align 4
|
|
; CHECK-NEXT: tail call void null(ptr [[PREVIOUSW_030]], ptr null, ptr null, i32 0, i32 0, ptr null, ptr null, i32 0)
|
|
; CHECK-NEXT: br i1 false, label [[FOR_END286_LOOPEXIT:%.*]], label [[FOR_BODY194]]
|
|
; CHECK: for.end286.loopexit:
|
|
; CHECK-NEXT: [[CURRENTW_031_LCSSA:%.*]] = phi ptr [ [[CURRENTW_031]], [[FOR_BODY194]] ]
|
|
; CHECK-NEXT: [[PREVIOUSW_030_LCSSA:%.*]] = phi ptr [ [[PREVIOUSW_030]], [[FOR_BODY194]] ]
|
|
; CHECK-NEXT: ret float 0.000000e+00
|
|
;
|
|
entry:
|
|
br label %for.body194
|
|
|
|
for.body194:
|
|
%indvars.iv132 = phi i64 [ 0, %entry ], [ 0, %for.body194 ]
|
|
%currentw.031 = phi ptr [ %call78, %entry ], [ %previousw.030, %for.body194 ]
|
|
%previousw.030 = phi ptr [ null, %entry ], [ %currentw.031, %for.body194 ]
|
|
store float 0.000000e+00, ptr %currentw.031, align 4
|
|
tail call void null(ptr %previousw.030, ptr null, ptr null, i32 0, i32 0, ptr null, ptr null, i32 0)
|
|
br i1 false, label %for.end286.loopexit, label %for.body194
|
|
|
|
for.end286.loopexit:
|
|
%currentw.031.lcssa = phi ptr [ %currentw.031, %for.body194 ]
|
|
%previousw.030.lcssa = phi ptr [ %previousw.030, %for.body194 ]
|
|
ret float 0.000000e+00
|
|
}
|
|
|
|
|