Home | History | Annotate | Download | only in X86
      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 -mtriple=x86_64-unknown-linux-gnu -mcpu=corei7 -bb-vectorize -bb-vectorize-req-chain-depth=3 -instcombine -gvn -S | FileCheck %s
      3 
      4 declare double @llvm.fma.f64(double, double, double)
      5 declare double @llvm.fmuladd.f64(double, double, double)
      6 declare double @llvm.cos.f64(double)
      7 declare double @llvm.powi.f64(double, i32)
      8 
      9 ; Basic depth-3 chain with fma
     10 define double @test1(double %A1, double %A2, double %B1, double %B2, double %C1, double %C2) {
     11 	%X1 = fsub double %A1, %B1
     12 	%X2 = fsub double %A2, %B2
     13 	%Y1 = call double @llvm.fma.f64(double %X1, double %A1, double %C1)
     14 	%Y2 = call double @llvm.fma.f64(double %X2, double %A2, double %C2)
     15 	%Z1 = fadd double %Y1, %B1
     16 	%Z2 = fadd double %Y2, %B2
     17 	%R  = fmul double %Z1, %Z2
     18 	ret double %R
     19 ; CHECK-LABEL: @test1(
     20 ; CHECK: ret double %R
     21 }
     22 
     23 ; Basic depth-3 chain with fmuladd
     24 define double @test1a(double %A1, double %A2, double %B1, double %B2, double %C1, double %C2) {
     25 	%X1 = fsub double %A1, %B1
     26 	%X2 = fsub double %A2, %B2
     27 	%Y1 = call double @llvm.fmuladd.f64(double %X1, double %A1, double %C1)
     28 	%Y2 = call double @llvm.fmuladd.f64(double %X2, double %A2, double %C2)
     29 	%Z1 = fadd double %Y1, %B1
     30 	%Z2 = fadd double %Y2, %B2
     31 	%R  = fmul double %Z1, %Z2
     32 	ret double %R
     33 ; CHECK-LABEL: @test1a(
     34 ; CHECK: ret double %R
     35 }
     36 
     37 ; Basic depth-3 chain with cos
     38 define double @test2(double %A1, double %A2, double %B1, double %B2) {
     39 	%X1 = fsub double %A1, %B1
     40 	%X2 = fsub double %A2, %B2
     41 	%Y1 = call double @llvm.cos.f64(double %X1)
     42 	%Y2 = call double @llvm.cos.f64(double %X2)
     43 	%Z1 = fadd double %Y1, %B1
     44 	%Z2 = fadd double %Y2, %B2
     45 	%R  = fmul double %Z1, %Z2
     46 	ret double %R
     47 ; CHECK-LABEL: @test2(
     48 ; CHECK: ret double %R
     49 }
     50 
     51 ; Basic depth-3 chain with powi
     52 define double @test3(double %A1, double %A2, double %B1, double %B2, i32 %P) {
     53 	%X1 = fsub double %A1, %B1
     54 	%X2 = fsub double %A2, %B2
     55 	%Y1 = call double @llvm.powi.f64(double %X1, i32 %P)
     56 	%Y2 = call double @llvm.powi.f64(double %X2, i32 %P)
     57 	%Z1 = fadd double %Y1, %B1
     58 	%Z2 = fadd double %Y2, %B2
     59 	%R  = fmul double %Z1, %Z2
     60 	ret double %R
     61 ; CHECK-LABEL: @test3(
     62 ; CHECK: ret double %R
     63 }
     64 
     65 ; Basic depth-3 chain with powi (different powers: should not vectorize)
     66 define double @test4(double %A1, double %A2, double %B1, double %B2, i32 %P) {
     67 	%X1 = fsub double %A1, %B1
     68 	%X2 = fsub double %A2, %B2
     69         %P2 = add i32 %P, 1
     70 	%Y1 = call double @llvm.powi.f64(double %X1, i32 %P)
     71 	%Y2 = call double @llvm.powi.f64(double %X2, i32 %P2)
     72 	%Z1 = fadd double %Y1, %B1
     73 	%Z2 = fadd double %Y2, %B2
     74 	%R  = fmul double %Z1, %Z2
     75 	ret double %R
     76 ; CHECK-LABEL: @test4(
     77 ; CHECK: ret double %R
     78 }
     79 
     80