1 ; NOTE: Assertions have been autogenerated by utils/update_test_checks.py
2 ; RUN: opt -passes=loop-vectorize -S -mtriple=x86_64-- -o - %s | FileCheck %s
4 ; Testcase that verify that we don't get a faulty bitcast that cast between
9 @a = global [1 x %rec8] zeroinitializer
10 @b = global [2 x ptr] zeroinitializer
16 ; CHECK-NEXT: br i1 false, label [[SCALAR_PH:%.*]], label [[VECTOR_PH:%.*]]
18 ; CHECK-NEXT: br label [[VECTOR_BODY:%.*]]
20 ; CHECK-NEXT: [[INDEX:%.*]] = phi i32 [ 0, [[VECTOR_PH]] ], [ [[INDEX_NEXT:%.*]], [[VECTOR_BODY]] ]
21 ; CHECK-NEXT: [[OFFSET_IDX:%.*]] = trunc i32 [[INDEX]] to i16
22 ; CHECK-NEXT: [[TMP0:%.*]] = add i16 [[OFFSET_IDX]], 0
23 ; CHECK-NEXT: [[TMP1:%.*]] = sext i16 [[TMP0]] to i64
24 ; CHECK-NEXT: [[TMP2:%.*]] = getelementptr [2 x ptr], ptr @b, i16 0, i64 [[TMP1]]
25 ; CHECK-NEXT: [[TMP3:%.*]] = getelementptr ptr, ptr [[TMP2]], i32 0
26 ; CHECK-NEXT: store <2 x ptr> <ptr @a, ptr @a>, ptr [[TMP3]], align 8
27 ; CHECK-NEXT: [[INDEX_NEXT]] = add nuw i32 [[INDEX]], 2
28 ; CHECK-NEXT: br i1 true, label [[MIDDLE_BLOCK:%.*]], label [[VECTOR_BODY]], !llvm.loop [[LOOP0:![0-9]+]]
29 ; CHECK: middle.block:
30 ; CHECK-NEXT: br i1 true, label [[BB3:%.*]], label [[SCALAR_PH]]
32 ; CHECK-NEXT: [[BC_RESUME_VAL:%.*]] = phi i16 [ 2, [[MIDDLE_BLOCK]] ], [ 0, [[BB1:%.*]] ]
33 ; CHECK-NEXT: br label [[BB2:%.*]]
35 ; CHECK-NEXT: [[C_1_0:%.*]] = phi i16 [ [[BC_RESUME_VAL]], [[SCALAR_PH]] ], [ [[_TMP9:%.*]], [[BB2]] ]
36 ; CHECK-NEXT: [[_TMP1:%.*]] = zext i16 0 to i64
37 ; CHECK-NEXT: [[_TMP2:%.*]] = getelementptr [1 x %rec8], ptr @a, i16 0, i64 [[_TMP1]]
38 ; CHECK-NEXT: [[_TMP6:%.*]] = sext i16 [[C_1_0]] to i64
39 ; CHECK-NEXT: [[_TMP7:%.*]] = getelementptr [2 x ptr], ptr @b, i16 0, i64 [[_TMP6]]
40 ; CHECK-NEXT: store ptr [[_TMP2]], ptr [[_TMP7]], align 8
41 ; CHECK-NEXT: [[_TMP9]] = add nsw i16 [[C_1_0]], 1
42 ; CHECK-NEXT: [[_TMP11:%.*]] = icmp slt i16 [[_TMP9]], 2
43 ; CHECK-NEXT: br i1 [[_TMP11]], label [[BB2]], label [[BB3]], !llvm.loop [[LOOP2:![0-9]+]]
45 ; CHECK-NEXT: ret void
52 %c.1.0 = phi i16 [ 0, %bb1 ], [ %_tmp9, %bb2 ]
53 %_tmp1 = zext i16 0 to i64
54 %_tmp2 = getelementptr [1 x %rec8], ptr @a, i16 0, i64 %_tmp1
55 %_tmp6 = sext i16 %c.1.0 to i64
56 %_tmp7 = getelementptr [2 x ptr], ptr @b, i16 0, i64 %_tmp6
57 store ptr %_tmp2, ptr %_tmp7
58 %_tmp9 = add nsw i16 %c.1.0, 1
59 %_tmp11 = icmp slt i16 %_tmp9, 2
60 br i1 %_tmp11, label %bb2, label %bb3