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