Home | History | Annotate | Download | only in BBVectorize
      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 target triple = "x86_64-unknown-linux-gnu"
      3 ; RUN: opt < %s -bb-vectorize -bb-vectorize-req-chain-depth=3 -bb-vectorize-ignore-target-info -instcombine -gvn -S | FileCheck %s
      4 ; RUN: opt < %s -basicaa -loop-unroll -unroll-threshold=45 -unroll-allow-partial -bb-vectorize -bb-vectorize-req-chain-depth=3 -bb-vectorize-ignore-target-info -instcombine -gvn -S | FileCheck %s -check-prefix=CHECK-UNRL
      5 ; The second check covers the use of alias analysis (with loop unrolling).
      6 
      7 define void @test1(double* noalias %out, double* noalias %in1, double* noalias %in2) nounwind uwtable {
      8 entry:
      9   br label %for.body
     10 ; CHECK: @test1
     11 ; CHECK-UNRL: @test1
     12 
     13 for.body:                                         ; preds = %for.body, %entry
     14   %indvars.iv = phi i64 [ 0, %entry ], [ %indvars.iv.next, %for.body ]
     15   %arrayidx = getelementptr inbounds double* %in1, i64 %indvars.iv
     16   %0 = load double* %arrayidx, align 8
     17   %arrayidx2 = getelementptr inbounds double* %in2, i64 %indvars.iv
     18   %1 = load double* %arrayidx2, align 8
     19   %mul = fmul double %0, %0
     20   %mul3 = fmul double %0, %1
     21   %add = fadd double %mul, %mul3
     22   %add4 = fadd double %1, %1
     23   %add5 = fadd double %add4, %0
     24   %mul6 = fmul double %0, %add5
     25   %add7 = fadd double %add, %mul6
     26   %mul8 = fmul double %1, %1
     27   %add9 = fadd double %0, %0
     28   %add10 = fadd double %add9, %0
     29   %mul11 = fmul double %mul8, %add10
     30   %add12 = fadd double %add7, %mul11
     31   %arrayidx14 = getelementptr inbounds double* %out, i64 %indvars.iv
     32   store double %add12, double* %arrayidx14, align 8
     33   %indvars.iv.next = add i64 %indvars.iv, 1
     34   %lftr.wideiv = trunc i64 %indvars.iv.next to i32
     35   %exitcond = icmp eq i32 %lftr.wideiv, 10
     36   br i1 %exitcond, label %for.end, label %for.body
     37 ; CHECK: %indvars.iv = phi i64 [ 0, %entry ], [ %indvars.iv.next, %for.body ]
     38 ; CHECK: %arrayidx = getelementptr inbounds double* %in1, i64 %indvars.iv
     39 ; CHECK: %0 = load double* %arrayidx, align 8
     40 ; CHECK: %arrayidx2 = getelementptr inbounds double* %in2, i64 %indvars.iv
     41 ; CHECK: %1 = load double* %arrayidx2, align 8
     42 ; CHECK: %mul = fmul double %0, %0
     43 ; CHECK: %mul3 = fmul double %0, %1
     44 ; CHECK: %add = fadd double %mul, %mul3
     45 ; CHECK: %mul8 = fmul double %1, %1
     46 ; CHECK: %add4.v.i1.1 = insertelement <2 x double> undef, double %1, i32 0
     47 ; CHECK: %add4.v.i1.2 = insertelement <2 x double> %add4.v.i1.1, double %0, i32 1
     48 ; CHECK: %add4 = fadd <2 x double> %add4.v.i1.2, %add4.v.i1.2
     49 ; CHECK: %add5.v.i1.1 = insertelement <2 x double> undef, double %0, i32 0
     50 ; CHECK: %add5.v.i1.2 = insertelement <2 x double> %add5.v.i1.1, double %0, i32 1
     51 ; CHECK: %add5 = fadd <2 x double> %add4, %add5.v.i1.2
     52 ; CHECK: %mul6.v.i0.2 = insertelement <2 x double> %add5.v.i1.1, double %mul8, i32 1
     53 ; CHECK: %mul6 = fmul <2 x double> %mul6.v.i0.2, %add5
     54 ; CHECK: %mul6.v.r1 = extractelement <2 x double> %mul6, i32 0
     55 ; CHECK: %mul6.v.r2 = extractelement <2 x double> %mul6, i32 1
     56 ; CHECK: %add7 = fadd double %add, %mul6.v.r1
     57 ; CHECK: %add12 = fadd double %add7, %mul6.v.r2
     58 ; CHECK: %arrayidx14 = getelementptr inbounds double* %out, i64 %indvars.iv
     59 ; CHECK: store double %add12, double* %arrayidx14, align 8
     60 ; CHECK: %indvars.iv.next = add i64 %indvars.iv, 1
     61 ; CHECK: %lftr.wideiv = trunc i64 %indvars.iv.next to i32
     62 ; CHECK: %exitcond = icmp eq i32 %lftr.wideiv, 10
     63 ; CHECK: br i1 %exitcond, label %for.end, label %for.body
     64 ; CHECK-UNRL: %indvars.iv = phi i64 [ 0, %entry ], [ %indvars.iv.next.1, %for.body ]
     65 ; CHECK-UNRL: %arrayidx = getelementptr inbounds double* %in1, i64 %indvars.iv
     66 ; CHECK-UNRL: %0 = bitcast double* %arrayidx to <2 x double>*
     67 ; CHECK-UNRL: %arrayidx2 = getelementptr inbounds double* %in2, i64 %indvars.iv
     68 ; CHECK-UNRL: %1 = bitcast double* %arrayidx2 to <2 x double>*
     69 ; CHECK-UNRL: %arrayidx14 = getelementptr inbounds double* %out, i64 %indvars.iv
     70 ; CHECK-UNRL: %2 = load <2 x double>* %0, align 8
     71 ; CHECK-UNRL: %3 = load <2 x double>* %1, align 8
     72 ; CHECK-UNRL: %mul = fmul <2 x double> %2, %2
     73 ; CHECK-UNRL: %mul3 = fmul <2 x double> %2, %3
     74 ; CHECK-UNRL: %add = fadd <2 x double> %mul, %mul3
     75 ; CHECK-UNRL: %add4 = fadd <2 x double> %3, %3
     76 ; CHECK-UNRL: %add5 = fadd <2 x double> %add4, %2
     77 ; CHECK-UNRL: %mul6 = fmul <2 x double> %2, %add5
     78 ; CHECK-UNRL: %add7 = fadd <2 x double> %add, %mul6
     79 ; CHECK-UNRL: %mul8 = fmul <2 x double> %3, %3
     80 ; CHECK-UNRL: %add9 = fadd <2 x double> %2, %2
     81 ; CHECK-UNRL: %add10 = fadd <2 x double> %add9, %2
     82 ; CHECK-UNRL: %mul11 = fmul <2 x double> %mul8, %add10
     83 ; CHECK-UNRL: %add12 = fadd <2 x double> %add7, %mul11
     84 ; CHECK-UNRL: %4 = bitcast double* %arrayidx14 to <2 x double>*
     85 ; CHECK-UNRL: store <2 x double> %add12, <2 x double>* %4, align 8
     86 ; CHECK-UNRL: %indvars.iv.next.1 = add i64 %indvars.iv, 2
     87 ; CHECK-UNRL: %lftr.wideiv.1 = trunc i64 %indvars.iv.next.1 to i32
     88 ; CHECK-UNRL: %exitcond.1 = icmp eq i32 %lftr.wideiv.1, 10
     89 ; CHECK-UNRL: br i1 %exitcond.1, label %for.end, label %for.body
     90 
     91 for.end:                                          ; preds = %for.body
     92   ret void
     93 }
     94