Skip to content

Commit b9b0ea5

Browse files
committed
[LV] Pass DT to isGuaranteedNotToBePoison in canVectorizeWithIfCvt.
Pass DT to slightly improve analysis results. Note that the context instruction is already passed.
1 parent 5cda242 commit b9b0ea5

File tree

2 files changed

+7
-24
lines changed

2 files changed

+7
-24
lines changed

llvm/lib/Transforms/Vectorize/LoopVectorizationLegality.cpp

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1530,7 +1530,8 @@ bool LoopVectorizationLegality::canVectorizeWithIfConvert() {
15301530
if (!isGuaranteedNotToBePoison(CurrV, AC,
15311531
TheLoop->getLoopPredecessor()
15321532
->getTerminator()
1533-
->getIterator()))
1533+
->getIterator(),
1534+
DT))
15341535
return false;
15351536
continue;
15361537
}

llvm/test/Transforms/LoopVectorize/dereferenceable-info-from-assumption-constant-size-needs-loop-guards.ll

Lines changed: 5 additions & 23 deletions
Original file line numberDiff line numberDiff line change
@@ -70,31 +70,13 @@ define void @loop_guard_on_assume_needed_to_prove_dereferenceable(i64 %x, ptr no
7070
; CHECK: [[VECTOR_PH]]:
7171
; CHECK-NEXT: br label %[[VECTOR_BODY:.*]]
7272
; CHECK: [[VECTOR_BODY]]:
73-
; CHECK-NEXT: [[INDEX:%.*]] = phi i64 [ 0, %[[VECTOR_PH]] ], [ [[INDEX_NEXT:%.*]], %[[PRED_LOAD_CONTINUE2:.*]] ]
73+
; CHECK-NEXT: [[INDEX:%.*]] = phi i64 [ 0, %[[VECTOR_PH]] ], [ [[INDEX_NEXT:%.*]], %[[VECTOR_BODY]] ]
7474
; CHECK-NEXT: [[TMP0:%.*]] = getelementptr i32, ptr [[B]], i64 [[INDEX]]
7575
; CHECK-NEXT: [[WIDE_LOAD:%.*]] = load <2 x i32>, ptr [[TMP0]], align 4
76-
; CHECK-NEXT: [[TMP1:%.*]] = icmp ne <2 x i32> [[WIDE_LOAD]], zeroinitializer
77-
; CHECK-NEXT: [[TMP2:%.*]] = extractelement <2 x i1> [[TMP1]], i32 0
78-
; CHECK-NEXT: br i1 [[TMP2]], label %[[PRED_LOAD_IF:.*]], label %[[PRED_LOAD_CONTINUE:.*]]
79-
; CHECK: [[PRED_LOAD_IF]]:
80-
; CHECK-NEXT: [[TMP3:%.*]] = add i64 [[INDEX]], 0
81-
; CHECK-NEXT: [[TMP4:%.*]] = getelementptr i32, ptr [[A]], i64 [[TMP3]]
82-
; CHECK-NEXT: [[TMP5:%.*]] = load i32, ptr [[TMP4]], align 4
83-
; CHECK-NEXT: [[TMP6:%.*]] = insertelement <2 x i32> poison, i32 [[TMP5]], i32 0
84-
; CHECK-NEXT: br label %[[PRED_LOAD_CONTINUE]]
85-
; CHECK: [[PRED_LOAD_CONTINUE]]:
86-
; CHECK-NEXT: [[TMP7:%.*]] = phi <2 x i32> [ poison, %[[VECTOR_BODY]] ], [ [[TMP6]], %[[PRED_LOAD_IF]] ]
87-
; CHECK-NEXT: [[TMP8:%.*]] = extractelement <2 x i1> [[TMP1]], i32 1
88-
; CHECK-NEXT: br i1 [[TMP8]], label %[[PRED_LOAD_IF1:.*]], label %[[PRED_LOAD_CONTINUE2]]
89-
; CHECK: [[PRED_LOAD_IF1]]:
90-
; CHECK-NEXT: [[TMP9:%.*]] = add i64 [[INDEX]], 1
91-
; CHECK-NEXT: [[TMP10:%.*]] = getelementptr i32, ptr [[A]], i64 [[TMP9]]
92-
; CHECK-NEXT: [[TMP11:%.*]] = load i32, ptr [[TMP10]], align 4
93-
; CHECK-NEXT: [[TMP12:%.*]] = insertelement <2 x i32> [[TMP7]], i32 [[TMP11]], i32 1
94-
; CHECK-NEXT: br label %[[PRED_LOAD_CONTINUE2]]
95-
; CHECK: [[PRED_LOAD_CONTINUE2]]:
96-
; CHECK-NEXT: [[TMP13:%.*]] = phi <2 x i32> [ [[TMP7]], %[[PRED_LOAD_CONTINUE]] ], [ [[TMP12]], %[[PRED_LOAD_IF1]] ]
97-
; CHECK-NEXT: [[PREDPHI:%.*]] = select <2 x i1> [[TMP1]], <2 x i32> [[TMP13]], <2 x i32> [[WIDE_LOAD]]
76+
; CHECK-NEXT: [[TMP1:%.*]] = icmp eq <2 x i32> [[WIDE_LOAD]], zeroinitializer
77+
; CHECK-NEXT: [[TMP2:%.*]] = getelementptr i32, ptr [[A]], i64 [[INDEX]]
78+
; CHECK-NEXT: [[WIDE_LOAD1:%.*]] = load <2 x i32>, ptr [[TMP2]], align 4
79+
; CHECK-NEXT: [[PREDPHI:%.*]] = select <2 x i1> [[TMP1]], <2 x i32> [[WIDE_LOAD]], <2 x i32> [[WIDE_LOAD1]]
9880
; CHECK-NEXT: [[TMP14:%.*]] = getelementptr inbounds i32, ptr [[C]], i64 [[INDEX]]
9981
; CHECK-NEXT: store <2 x i32> [[PREDPHI]], ptr [[TMP14]], align 4
10082
; CHECK-NEXT: [[INDEX_NEXT]] = add nuw i64 [[INDEX]], 2

0 commit comments

Comments
 (0)