1 ; NOTE: Assertions have been autogenerated by utils/update_test_checks.py UTC_ARGS: --version 2
2 ; RUN: opt < %s -passes=loop-vectorize,dce,instcombine -force-vector-interleave=1 -force-vector-width=4 -S | FileCheck %s
4 ; From a simple program with two address spaces:
5 ; char Y[4*10000] __attribute__((address_space(1)));
8 ; for (int i = 0; i < 4*10000; ++i)
13 target datalayout = "e-p:64:64:64-i1:8:8-i8:8:8-i16:16:16-i32:32:32-i64:64:64-f32:32:32-f64:64:64-v64:64:64-v128:128:128-a0:0:64-s0:64:64-f80:128:128-n8:16:32:64-S128"
15 @Y = common addrspace(1) global [40000 x i8] zeroinitializer, align 16
16 @X = common global [40000 x i8] zeroinitializer, align 16
18 define i32 @main() #0 {
19 ; CHECK-LABEL: define i32 @main
20 ; CHECK-SAME: () #[[ATTR0:[0-9]+]] {
22 ; CHECK-NEXT: br i1 false, label [[SCALAR_PH:%.*]], label [[VECTOR_PH:%.*]]
24 ; CHECK-NEXT: br label [[VECTOR_BODY:%.*]]
26 ; CHECK-NEXT: [[INDEX:%.*]] = phi i64 [ 0, [[VECTOR_PH]] ], [ [[INDEX_NEXT:%.*]], [[VECTOR_BODY]] ]
27 ; CHECK-NEXT: [[TMP0:%.*]] = getelementptr inbounds [40000 x i8], ptr addrspace(1) @Y, i64 0, i64 [[INDEX]]
28 ; CHECK-NEXT: [[WIDE_LOAD:%.*]] = load <4 x i8>, ptr addrspace(1) [[TMP0]], align 1
29 ; CHECK-NEXT: [[TMP1:%.*]] = add <4 x i8> [[WIDE_LOAD]], <i8 1, i8 1, i8 1, i8 1>
30 ; CHECK-NEXT: [[TMP2:%.*]] = getelementptr inbounds [40000 x i8], ptr @X, i64 0, i64 [[INDEX]]
31 ; CHECK-NEXT: store <4 x i8> [[TMP1]], ptr [[TMP2]], align 1
32 ; CHECK-NEXT: [[INDEX_NEXT]] = add nuw i64 [[INDEX]], 4
33 ; CHECK-NEXT: [[TMP3:%.*]] = icmp eq i64 [[INDEX_NEXT]], 40000
34 ; CHECK-NEXT: br i1 [[TMP3]], label [[MIDDLE_BLOCK:%.*]], label [[VECTOR_BODY]], !llvm.loop [[LOOP0:![0-9]+]]
35 ; CHECK: middle.block:
36 ; CHECK-NEXT: br i1 true, label [[FOR_END:%.*]], label [[SCALAR_PH]]
38 ; CHECK-NEXT: br label [[FOR_BODY:%.*]]
40 ; CHECK-NEXT: br i1 poison, label [[FOR_END]], label [[FOR_BODY]], !llvm.loop [[LOOP3:![0-9]+]]
42 ; CHECK-NEXT: ret i32 0
47 for.body: ; preds = %for.body, %entry
48 %indvars.iv = phi i64 [ 0, %entry ], [ %indvars.iv.next, %for.body ]
49 %arrayidx = getelementptr inbounds [40000 x i8], ptr addrspace(1) @Y, i64 0, i64 %indvars.iv
50 %0 = load i8, ptr addrspace(1) %arrayidx, align 1
52 %arrayidx3 = getelementptr inbounds [40000 x i8], ptr @X, i64 0, i64 %indvars.iv
53 store i8 %add, ptr %arrayidx3, align 1
54 %indvars.iv.next = add i64 %indvars.iv, 1
55 %lftr.wideiv = trunc i64 %indvars.iv.next to i32
56 %exitcond = icmp eq i32 %lftr.wideiv, 40000
57 br i1 %exitcond, label %for.end, label %for.body
59 for.end: ; preds = %for.body
63 attributes #0 = { nounwind uwtable "less-precise-fpmad"="false" "frame-pointer"="none" "no-infs-fp-math"="false" "no-nans-fp-math"="false" "unsafe-fp-math"="false" "use-soft-float"="false" }