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 ; Simple 3-pair chain also with loads and stores (using ptrs and gep) 6 define double @test1(i64* %a, i64* %b, i64* %c) nounwind uwtable readonly { 7 entry: 8 %i0 = load i64* %a, align 8 9 %i1 = load i64* %b, align 8 10 %mul = mul i64 %i0, %i1 11 %arrayidx3 = getelementptr inbounds i64* %a, i64 1 12 %i3 = load i64* %arrayidx3, align 8 13 %arrayidx4 = getelementptr inbounds i64* %b, i64 1 14 %i4 = load i64* %arrayidx4, align 8 15 %mul5 = mul i64 %i3, %i4 16 %ptr = inttoptr i64 %mul to double* 17 %ptr5 = inttoptr i64 %mul5 to double* 18 %aptr = getelementptr inbounds double* %ptr, i64 2 19 %aptr5 = getelementptr inbounds double* %ptr5, i64 3 20 %av = load double* %aptr, align 16 21 %av5 = load double* %aptr5, align 16 22 %r = fmul double %av, %av5 23 store i64 %mul, i64* %c, align 8 24 %arrayidx5 = getelementptr inbounds i64* %c, i64 1 25 store i64 %mul5, i64* %arrayidx5, align 8 26 ret double %r 27 ; CHECK: @test1 28 ; CHECK: %i0.v.i0 = bitcast i64* %a to <2 x i64>* 29 ; CHECK: %i1.v.i0 = bitcast i64* %b to <2 x i64>* 30 ; CHECK: %i0 = load <2 x i64>* %i0.v.i0, align 8 31 ; CHECK: %i1 = load <2 x i64>* %i1.v.i0, align 8 32 ; CHECK: %mul = mul <2 x i64> %i0, %i1 33 ; CHECK: %ptr = inttoptr <2 x i64> %mul to <2 x double*> 34 ; CHECK: %aptr = getelementptr inbounds <2 x double*> %ptr, <2 x i64> <i64 2, i64 3> 35 ; CHECK: %aptr.v.r1 = extractelement <2 x double*> %aptr, i32 0 36 ; CHECK: %aptr.v.r2 = extractelement <2 x double*> %aptr, i32 1 37 ; CHECK: %av = load double* %aptr.v.r1, align 16 38 ; CHECK: %av5 = load double* %aptr.v.r2, align 16 39 ; CHECK: %r = fmul double %av, %av5 40 ; CHECK: %0 = bitcast i64* %c to <2 x i64>* 41 ; CHECK: store <2 x i64> %mul, <2 x i64>* %0, align 8 42 ; CHECK: ret double %r 43 ; CHECK-AO: @test1 44 ; CHECK-AO-NOT: load <2 x 45 } 46 47 ; Simple 3-pair chain with loads and stores (using ptrs and gep) 48 define void @test2(i64** %a, i64** %b, i64** %c) nounwind uwtable readonly { 49 entry: 50 %i0 = load i64** %a, align 8 51 %i1 = load i64** %b, align 8 52 %arrayidx3 = getelementptr inbounds i64** %a, i64 1 53 %i3 = load i64** %arrayidx3, align 8 54 %arrayidx4 = getelementptr inbounds i64** %b, i64 1 55 %i4 = load i64** %arrayidx4, align 8 56 %o1 = load i64* %i1, align 8 57 %o4 = load i64* %i4, align 8 58 %ptr0 = getelementptr inbounds i64* %i0, i64 %o1 59 %ptr3 = getelementptr inbounds i64* %i3, i64 %o4 60 store i64* %ptr0, i64** %c, align 8 61 %arrayidx5 = getelementptr inbounds i64** %c, i64 1 62 store i64* %ptr3, i64** %arrayidx5, align 8 63 ret void 64 ; CHECK: @test2 65 ; CHECK: %i0.v.i0 = bitcast i64** %a to <2 x i64*>* 66 ; CHECK: %i1 = load i64** %b, align 8 67 ; CHECK: %i0 = load <2 x i64*>* %i0.v.i0, align 8 68 ; CHECK: %arrayidx4 = getelementptr inbounds i64** %b, i64 1 69 ; CHECK: %i4 = load i64** %arrayidx4, align 8 70 ; CHECK: %o1 = load i64* %i1, align 8 71 ; CHECK: %o4 = load i64* %i4, align 8 72 ; CHECK: %ptr0.v.i1.1 = insertelement <2 x i64> undef, i64 %o1, i32 0 73 ; CHECK: %ptr0.v.i1.2 = insertelement <2 x i64> %ptr0.v.i1.1, i64 %o4, i32 1 74 ; CHECK: %ptr0 = getelementptr inbounds <2 x i64*> %i0, <2 x i64> %ptr0.v.i1.2 75 ; CHECK: %0 = bitcast i64** %c to <2 x i64*>* 76 ; CHECK: store <2 x i64*> %ptr0, <2 x i64*>* %0, align 8 77 ; CHECK: ret void 78 ; CHECK-AO: @test2 79 ; CHECK-AO-NOT: <2 x 80 } 81 82