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"
      2 ; RUN: opt < %s -bb-vectorize -bb-vectorize-req-chain-depth=3 -bb-vectorize-ignore-target-info -instcombine -gvn -S | FileCheck %s
      3 
      4 ; This test checks the non-trivial pairing-induced cycle avoidance. Without this cycle avoidance, the algorithm would otherwise
      5 ; want to select the pairs:
      6 ; %div77 = fdiv double %sub74, %mul76.v.r1 <->   %div125 = fdiv double %mul121, %mul76.v.r2 (div125 depends on mul117)
      7 ; %add84 = fadd double %sub83, 2.000000e+00 <->   %add127 = fadd double %mul126, 1.000000e+00 (add127 depends on div77)
      8 ; %mul95 = fmul double %sub45.v.r1, %sub36.v.r1 <->   %mul88 = fmul double %sub36.v.r1, %sub87 (mul88 depends on add84)
      9 ; %mul117 = fmul double %sub39.v.r1, %sub116 <->   %mul97 = fmul double %mul96, %sub39.v.r1 (mul97 depends on mul95)
     10 ; and so a dependency cycle would be created.
     11 
     12 declare double @fabs(double) nounwind readnone
     13 define void @test1(double %a, double %b, double %c, double %add80, double %mul1, double %mul2.v.r1, double %mul73, double %sub, double %sub65, double %F.0, i32 %n.0, double %Bnm3.0, double %Bnm2.0, double %Bnm1.0, double %Anm3.0, double %Anm2.0, double %Anm1.0) {
     14 entry:
     15   br label %go
     16 go:
     17   %conv = sitofp i32 %n.0 to double
     18   %add35 = fadd double %conv, %a
     19   %sub36 = fadd double %add35, -1.000000e+00
     20   %add38 = fadd double %conv, %b
     21   %sub39 = fadd double %add38, -1.000000e+00
     22   %add41 = fadd double %conv, %c
     23   %sub42 = fadd double %add41, -1.000000e+00
     24   %sub45 = fadd double %add35, -2.000000e+00
     25   %sub48 = fadd double %add38, -2.000000e+00
     26   %sub51 = fadd double %add41, -2.000000e+00
     27   %mul52 = shl nsw i32 %n.0, 1
     28   %sub53 = add nsw i32 %mul52, -1
     29   %conv54 = sitofp i32 %sub53 to double
     30   %sub56 = add nsw i32 %mul52, -3
     31   %conv57 = sitofp i32 %sub56 to double
     32   %sub59 = add nsw i32 %mul52, -5
     33   %conv60 = sitofp i32 %sub59 to double
     34   %mul61 = mul nsw i32 %n.0, %n.0
     35   %conv62 = sitofp i32 %mul61 to double
     36   %mul63 = fmul double %conv62, 3.000000e+00
     37   %mul67 = fmul double %sub65, %conv
     38   %add68 = fadd double %mul63, %mul67
     39   %add69 = fadd double %add68, 2.000000e+00
     40   %sub71 = fsub double %add69, %mul2.v.r1
     41   %sub74 = fsub double %sub71, %mul73
     42   %mul75 = fmul double %conv57, 2.000000e+00
     43   %mul76 = fmul double %mul75, %sub42
     44   %div77 = fdiv double %sub74, %mul76
     45   %mul82 = fmul double %add80, %conv
     46   %sub83 = fsub double %mul63, %mul82
     47   %add84 = fadd double %sub83, 2.000000e+00
     48   %sub86 = fsub double %add84, %mul2.v.r1
     49   %sub87 = fsub double -0.000000e+00, %sub86
     50   %mul88 = fmul double %sub36, %sub87
     51   %mul89 = fmul double %mul88, %sub39
     52   %mul90 = fmul double %conv54, 4.000000e+00
     53   %mul91 = fmul double %mul90, %conv57
     54   %mul92 = fmul double %mul91, %sub51
     55   %mul93 = fmul double %mul92, %sub42
     56   %div94 = fdiv double %mul89, %mul93
     57   %mul95 = fmul double %sub45, %sub36
     58   %mul96 = fmul double %mul95, %sub48
     59   %mul97 = fmul double %mul96, %sub39
     60   %sub99 = fsub double %conv, %a
     61   %sub100 = fadd double %sub99, -2.000000e+00
     62   %mul101 = fmul double %mul97, %sub100
     63   %sub103 = fsub double %conv, %b
     64   %sub104 = fadd double %sub103, -2.000000e+00
     65   %mul105 = fmul double %mul101, %sub104
     66   %mul106 = fmul double %conv57, 8.000000e+00
     67   %mul107 = fmul double %mul106, %conv57
     68   %mul108 = fmul double %mul107, %conv60
     69   %sub111 = fadd double %add41, -3.000000e+00
     70   %mul112 = fmul double %mul108, %sub111
     71   %mul113 = fmul double %mul112, %sub51
     72   %mul114 = fmul double %mul113, %sub42
     73   %div115 = fdiv double %mul105, %mul114
     74   %sub116 = fsub double -0.000000e+00, %sub36
     75   %mul117 = fmul double %sub39, %sub116
     76   %sub119 = fsub double %conv, %c
     77   %sub120 = fadd double %sub119, -1.000000e+00
     78   %mul121 = fmul double %mul117, %sub120
     79   %mul123 = fmul double %mul75, %sub51
     80   %mul124 = fmul double %mul123, %sub42
     81   %div125 = fdiv double %mul121, %mul124
     82   %mul126 = fmul double %div77, %sub
     83   %add127 = fadd double %mul126, 1.000000e+00
     84   %mul128 = fmul double %add127, %Anm1.0
     85   %mul129 = fmul double %div94, %sub
     86   %add130 = fadd double %div125, %mul129
     87   %mul131 = fmul double %add130, %sub
     88   %mul132 = fmul double %mul131, %Anm2.0
     89   %add133 = fadd double %mul128, %mul132
     90   %mul134 = fmul double %div115, %mul1
     91   %mul135 = fmul double %mul134, %Anm3.0
     92   %add136 = fadd double %add133, %mul135
     93   %mul139 = fmul double %add127, %Bnm1.0
     94   %mul143 = fmul double %mul131, %Bnm2.0
     95   %add144 = fadd double %mul139, %mul143
     96   %mul146 = fmul double %mul134, %Bnm3.0
     97   %add147 = fadd double %add144, %mul146
     98   %div148 = fdiv double %add136, %add147
     99   %sub149 = fsub double %F.0, %div148
    100   %div150 = fdiv double %sub149, %F.0
    101   %call = tail call double @fabs(double %div150) nounwind readnone
    102   %cmp = fcmp olt double %call, 0x3CB0000000000000
    103   %cmp152 = icmp sgt i32 %n.0, 20000
    104   %or.cond = or i1 %cmp, %cmp152
    105   br i1 %or.cond, label %done, label %go
    106 done:
    107   ret void
    108 ; CHECK: @test1
    109 ; CHECK: go:
    110 ; CHECK: %conv.v.i0.1 = insertelement <2 x i32> undef, i32 %n.0, i32 0
    111 ; FIXME: When tree pruning is deterministic, include the entire output.
    112 }
    113