Skip to content

Commit e584278

Browse files
committed
[LV] Update tests to avoid loop invariant instructions.
Update some tests with loop invariant instructions so the instructions cannot be hoisted out. This preserves the original test intention after #107894.
1 parent f009f72 commit e584278

File tree

3 files changed

+11
-5
lines changed

3 files changed

+11
-5
lines changed

llvm/test/Transforms/LoopVectorize/AArch64/scalable-call.ll

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -128,6 +128,7 @@ for.cond.cleanup: ; preds = %for.body
128128

129129
; CHECK-REMARKS: UserVF ignored because of invalid costs.
130130
; CHECK-REMARKS-NEXT: t.c:3:10: Recipe with invalid costs prevented vectorization at VF=(vscale x 1): load
131+
; CHECK-REMARKS-NEXT: t.c:3:30: Recipe with invalid costs prevented vectorization at VF=(vscale x 1): fadd
131132
; CHECK-REMARKS-NEXT: t.c:3:30: Recipe with invalid costs prevented vectorization at VF=(vscale x 1, vscale x 2): call to llvm.sin.f32
132133
; CHECK-REMARKS-NEXT: t.c:3:20: Recipe with invalid costs prevented vectorization at VF=(vscale x 1, vscale x 2): call to llvm.sin.f32
133134
; CHECK-REMARKS-NEXT: t.c:3:40: Recipe with invalid costs prevented vectorization at VF=(vscale x 1): store
@@ -148,7 +149,8 @@ if.then:
148149
%1 = tail call fast float @llvm.sin.f32(float %0), !dbg !12
149150
br label %if.end
150151
if.else:
151-
%2 = tail call fast float @llvm.sin.f32(float 0.0), !dbg !13
152+
%add = fadd float %0, 12.0, !dbg !13
153+
%2 = tail call fast float @llvm.sin.f32(float %add), !dbg !13
152154
br label %if.end
153155
if.end:
154156
%3 = phi float [%1, %if.then], [%2, %if.else]

llvm/test/Transforms/LoopVectorize/is_fpclass.ll

Lines changed: 6 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -10,8 +10,11 @@ define void @d() {
1010
; CHECK: vector.body:
1111
; CHECK-NEXT: [[INDEX:%.*]] = phi i64 [ 0, [[VECTOR_PH]] ], [ [[INDEX_NEXT:%.*]], [[VECTOR_BODY]] ]
1212
; CHECK-NEXT: [[TMP0:%.*]] = add i64 [[INDEX]], 0
13+
; CHECK-NEXT: [[TMP6:%.*]] = load float, ptr null, align 4
14+
; CHECK-NEXT: [[BROADCAST_SPLATINSERT:%.*]] = insertelement <2 x float> poison, float [[TMP6]], i64 0
15+
; CHECK-NEXT: [[BROADCAST_SPLAT:%.*]] = shufflevector <2 x float> [[BROADCAST_SPLATINSERT]], <2 x float> poison, <2 x i32> zeroinitializer
1316
; CHECK-NEXT: [[TMP1:%.*]] = getelementptr float, ptr @d, i64 [[TMP0]]
14-
; CHECK-NEXT: [[TMP2:%.*]] = call <2 x i1> @llvm.is.fpclass.v2f32(<2 x float> zeroinitializer, i32 0)
17+
; CHECK-NEXT: [[TMP2:%.*]] = call <2 x i1> @llvm.is.fpclass.v2f32(<2 x float> [[BROADCAST_SPLAT]], i32 0)
1518
; CHECK-NEXT: [[TMP3:%.*]] = select <2 x i1> [[TMP2]], <2 x float> zeroinitializer, <2 x float> zeroinitializer
1619
; CHECK-NEXT: [[TMP4:%.*]] = getelementptr float, ptr [[TMP1]], i32 0
1720
; CHECK-NEXT: store <2 x float> [[TMP3]], ptr [[TMP4]], align 4
@@ -27,7 +30,7 @@ define void @d() {
2730
; CHECK-NEXT: [[I:%.*]] = phi i64 [ [[BC_RESUME_VAL]], [[SCALAR_PH]] ], [ [[I7:%.*]], [[LOOP]] ]
2831
; CHECK-NEXT: [[I3:%.*]] = load float, ptr null, align 4
2932
; CHECK-NEXT: [[I4:%.*]] = getelementptr float, ptr @d, i64 [[I]]
30-
; CHECK-NEXT: [[I5:%.*]] = tail call i1 @llvm.is.fpclass.f32(float 0.000000e+00, i32 0)
33+
; CHECK-NEXT: [[I5:%.*]] = tail call i1 @llvm.is.fpclass.f32(float [[I3]], i32 0)
3134
; CHECK-NEXT: [[I6:%.*]] = select i1 [[I5]], float 0.000000e+00, float 0.000000e+00
3235
; CHECK-NEXT: store float [[I6]], ptr [[I4]], align 4
3336
; CHECK-NEXT: [[I7]] = add i64 [[I]], 1
@@ -43,7 +46,7 @@ loop:
4346
%i = phi i64 [ 0, %entry ], [ %i7, %loop ]
4447
%i3 = load float, ptr null, align 4
4548
%i4 = getelementptr float, ptr @d, i64 %i
46-
%i5 = tail call i1 @llvm.is.fpclass.f32(float 0.0, i32 0)
49+
%i5 = tail call i1 @llvm.is.fpclass.f32(float %i3, i32 0)
4750
%i6 = select i1 %i5, float 0.0, float 0.0
4851
store float %i6, ptr %i4, align 4
4952
%i7 = add i64 %i, 1

llvm/test/Transforms/LoopVectorize/vector-freeze.ll

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -18,7 +18,8 @@ exit:
1818

1919
loop:
2020
%tmp3 = phi ptr [ %tmp6, %loop ], [ %addr, %entry ]
21-
%tmp4 = freeze i64 0
21+
%l = load i64, ptr %tmp3
22+
%tmp4 = freeze i64 %l
2223
%tmp5 = add i64 0, 0
2324
%tmp6 = getelementptr inbounds ptr, ptr %tmp3, i64 1
2425
%tmp7 = icmp eq ptr %tmp6, null

0 commit comments

Comments
 (0)