1 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" 2 ; RUN: opt < %s -bb-vectorize -bb-vectorize-req-chain-depth=3 -bb-vectorize-ignore-target-info -instcombine -gvn -S | FileCheck %s 3 ; RUN: opt < %s -bb-vectorize -bb-vectorize-req-chain-depth=3 -bb-vectorize-aligned-only -bb-vectorize-ignore-target-info -instcombine -gvn -S | FileCheck %s -check-prefix=CHECK-AO 4 5 ; Simple 3-pair chain with loads and stores 6 define void @test1(double* %a, double* %b, double* %c) nounwind uwtable readonly { 7 entry: 8 %i0 = load double* %a, align 8 9 %i1 = load double* %b, align 8 10 %mul = fmul double %i0, %i1 11 %arrayidx3 = getelementptr inbounds double* %a, i64 1 12 %i3 = load double* %arrayidx3, align 8 13 %arrayidx4 = getelementptr inbounds double* %b, i64 1 14 %i4 = load double* %arrayidx4, align 8 15 %mul5 = fmul double %i3, %i4 16 store double %mul, double* %c, align 8 17 %arrayidx5 = getelementptr inbounds double* %c, i64 1 18 store double %mul5, double* %arrayidx5, align 8 19 ret void 20 ; CHECK: @test1 21 ; CHECK: %i0.v.i0 = bitcast double* %a to <2 x double>* 22 ; CHECK: %i1.v.i0 = bitcast double* %b to <2 x double>* 23 ; CHECK: %i0 = load <2 x double>* %i0.v.i0, align 8 24 ; CHECK: %i1 = load <2 x double>* %i1.v.i0, align 8 25 ; CHECK: %mul = fmul <2 x double> %i0, %i1 26 ; CHECK: %0 = bitcast double* %c to <2 x double>* 27 ; CHECK: store <2 x double> %mul, <2 x double>* %0, align 8 28 ; CHECK: ret void 29 ; CHECK-AO: @test1 30 ; CHECK-AO-NOT: <2 x double> 31 } 32 33 ; Simple chain with extending loads and stores 34 define void @test2(float* %a, float* %b, double* %c) nounwind uwtable readonly { 35 entry: 36 %i0f = load float* %a, align 4 37 %i0 = fpext float %i0f to double 38 %i1f = load float* %b, align 4 39 %i1 = fpext float %i1f to double 40 %mul = fmul double %i0, %i1 41 %arrayidx3 = getelementptr inbounds float* %a, i64 1 42 %i3f = load float* %arrayidx3, align 4 43 %i3 = fpext float %i3f to double 44 %arrayidx4 = getelementptr inbounds float* %b, i64 1 45 %i4f = load float* %arrayidx4, align 4 46 %i4 = fpext float %i4f to double 47 %mul5 = fmul double %i3, %i4 48 store double %mul, double* %c, align 8 49 %arrayidx5 = getelementptr inbounds double* %c, i64 1 50 store double %mul5, double* %arrayidx5, align 8 51 ret void 52 ; CHECK: @test2 53 ; CHECK: %i0f.v.i0 = bitcast float* %a to <2 x float>* 54 ; CHECK: %i1f.v.i0 = bitcast float* %b to <2 x float>* 55 ; CHECK: %i0f = load <2 x float>* %i0f.v.i0, align 4 56 ; CHECK: %i0 = fpext <2 x float> %i0f to <2 x double> 57 ; CHECK: %i1f = load <2 x float>* %i1f.v.i0, align 4 58 ; CHECK: %i1 = fpext <2 x float> %i1f to <2 x double> 59 ; CHECK: %mul = fmul <2 x double> %i0, %i1 60 ; CHECK: %0 = bitcast double* %c to <2 x double>* 61 ; CHECK: store <2 x double> %mul, <2 x double>* %0, align 8 62 ; CHECK: ret void 63 ; CHECK-AO: @test2 64 ; CHECK-AO-NOT: <2 x double> 65 } 66 67 ; Simple chain with loads and truncating stores 68 define void @test3(double* %a, double* %b, float* %c) nounwind uwtable readonly { 69 entry: 70 %i0 = load double* %a, align 8 71 %i1 = load double* %b, align 8 72 %mul = fmul double %i0, %i1 73 %mulf = fptrunc double %mul to float 74 %arrayidx3 = getelementptr inbounds double* %a, i64 1 75 %i3 = load double* %arrayidx3, align 8 76 %arrayidx4 = getelementptr inbounds double* %b, i64 1 77 %i4 = load double* %arrayidx4, align 8 78 %mul5 = fmul double %i3, %i4 79 %mul5f = fptrunc double %mul5 to float 80 store float %mulf, float* %c, align 8 81 %arrayidx5 = getelementptr inbounds float* %c, i64 1 82 store float %mul5f, float* %arrayidx5, align 4 83 ret void 84 ; CHECK: @test3 85 ; CHECK: %i0.v.i0 = bitcast double* %a to <2 x double>* 86 ; CHECK: %i1.v.i0 = bitcast double* %b to <2 x double>* 87 ; CHECK: %i0 = load <2 x double>* %i0.v.i0, align 8 88 ; CHECK: %i1 = load <2 x double>* %i1.v.i0, align 8 89 ; CHECK: %mul = fmul <2 x double> %i0, %i1 90 ; CHECK: %mulf = fptrunc <2 x double> %mul to <2 x float> 91 ; CHECK: %0 = bitcast float* %c to <2 x float>* 92 ; CHECK: store <2 x float> %mulf, <2 x float>* %0, align 8 93 ; CHECK: ret void 94 ; CHECK-AO: @test3 95 ; CHECK-AO: %i0 = load double* %a, align 8 96 ; CHECK-AO: %i1 = load double* %b, align 8 97 ; CHECK-AO: %arrayidx3 = getelementptr inbounds double* %a, i64 1 98 ; CHECK-AO: %i3 = load double* %arrayidx3, align 8 99 ; CHECK-AO: %arrayidx4 = getelementptr inbounds double* %b, i64 1 100 ; CHECK-AO: %i4 = load double* %arrayidx4, align 8 101 ; CHECK-AO: %mul.v.i1.1 = insertelement <2 x double> undef, double %i1, i32 0 102 ; CHECK-AO: %mul.v.i1.2 = insertelement <2 x double> %mul.v.i1.1, double %i4, i32 1 103 ; CHECK-AO: %mul.v.i0.1 = insertelement <2 x double> undef, double %i0, i32 0 104 ; CHECK-AO: %mul.v.i0.2 = insertelement <2 x double> %mul.v.i0.1, double %i3, i32 1 105 ; CHECK-AO: %mul = fmul <2 x double> %mul.v.i0.2, %mul.v.i1.2 106 ; CHECK-AO: %mulf = fptrunc <2 x double> %mul to <2 x float> 107 ; CHECK-AO: %0 = bitcast float* %c to <2 x float>* 108 ; CHECK-AO: store <2 x float> %mulf, <2 x float>* %0, align 8 109 ; CHECK-AO: ret void 110 } 111 112 ; Simple 3-pair chain with loads and stores (unreachable) 113 define void @test4(i1 %bool, double* %a, double* %b, double* %c) nounwind uwtable readonly { 114 entry: 115 br i1 %bool, label %if.then1, label %if.end 116 117 if.then1: 118 unreachable 119 br label %if.then 120 121 if.then: 122 %i0 = load double* %a, align 8 123 %i1 = load double* %b, align 8 124 %mul = fmul double %i0, %i1 125 %arrayidx3 = getelementptr inbounds double* %a, i64 1 126 %i3 = load double* %arrayidx3, align 8 127 %arrayidx4 = getelementptr inbounds double* %b, i64 1 128 %i4 = load double* %arrayidx4, align 8 129 %mul5 = fmul double %i3, %i4 130 store double %mul, double* %c, align 8 131 %arrayidx5 = getelementptr inbounds double* %c, i64 1 132 store double %mul5, double* %arrayidx5, align 8 133 br label %if.end 134 135 if.end: 136 ret void 137 ; CHECK: @test4 138 ; CHECK-NOT: <2 x double> 139 ; CHECK-AO: @test4 140 ; CHECK-AO-NOT: <2 x double> 141 } 142 143 ; Simple 3-pair chain with loads and stores 144 define void @test5(double* %a, double* %b, double* %c) nounwind uwtable readonly { 145 entry: 146 %i0 = load double* %a, align 8 147 %i1 = load double* %b, align 8 148 %mul = fmul double %i0, %i1 149 %arrayidx3 = getelementptr inbounds double* %a, i64 1 150 %i3 = load double* %arrayidx3, align 8 151 %arrayidx4 = getelementptr inbounds double* %b, i64 1 152 %i4 = load double* %arrayidx4, align 8 153 %mul5 = fmul double %i3, %i4 154 %arrayidx5 = getelementptr inbounds double* %c, i64 1 155 store double %mul5, double* %arrayidx5, align 8 156 store double %mul, double* %c, align 4 157 ret void 158 ; CHECK: @test5 159 ; CHECK: %i0.v.i0 = bitcast double* %a to <2 x double>* 160 ; CHECK: %i1.v.i0 = bitcast double* %b to <2 x double>* 161 ; CHECK: %i0 = load <2 x double>* %i0.v.i0, align 8 162 ; CHECK: %i1 = load <2 x double>* %i1.v.i0, align 8 163 ; CHECK: %mul = fmul <2 x double> %i0, %i1 164 ; CHECK: %0 = bitcast double* %c to <2 x double>* 165 ; CHECK: store <2 x double> %mul, <2 x double>* %0, align 4 166 ; CHECK: ret void 167 ; CHECK-AO: @test5 168 ; CHECK-AO-NOT: <2 x double> 169 } 170 171