Skip to content

Commit 79de036

Browse files
committed
[LV][X86] Add test for preserving flags when widening casts; NFC
1 parent faefedf commit 79de036

File tree

1 file changed

+78
-0
lines changed

1 file changed

+78
-0
lines changed
Lines changed: 78 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,78 @@
1+
; NOTE: Assertions have been autogenerated by utils/update_test_checks.py
2+
; RUN: opt -passes="default<O3>,loop-vectorize" -force-vector-interleave=1 -force-vector-width=4 -S < %s | FileCheck %s
3+
4+
target datalayout = "e-m:e-i64:64-f80:128-n8:16:32:64-S128"
5+
target triple = "x86_64-unknown-linux-gnu"
6+
7+
define dso_local void @uitofp_preserve_nneg(ptr nocapture noundef writeonly %result, i32 noundef %size, float noundef %y, float noundef %delta) {
8+
; CHECK-LABEL: @uitofp_preserve_nneg(
9+
; CHECK-NEXT: entry:
10+
; CHECK-NEXT: [[CMP4:%.*]] = icmp sgt i32 [[SIZE:%.*]], 0
11+
; CHECK-NEXT: br i1 [[CMP4]], label [[FOR_BODY_PREHEADER:%.*]], label [[FOR_END:%.*]]
12+
; CHECK: for.body.preheader:
13+
; CHECK-NEXT: [[WIDE_TRIP_COUNT:%.*]] = zext nneg i32 [[SIZE]] to i64
14+
; CHECK-NEXT: [[MIN_ITERS_CHECK:%.*]] = icmp ult i32 [[SIZE]], 4
15+
; CHECK-NEXT: br i1 [[MIN_ITERS_CHECK]], label [[FOR_BODY_PREHEADER4:%.*]], label [[VECTOR_PH:%.*]]
16+
; CHECK: vector.ph:
17+
; CHECK-NEXT: [[N_VEC:%.*]] = and i64 [[WIDE_TRIP_COUNT]], 2147483644
18+
; CHECK-NEXT: [[BROADCAST_SPLATINSERT:%.*]] = insertelement <4 x float> poison, float [[DELTA:%.*]], i64 0
19+
; CHECK-NEXT: [[BROADCAST_SPLAT:%.*]] = shufflevector <4 x float> [[BROADCAST_SPLATINSERT]], <4 x float> poison, <4 x i32> zeroinitializer
20+
; CHECK-NEXT: [[BROADCAST_SPLATINSERT2:%.*]] = insertelement <4 x float> poison, float [[Y:%.*]], i64 0
21+
; CHECK-NEXT: [[BROADCAST_SPLAT3:%.*]] = shufflevector <4 x float> [[BROADCAST_SPLATINSERT2]], <4 x float> poison, <4 x i32> zeroinitializer
22+
; CHECK-NEXT: br label [[VECTOR_BODY:%.*]]
23+
; CHECK: vector.body:
24+
; CHECK-NEXT: [[INDEX:%.*]] = phi i64 [ 0, [[VECTOR_PH]] ], [ [[INDEX_NEXT:%.*]], [[VECTOR_BODY]] ]
25+
; CHECK-NEXT: [[VEC_IND:%.*]] = phi <4 x i32> [ <i32 0, i32 1, i32 2, i32 3>, [[VECTOR_PH]] ], [ [[VEC_IND_NEXT:%.*]], [[VECTOR_BODY]] ]
26+
; CHECK-NEXT: [[TMP0:%.*]] = uitofp <4 x i32> [[VEC_IND]] to <4 x float>
27+
; CHECK-NEXT: [[TMP1:%.*]] = tail call <4 x float> @llvm.fmuladd.v4f32(<4 x float> [[BROADCAST_SPLAT]], <4 x float> [[TMP0]], <4 x float> [[BROADCAST_SPLAT3]])
28+
; CHECK-NEXT: [[TMP2:%.*]] = getelementptr inbounds float, ptr [[RESULT:%.*]], i64 [[INDEX]]
29+
; CHECK-NEXT: store <4 x float> [[TMP1]], ptr [[TMP2]], align 4
30+
; CHECK-NEXT: [[INDEX_NEXT]] = add nuw i64 [[INDEX]], 4
31+
; CHECK-NEXT: [[VEC_IND_NEXT]] = add <4 x i32> [[VEC_IND]], splat (i32 4)
32+
; CHECK-NEXT: [[TMP3:%.*]] = icmp eq i64 [[INDEX_NEXT]], [[N_VEC]]
33+
; CHECK-NEXT: br i1 [[TMP3]], label [[MIDDLE_BLOCK:%.*]], label [[VECTOR_BODY]], !llvm.loop [[LOOP0:![0-9]+]]
34+
; CHECK: middle.block:
35+
; CHECK-NEXT: [[CMP_N:%.*]] = icmp eq i64 [[N_VEC]], [[WIDE_TRIP_COUNT]]
36+
; CHECK-NEXT: br i1 [[CMP_N]], label [[FOR_END]], label [[FOR_BODY_PREHEADER4]]
37+
; CHECK: for.body.preheader4:
38+
; CHECK-NEXT: [[INDVARS_IV_PH:%.*]] = phi i64 [ 0, [[FOR_BODY_PREHEADER]] ], [ [[N_VEC]], [[MIDDLE_BLOCK]] ]
39+
; CHECK-NEXT: br label [[FOR_BODY:%.*]]
40+
; CHECK: for.body:
41+
; CHECK-NEXT: [[INDVARS_IV:%.*]] = phi i64 [ [[INDVARS_IV_NEXT:%.*]], [[FOR_BODY]] ], [ [[INDVARS_IV_PH]], [[FOR_BODY_PREHEADER4]] ]
42+
; CHECK-NEXT: [[TMP4:%.*]] = trunc nuw nsw i64 [[INDVARS_IV]] to i32
43+
; CHECK-NEXT: [[CONV:%.*]] = uitofp nneg i32 [[TMP4]] to float
44+
; CHECK-NEXT: [[TMP5:%.*]] = tail call float @llvm.fmuladd.f32(float [[DELTA]], float [[CONV]], float [[Y]])
45+
; CHECK-NEXT: [[ARRAYIDX:%.*]] = getelementptr inbounds float, ptr [[RESULT]], i64 [[INDVARS_IV]]
46+
; CHECK-NEXT: store float [[TMP5]], ptr [[ARRAYIDX]], align 4
47+
; CHECK-NEXT: [[INDVARS_IV_NEXT]] = add nuw nsw i64 [[INDVARS_IV]], 1
48+
; CHECK-NEXT: [[EXITCOND_NOT:%.*]] = icmp eq i64 [[INDVARS_IV_NEXT]], [[WIDE_TRIP_COUNT]]
49+
; CHECK-NEXT: br i1 [[EXITCOND_NOT]], label [[FOR_END_LOOPEXIT:%.*]], label [[FOR_BODY]], !llvm.loop [[LOOP3:![0-9]+]]
50+
; CHECK: for.end.loopexit:
51+
; CHECK-NEXT: br label [[FOR_END]]
52+
; CHECK: for.end:
53+
; CHECK-NEXT: ret void
54+
;
55+
entry:
56+
%cmp4 = icmp sgt i32 %size, 0
57+
br i1 %cmp4, label %for.body.preheader, label %for.end
58+
59+
for.body.preheader:
60+
br label %for.body
61+
62+
for.body:
63+
%t.05 = phi i32 [ %inc, %for.body ], [ 0, %for.body.preheader ]
64+
%conv = uitofp nneg i32 %t.05 to float
65+
%0 = tail call float @llvm.fmuladd.f32(float %delta, float %conv, float %y)
66+
%idxprom = zext nneg i32 %t.05 to i64
67+
%arrayidx = getelementptr inbounds float, ptr %result, i64 %idxprom
68+
store float %0, ptr %arrayidx, align 4
69+
%inc = add nuw nsw i32 %t.05, 1
70+
%cmp = icmp slt i32 %inc, %size
71+
br i1 %cmp, label %for.body, label %for.end.loopexit
72+
73+
for.end.loopexit:
74+
br label %for.end
75+
76+
for.end:
77+
ret void
78+
}

0 commit comments

Comments
 (0)