1; RUN: opt -codegenprepare -load-store-vectorizer %s -S -o - | FileCheck %s 2; RUN: opt -load-store-vectorizer %s -S -o - | FileCheck %s 3; RUN: opt -codegenprepare -aa-pipeline=basic-aa -passes='function(load-store-vectorizer)' %s -S -o - | FileCheck %s 4; RUN: opt -aa-pipeline=basic-aa -passes='function(load-store-vectorizer)' %s -S -o - | FileCheck %s 5 6target triple = "x86_64--" 7 8%union = type { { [4 x [4 x [4 x [16 x float]]]], [4 x [4 x [4 x [16 x float]]]], [10 x [10 x [4 x float]]] } } 9 10@global_pointer = external unnamed_addr global { %union, [2000 x i8] }, align 4 11 12; Function Attrs: convergent nounwind 13define void @test(i32 %base) #0 { 14; CHECK-LABEL: @test( 15; CHECK-NOT: load i32 16; CHECK: load <2 x i32> 17; CHECK-NOT: load i32 18entry: 19 %mul331 = and i32 %base, -4 20 %add350.4 = add i32 4, %mul331 21 %idx351.4 = zext i32 %add350.4 to i64 22 %arrayidx352.4 = getelementptr inbounds { %union, [2000 x i8] }, { %union, [2000 x i8] }* @global_pointer, i64 0, i32 0, i32 0, i32 1, i64 0, i64 0, i64 0, i64 %idx351.4 23 %tmp296.4 = bitcast float* %arrayidx352.4 to i32* 24 %add350.5 = add i32 5, %mul331 25 %idx351.5 = zext i32 %add350.5 to i64 26 %arrayidx352.5 = getelementptr inbounds { %union, [2000 x i8] }, { %union, [2000 x i8] }* @global_pointer, i64 0, i32 0, i32 0, i32 1, i64 0, i64 0, i64 0, i64 %idx351.5 27 %tmp296.5 = bitcast float* %arrayidx352.5 to i32* 28 %cnd = icmp ult i32 %base, 1000 29 br i1 %cnd, label %loads, label %exit 30 31loads: 32 ; If and only if the loads are in a different BB from the GEPs codegenprepare 33 ; would try to turn the GEPs into math, which makes LoadStoreVectorizer's job 34 ; harder 35 %tmp297.4 = load i32, i32* %tmp296.4, align 4, !tbaa !0 36 %tmp297.5 = load i32, i32* %tmp296.5, align 4, !tbaa !0 37 br label %exit 38 39exit: 40 ret void 41} 42 43; Function Attrs: convergent nounwind 44define void @test.codegenprepared(i32 %base) #0 { 45; CHECK-LABEL: @test.codegenprepared( 46; CHECK-NOT: load i32 47; CHECK: load <2 x i32> 48; CHECK-NOT: load i32 49entry: 50 %mul331 = and i32 %base, -4 51 %add350.4 = add i32 4, %mul331 52 %idx351.4 = zext i32 %add350.4 to i64 53 %add350.5 = add i32 5, %mul331 54 %idx351.5 = zext i32 %add350.5 to i64 55 %cnd = icmp ult i32 %base, 1000 56 br i1 %cnd, label %loads, label %exit 57 58loads: ; preds = %entry 59 %sunkaddr = mul i64 %idx351.4, 4 60 %sunkaddr1 = getelementptr inbounds i8, i8* bitcast ({ %union, [2000 x i8] }* @global_pointer to i8*), i64 %sunkaddr 61 %sunkaddr2 = getelementptr inbounds i8, i8* %sunkaddr1, i64 4096 62 %0 = bitcast i8* %sunkaddr2 to i32* 63 %tmp297.4 = load i32, i32* %0, align 4, !tbaa !0 64 %sunkaddr3 = mul i64 %idx351.5, 4 65 %sunkaddr4 = getelementptr inbounds i8, i8* bitcast ({ %union, [2000 x i8] }* @global_pointer to i8*), i64 %sunkaddr3 66 %sunkaddr5 = getelementptr inbounds i8, i8* %sunkaddr4, i64 4096 67 %1 = bitcast i8* %sunkaddr5 to i32* 68 %tmp297.5 = load i32, i32* %1, align 4, !tbaa !0 69 br label %exit 70 71exit: ; preds = %loads, %entry 72 ret void 73} 74 75attributes #0 = { convergent nounwind } 76 77!0 = !{!1, !1, i64 0} 78!1 = !{!"float", !2, i64 0} 79!2 = !{!"omnipotent char", !3, i64 0} 80!3 = !{!"Simple C++ TBAA"} 81