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 -instcombine -gvn -S | FileCheck %s 3 ; RUN: opt < %s -bb-vectorize -bb-vectorize-req-chain-depth=3 -bb-vectorize-aligned-only -instcombine -gvn -S | FileCheck %s -check-prefix=CHECK-AO 4 5 ; FIXME: re-enable this once pointer vectors work properly 6 ; XFAIL: * 7 8 ; Simple 3-pair chain also with loads and stores (using ptrs and gep) 9 define double @test1(i64* %a, i64* %b, i64* %c) nounwind uwtable readonly { 10 entry: 11 %i0 = load i64* %a, align 8 12 %i1 = load i64* %b, align 8 13 %mul = mul i64 %i0, %i1 14 %arrayidx3 = getelementptr inbounds i64* %a, i64 1 15 %i3 = load i64* %arrayidx3, align 8 16 %arrayidx4 = getelementptr inbounds i64* %b, i64 1 17 %i4 = load i64* %arrayidx4, align 8 18 %mul5 = mul i64 %i3, %i4 19 %ptr = inttoptr i64 %mul to double* 20 %ptr5 = inttoptr i64 %mul5 to double* 21 %aptr = getelementptr inbounds double* %ptr, i64 2 22 %aptr5 = getelementptr inbounds double* %ptr5, i64 3 23 %av = load double* %aptr, align 16 24 %av5 = load double* %aptr5, align 16 25 %r = fmul double %av, %av5 26 store i64 %mul, i64* %c, align 8 27 %arrayidx5 = getelementptr inbounds i64* %c, i64 1 28 store i64 %mul5, i64* %arrayidx5, align 8 29 ret double %r 30 ; CHECK-LABEL: @test1( 31 ; CHECK: %i0.v.i0 = bitcast i64* %a to <2 x i64>* 32 ; CHECK: %i1.v.i0 = bitcast i64* %b to <2 x i64>* 33 ; CHECK: %i0 = load <2 x i64>* %i0.v.i0, align 8 34 ; CHECK: %i1 = load <2 x i64>* %i1.v.i0, align 8 35 ; CHECK: %mul = mul <2 x i64> %i0, %i1 36 ; CHECK: %ptr = inttoptr <2 x i64> %mul to <2 x double*> 37 ; CHECK: %aptr = getelementptr inbounds <2 x double*> %ptr, <2 x i64> <i64 2, i64 3> 38 ; CHECK: %aptr.v.r1 = extractelement <2 x double*> %aptr, i32 0 39 ; CHECK: %aptr.v.r2 = extractelement <2 x double*> %aptr, i32 1 40 ; CHECK: %av = load double* %aptr.v.r1, align 16 41 ; CHECK: %av5 = load double* %aptr.v.r2, align 16 42 ; CHECK: %r = fmul double %av, %av5 43 ; CHECK: %0 = bitcast i64* %c to <2 x i64>* 44 ; CHECK: store <2 x i64> %mul, <2 x i64>* %0, align 8 45 ; CHECK: ret double %r 46 ; CHECK-AO-LABEL: @test1( 47 ; CHECK-AO-NOT: load <2 x 48 } 49 50 ; Simple 3-pair chain with loads and stores (using ptrs and gep) 51 define void @test2(i64** %a, i64** %b, i64** %c) nounwind uwtable readonly { 52 entry: 53 %i0 = load i64** %a, align 8 54 %i1 = load i64** %b, align 8 55 %arrayidx3 = getelementptr inbounds i64** %a, i64 1 56 %i3 = load i64** %arrayidx3, align 8 57 %arrayidx4 = getelementptr inbounds i64** %b, i64 1 58 %i4 = load i64** %arrayidx4, align 8 59 %o1 = load i64* %i1, align 8 60 %o4 = load i64* %i4, align 8 61 %ptr0 = getelementptr inbounds i64* %i0, i64 %o1 62 %ptr3 = getelementptr inbounds i64* %i3, i64 %o4 63 store i64* %ptr0, i64** %c, align 8 64 %arrayidx5 = getelementptr inbounds i64** %c, i64 1 65 store i64* %ptr3, i64** %arrayidx5, align 8 66 ret void 67 ; CHECK-LABEL: @test2( 68 ; CHECK: %i0.v.i0 = bitcast i64** %a to <2 x i64*>* 69 ; CHECK: %i1 = load i64** %b, align 8 70 ; CHECK: %i0 = load <2 x i64*>* %i0.v.i0, align 8 71 ; CHECK: %arrayidx4 = getelementptr inbounds i64** %b, i64 1 72 ; CHECK: %i4 = load i64** %arrayidx4, align 8 73 ; CHECK: %o1 = load i64* %i1, align 8 74 ; CHECK: %o4 = load i64* %i4, align 8 75 ; CHECK: %ptr0.v.i1.1 = insertelement <2 x i64> undef, i64 %o1, i32 0 76 ; CHECK: %ptr0.v.i1.2 = insertelement <2 x i64> %ptr0.v.i1.1, i64 %o4, i32 1 77 ; CHECK: %ptr0 = getelementptr inbounds <2 x i64*> %i0, <2 x i64> %ptr0.v.i1.2 78 ; CHECK: %0 = bitcast i64** %c to <2 x i64*>* 79 ; CHECK: store <2 x i64*> %ptr0, <2 x i64*>* %0, align 8 80 ; CHECK: ret void 81 ; CHECK-AO-LABEL: @test2( 82 ; CHECK-AO-NOT: <2 x 83 } 84 85 ; Simple 3-pair chain with loads and stores (using ptrs and gep) 86 ; using pointer vectors. 87 define void @test3(<2 x i64*>* %a, <2 x i64*>* %b, <2 x i64*>* %c) nounwind uwtable readonly { 88 entry: 89 %i0 = load <2 x i64*>* %a, align 8 90 %i1 = load <2 x i64*>* %b, align 8 91 %arrayidx3 = getelementptr inbounds <2 x i64*>* %a, i64 1 92 %i3 = load <2 x i64*>* %arrayidx3, align 8 93 %arrayidx4 = getelementptr inbounds <2 x i64*>* %b, i64 1 94 %i4 = load <2 x i64*>* %arrayidx4, align 8 95 %j1 = extractelement <2 x i64*> %i1, i32 0 96 %j4 = extractelement <2 x i64*> %i4, i32 0 97 %o1 = load i64* %j1, align 8 98 %o4 = load i64* %j4, align 8 99 %j0 = extractelement <2 x i64*> %i0, i32 0 100 %j3 = extractelement <2 x i64*> %i3, i32 0 101 %ptr0 = getelementptr inbounds i64* %j0, i64 %o1 102 %ptr3 = getelementptr inbounds i64* %j3, i64 %o4 103 %qtr0 = insertelement <2 x i64*> undef, i64* %ptr0, i32 0 104 %rtr0 = insertelement <2 x i64*> %qtr0, i64* %ptr0, i32 1 105 %qtr3 = insertelement <2 x i64*> undef, i64* %ptr3, i32 0 106 %rtr3 = insertelement <2 x i64*> %qtr3, i64* %ptr3, i32 1 107 store <2 x i64*> %rtr0, <2 x i64*>* %c, align 8 108 %arrayidx5 = getelementptr inbounds <2 x i64*>* %c, i64 1 109 store <2 x i64*> %rtr3, <2 x i64*>* %arrayidx5, align 8 110 ret void 111 ; CHECK-LABEL: @test3( 112 ; CHECK: %i0.v.i0 = bitcast <2 x i64*>* %a to <4 x i64*>* 113 ; CHECK: %i1 = load <2 x i64*>* %b, align 8 114 ; CHECK: %i0 = load <4 x i64*>* %i0.v.i0, align 8 115 ; CHECK: %arrayidx4 = getelementptr inbounds <2 x i64*>* %b, i64 1 116 ; CHECK: %i4 = load <2 x i64*>* %arrayidx4, align 8 117 ; CHECK: %j1 = extractelement <2 x i64*> %i1, i32 0 118 ; CHECK: %j4 = extractelement <2 x i64*> %i4, i32 0 119 ; CHECK: %o1 = load i64* %j1, align 8 120 ; CHECK: %o4 = load i64* %j4, align 8 121 ; CHECK: %ptr0.v.i1.1 = insertelement <2 x i64> undef, i64 %o1, i32 0 122 ; CHECK: %ptr0.v.i1.2 = insertelement <2 x i64> %ptr0.v.i1.1, i64 %o4, i32 1 123 ; CHECK: %ptr0.v.i0 = shufflevector <4 x i64*> %i0, <4 x i64*> undef, <2 x i32> <i32 0, i32 2> 124 ; CHECK: %ptr0 = getelementptr inbounds <2 x i64*> %ptr0.v.i0, <2 x i64> %ptr0.v.i1.2 125 ; CHECK: %rtr0 = shufflevector <2 x i64*> %ptr0, <2 x i64*> undef, <2 x i32> zeroinitializer 126 ; CHECK: %rtr3 = shufflevector <2 x i64*> %ptr0, <2 x i64*> undef, <2 x i32> <i32 1, i32 1> 127 ; CHECK: %0 = bitcast <2 x i64*>* %c to <4 x i64*>* 128 ; CHECK: %1 = shufflevector <2 x i64*> %rtr0, <2 x i64*> %rtr3, <4 x i32> <i32 0, i32 1, i32 2, i32 3> 129 ; CHECK: store <4 x i64*> %1, <4 x i64*>* %0, align 8 130 ; CHECK: ret void 131 ; CHECK-AO-LABEL: @test3( 132 ; CHECK-AO-NOT: <4 x 133 } 134 135