Hal Finkel | c34e511 | 2012-02-01 03:51:43 +0000 | [diff] [blame] | 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" |
Chandler Carruth | 7383bfd6 | 2013-01-07 10:22:36 +0000 | [diff] [blame] | 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 |
Hal Finkel | c34e511 | 2012-02-01 03:51:43 +0000 | [diff] [blame] | 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: |
David Blaikie | a79ac14 | 2015-02-27 21:17:42 +0000 | [diff] [blame] | 8 | %i0 = load double, double* %a, align 8 |
| 9 | %i1 = load double, double* %b, align 8 |
Hal Finkel | c34e511 | 2012-02-01 03:51:43 +0000 | [diff] [blame] | 10 | %mul = fmul double %i0, %i1 |
David Blaikie | 79e6c74 | 2015-02-27 19:29:02 +0000 | [diff] [blame] | 11 | %arrayidx3 = getelementptr inbounds double, double* %a, i64 1 |
David Blaikie | a79ac14 | 2015-02-27 21:17:42 +0000 | [diff] [blame] | 12 | %i3 = load double, double* %arrayidx3, align 8 |
David Blaikie | 79e6c74 | 2015-02-27 19:29:02 +0000 | [diff] [blame] | 13 | %arrayidx4 = getelementptr inbounds double, double* %b, i64 1 |
David Blaikie | a79ac14 | 2015-02-27 21:17:42 +0000 | [diff] [blame] | 14 | %i4 = load double, double* %arrayidx4, align 8 |
Hal Finkel | c34e511 | 2012-02-01 03:51:43 +0000 | [diff] [blame] | 15 | %mul5 = fmul double %i3, %i4 |
| 16 | store double %mul, double* %c, align 8 |
David Blaikie | 79e6c74 | 2015-02-27 19:29:02 +0000 | [diff] [blame] | 17 | %arrayidx5 = getelementptr inbounds double, double* %c, i64 1 |
Hal Finkel | c34e511 | 2012-02-01 03:51:43 +0000 | [diff] [blame] | 18 | store double %mul5, double* %arrayidx5, align 8 |
| 19 | ret void |
Stephen Lin | c1c7a13 | 2013-07-14 01:42:54 +0000 | [diff] [blame] | 20 | ; CHECK-LABEL: @test1( |
Hal Finkel | c34e511 | 2012-02-01 03:51:43 +0000 | [diff] [blame] | 21 | ; CHECK: %i0.v.i0 = bitcast double* %a to <2 x double>* |
| 22 | ; CHECK: %i1.v.i0 = bitcast double* %b to <2 x double>* |
David Blaikie | a79ac14 | 2015-02-27 21:17:42 +0000 | [diff] [blame] | 23 | ; CHECK: %i0 = load <2 x double>, <2 x double>* %i0.v.i0, align 8 |
| 24 | ; CHECK: %i1 = load <2 x double>, <2 x double>* %i1.v.i0, align 8 |
Hal Finkel | c34e511 | 2012-02-01 03:51:43 +0000 | [diff] [blame] | 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 |
Stephen Lin | c1c7a13 | 2013-07-14 01:42:54 +0000 | [diff] [blame] | 29 | ; CHECK-AO-LABEL: @test1( |
Hal Finkel | c34e511 | 2012-02-01 03:51:43 +0000 | [diff] [blame] | 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: |
David Blaikie | a79ac14 | 2015-02-27 21:17:42 +0000 | [diff] [blame] | 36 | %i0f = load float, float* %a, align 4 |
Hal Finkel | c34e511 | 2012-02-01 03:51:43 +0000 | [diff] [blame] | 37 | %i0 = fpext float %i0f to double |
David Blaikie | a79ac14 | 2015-02-27 21:17:42 +0000 | [diff] [blame] | 38 | %i1f = load float, float* %b, align 4 |
Hal Finkel | c34e511 | 2012-02-01 03:51:43 +0000 | [diff] [blame] | 39 | %i1 = fpext float %i1f to double |
| 40 | %mul = fmul double %i0, %i1 |
David Blaikie | 79e6c74 | 2015-02-27 19:29:02 +0000 | [diff] [blame] | 41 | %arrayidx3 = getelementptr inbounds float, float* %a, i64 1 |
David Blaikie | a79ac14 | 2015-02-27 21:17:42 +0000 | [diff] [blame] | 42 | %i3f = load float, float* %arrayidx3, align 4 |
Hal Finkel | c34e511 | 2012-02-01 03:51:43 +0000 | [diff] [blame] | 43 | %i3 = fpext float %i3f to double |
David Blaikie | 79e6c74 | 2015-02-27 19:29:02 +0000 | [diff] [blame] | 44 | %arrayidx4 = getelementptr inbounds float, float* %b, i64 1 |
David Blaikie | a79ac14 | 2015-02-27 21:17:42 +0000 | [diff] [blame] | 45 | %i4f = load float, float* %arrayidx4, align 4 |
Hal Finkel | c34e511 | 2012-02-01 03:51:43 +0000 | [diff] [blame] | 46 | %i4 = fpext float %i4f to double |
| 47 | %mul5 = fmul double %i3, %i4 |
| 48 | store double %mul, double* %c, align 8 |
David Blaikie | 79e6c74 | 2015-02-27 19:29:02 +0000 | [diff] [blame] | 49 | %arrayidx5 = getelementptr inbounds double, double* %c, i64 1 |
Hal Finkel | c34e511 | 2012-02-01 03:51:43 +0000 | [diff] [blame] | 50 | store double %mul5, double* %arrayidx5, align 8 |
| 51 | ret void |
Stephen Lin | c1c7a13 | 2013-07-14 01:42:54 +0000 | [diff] [blame] | 52 | ; CHECK-LABEL: @test2( |
Hal Finkel | c34e511 | 2012-02-01 03:51:43 +0000 | [diff] [blame] | 53 | ; CHECK: %i0f.v.i0 = bitcast float* %a to <2 x float>* |
| 54 | ; CHECK: %i1f.v.i0 = bitcast float* %b to <2 x float>* |
David Blaikie | a79ac14 | 2015-02-27 21:17:42 +0000 | [diff] [blame] | 55 | ; CHECK: %i0f = load <2 x float>, <2 x float>* %i0f.v.i0, align 4 |
Hal Finkel | c34e511 | 2012-02-01 03:51:43 +0000 | [diff] [blame] | 56 | ; CHECK: %i0 = fpext <2 x float> %i0f to <2 x double> |
David Blaikie | a79ac14 | 2015-02-27 21:17:42 +0000 | [diff] [blame] | 57 | ; CHECK: %i1f = load <2 x float>, <2 x float>* %i1f.v.i0, align 4 |
Hal Finkel | c34e511 | 2012-02-01 03:51:43 +0000 | [diff] [blame] | 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 |
Stephen Lin | c1c7a13 | 2013-07-14 01:42:54 +0000 | [diff] [blame] | 63 | ; CHECK-AO-LABEL: @test2( |
Hal Finkel | c34e511 | 2012-02-01 03:51:43 +0000 | [diff] [blame] | 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: |
David Blaikie | a79ac14 | 2015-02-27 21:17:42 +0000 | [diff] [blame] | 70 | %i0 = load double, double* %a, align 8 |
| 71 | %i1 = load double, double* %b, align 8 |
Hal Finkel | c34e511 | 2012-02-01 03:51:43 +0000 | [diff] [blame] | 72 | %mul = fmul double %i0, %i1 |
| 73 | %mulf = fptrunc double %mul to float |
David Blaikie | 79e6c74 | 2015-02-27 19:29:02 +0000 | [diff] [blame] | 74 | %arrayidx3 = getelementptr inbounds double, double* %a, i64 1 |
David Blaikie | a79ac14 | 2015-02-27 21:17:42 +0000 | [diff] [blame] | 75 | %i3 = load double, double* %arrayidx3, align 8 |
David Blaikie | 79e6c74 | 2015-02-27 19:29:02 +0000 | [diff] [blame] | 76 | %arrayidx4 = getelementptr inbounds double, double* %b, i64 1 |
David Blaikie | a79ac14 | 2015-02-27 21:17:42 +0000 | [diff] [blame] | 77 | %i4 = load double, double* %arrayidx4, align 8 |
Hal Finkel | c34e511 | 2012-02-01 03:51:43 +0000 | [diff] [blame] | 78 | %mul5 = fmul double %i3, %i4 |
| 79 | %mul5f = fptrunc double %mul5 to float |
| 80 | store float %mulf, float* %c, align 8 |
David Blaikie | 79e6c74 | 2015-02-27 19:29:02 +0000 | [diff] [blame] | 81 | %arrayidx5 = getelementptr inbounds float, float* %c, i64 1 |
Hal Finkel | c34e511 | 2012-02-01 03:51:43 +0000 | [diff] [blame] | 82 | store float %mul5f, float* %arrayidx5, align 4 |
| 83 | ret void |
Stephen Lin | c1c7a13 | 2013-07-14 01:42:54 +0000 | [diff] [blame] | 84 | ; CHECK-LABEL: @test3( |
Hal Finkel | c34e511 | 2012-02-01 03:51:43 +0000 | [diff] [blame] | 85 | ; CHECK: %i0.v.i0 = bitcast double* %a to <2 x double>* |
| 86 | ; CHECK: %i1.v.i0 = bitcast double* %b to <2 x double>* |
David Blaikie | a79ac14 | 2015-02-27 21:17:42 +0000 | [diff] [blame] | 87 | ; CHECK: %i0 = load <2 x double>, <2 x double>* %i0.v.i0, align 8 |
| 88 | ; CHECK: %i1 = load <2 x double>, <2 x double>* %i1.v.i0, align 8 |
Hal Finkel | c34e511 | 2012-02-01 03:51:43 +0000 | [diff] [blame] | 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 |
Stephen Lin | c1c7a13 | 2013-07-14 01:42:54 +0000 | [diff] [blame] | 94 | ; CHECK-AO-LABEL: @test3( |
David Blaikie | a79ac14 | 2015-02-27 21:17:42 +0000 | [diff] [blame] | 95 | ; CHECK-AO: %i0 = load double, double* %a, align 8 |
| 96 | ; CHECK-AO: %i1 = load double, double* %b, align 8 |
David Blaikie | 79e6c74 | 2015-02-27 19:29:02 +0000 | [diff] [blame] | 97 | ; CHECK-AO: %arrayidx3 = getelementptr inbounds double, double* %a, i64 1 |
David Blaikie | a79ac14 | 2015-02-27 21:17:42 +0000 | [diff] [blame] | 98 | ; CHECK-AO: %i3 = load double, double* %arrayidx3, align 8 |
David Blaikie | 79e6c74 | 2015-02-27 19:29:02 +0000 | [diff] [blame] | 99 | ; CHECK-AO: %arrayidx4 = getelementptr inbounds double, double* %b, i64 1 |
David Blaikie | a79ac14 | 2015-02-27 21:17:42 +0000 | [diff] [blame] | 100 | ; CHECK-AO: %i4 = load double, double* %arrayidx4, align 8 |
Hal Finkel | 842ad0b | 2012-10-31 15:17:07 +0000 | [diff] [blame] | 101 | ; CHECK-AO: %mul.v.i1.1 = insertelement <2 x double> undef, double %i1, i32 0 |
Hal Finkel | c34e511 | 2012-02-01 03:51:43 +0000 | [diff] [blame] | 102 | ; CHECK-AO: %mul.v.i1.2 = insertelement <2 x double> %mul.v.i1.1, double %i4, i32 1 |
Hal Finkel | 842ad0b | 2012-10-31 15:17:07 +0000 | [diff] [blame] | 103 | ; CHECK-AO: %mul.v.i0.1 = insertelement <2 x double> undef, double %i0, i32 0 |
Hal Finkel | c34e511 | 2012-02-01 03:51:43 +0000 | [diff] [blame] | 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 | } |
Hal Finkel | 931c52b | 2012-10-22 18:00:55 +0000 | [diff] [blame] | 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: |
David Blaikie | a79ac14 | 2015-02-27 21:17:42 +0000 | [diff] [blame] | 122 | %i0 = load double, double* %a, align 8 |
| 123 | %i1 = load double, double* %b, align 8 |
Hal Finkel | 931c52b | 2012-10-22 18:00:55 +0000 | [diff] [blame] | 124 | %mul = fmul double %i0, %i1 |
David Blaikie | 79e6c74 | 2015-02-27 19:29:02 +0000 | [diff] [blame] | 125 | %arrayidx3 = getelementptr inbounds double, double* %a, i64 1 |
David Blaikie | a79ac14 | 2015-02-27 21:17:42 +0000 | [diff] [blame] | 126 | %i3 = load double, double* %arrayidx3, align 8 |
David Blaikie | 79e6c74 | 2015-02-27 19:29:02 +0000 | [diff] [blame] | 127 | %arrayidx4 = getelementptr inbounds double, double* %b, i64 1 |
David Blaikie | a79ac14 | 2015-02-27 21:17:42 +0000 | [diff] [blame] | 128 | %i4 = load double, double* %arrayidx4, align 8 |
Hal Finkel | 931c52b | 2012-10-22 18:00:55 +0000 | [diff] [blame] | 129 | %mul5 = fmul double %i3, %i4 |
| 130 | store double %mul, double* %c, align 8 |
David Blaikie | 79e6c74 | 2015-02-27 19:29:02 +0000 | [diff] [blame] | 131 | %arrayidx5 = getelementptr inbounds double, double* %c, i64 1 |
Hal Finkel | 931c52b | 2012-10-22 18:00:55 +0000 | [diff] [blame] | 132 | store double %mul5, double* %arrayidx5, align 8 |
| 133 | br label %if.end |
| 134 | |
| 135 | if.end: |
| 136 | ret void |
Stephen Lin | c1c7a13 | 2013-07-14 01:42:54 +0000 | [diff] [blame] | 137 | ; CHECK-LABEL: @test4( |
Hal Finkel | 931c52b | 2012-10-22 18:00:55 +0000 | [diff] [blame] | 138 | ; CHECK-NOT: <2 x double> |
Stephen Lin | c1c7a13 | 2013-07-14 01:42:54 +0000 | [diff] [blame] | 139 | ; CHECK-AO-LABEL: @test4( |
Hal Finkel | 931c52b | 2012-10-22 18:00:55 +0000 | [diff] [blame] | 140 | ; CHECK-AO-NOT: <2 x double> |
| 141 | } |
| 142 | |
Hal Finkel | 2eaadd1 | 2012-10-30 19:47:37 +0000 | [diff] [blame] | 143 | ; Simple 3-pair chain with loads and stores |
| 144 | define void @test5(double* %a, double* %b, double* %c) nounwind uwtable readonly { |
| 145 | entry: |
David Blaikie | a79ac14 | 2015-02-27 21:17:42 +0000 | [diff] [blame] | 146 | %i0 = load double, double* %a, align 8 |
| 147 | %i1 = load double, double* %b, align 8 |
Hal Finkel | 2eaadd1 | 2012-10-30 19:47:37 +0000 | [diff] [blame] | 148 | %mul = fmul double %i0, %i1 |
David Blaikie | 79e6c74 | 2015-02-27 19:29:02 +0000 | [diff] [blame] | 149 | %arrayidx3 = getelementptr inbounds double, double* %a, i64 1 |
David Blaikie | a79ac14 | 2015-02-27 21:17:42 +0000 | [diff] [blame] | 150 | %i3 = load double, double* %arrayidx3, align 8 |
David Blaikie | 79e6c74 | 2015-02-27 19:29:02 +0000 | [diff] [blame] | 151 | %arrayidx4 = getelementptr inbounds double, double* %b, i64 1 |
David Blaikie | a79ac14 | 2015-02-27 21:17:42 +0000 | [diff] [blame] | 152 | %i4 = load double, double* %arrayidx4, align 8 |
Hal Finkel | 2eaadd1 | 2012-10-30 19:47:37 +0000 | [diff] [blame] | 153 | %mul5 = fmul double %i3, %i4 |
David Blaikie | 79e6c74 | 2015-02-27 19:29:02 +0000 | [diff] [blame] | 154 | %arrayidx5 = getelementptr inbounds double, double* %c, i64 1 |
Hal Finkel | 2eaadd1 | 2012-10-30 19:47:37 +0000 | [diff] [blame] | 155 | store double %mul5, double* %arrayidx5, align 8 |
| 156 | store double %mul, double* %c, align 4 |
| 157 | ret void |
Stephen Lin | c1c7a13 | 2013-07-14 01:42:54 +0000 | [diff] [blame] | 158 | ; CHECK-LABEL: @test5( |
Hal Finkel | 2eaadd1 | 2012-10-30 19:47:37 +0000 | [diff] [blame] | 159 | ; CHECK: %i0.v.i0 = bitcast double* %a to <2 x double>* |
| 160 | ; CHECK: %i1.v.i0 = bitcast double* %b to <2 x double>* |
David Blaikie | a79ac14 | 2015-02-27 21:17:42 +0000 | [diff] [blame] | 161 | ; CHECK: %i0 = load <2 x double>, <2 x double>* %i0.v.i0, align 8 |
| 162 | ; CHECK: %i1 = load <2 x double>, <2 x double>* %i1.v.i0, align 8 |
Hal Finkel | 2eaadd1 | 2012-10-30 19:47:37 +0000 | [diff] [blame] | 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 |
Stephen Lin | c1c7a13 | 2013-07-14 01:42:54 +0000 | [diff] [blame] | 167 | ; CHECK-AO-LABEL: @test5( |
Hal Finkel | 2eaadd1 | 2012-10-30 19:47:37 +0000 | [diff] [blame] | 168 | ; CHECK-AO-NOT: <2 x double> |
| 169 | } |
| 170 | |