Handle vlas during inline cost computation if they'll be turned
[oota-llvm.git] / test / Transforms / InstCombine / constant-fold-math.ll
1 ; RUN: opt -S -instcombine < %s | FileCheck %s
2
3 declare float @llvm.fma.f32(float, float, float) #0
4 declare float @llvm.fmuladd.f32(float, float, float) #0
5 declare <4 x float> @llvm.fma.v4f32(<4 x float>, <4 x float>, <4 x float>) #0
6
7 declare double @llvm.fma.f64(double, double, double) #0
8 declare double @llvm.fmuladd.f64(double, double, double) #0
9
10
11
12 ; CHECK-LABEL: @constant_fold_fma_f32
13 ; CHECK-NEXT: ret float 6.000000e+00
14 define float @constant_fold_fma_f32() #0 {
15   %x = call float @llvm.fma.f32(float 1.0, float 2.0, float 4.0) #0
16   ret float %x
17 }
18
19 ; CHECK-LABEL: @constant_fold_fma_v4f32
20 ; CHECK-NEXT: ret <4 x float> <float 1.200000e+01, float 1.400000e+01, float 1.600000e+01, float 1.800000e+01>
21 define <4 x float> @constant_fold_fma_v4f32() #0 {
22   %x = call <4 x float> @llvm.fma.v4f32(<4 x float> <float 1.0, float 2.0, float 3.0, float 4.0>, <4 x float> <float 2.0, float 2.0, float 2.0, float 2.0>, <4 x float> <float 10.0, float 10.0, float 10.0, float 10.0>)
23   ret <4 x float> %x
24 }
25
26 ; CHECK-LABEL: @constant_fold_fmuladd_f32
27 ; CHECK-NEXT: ret float 6.000000e+00
28 define float @constant_fold_fmuladd_f32() #0 {
29   %x = call float @llvm.fmuladd.f32(float 1.0, float 2.0, float 4.0) #0
30   ret float %x
31 }
32
33 ; CHECK-LABEL: @constant_fold_fma_f64
34 ; CHECK-NEXT: ret double 6.000000e+00
35 define double @constant_fold_fma_f64() #0 {
36   %x = call double @llvm.fma.f64(double 1.0, double 2.0, double 4.0) #0
37   ret double %x
38 }
39
40 ; CHECK-LABEL: @constant_fold_fmuladd_f64
41 ; CHECK-NEXT: ret double 6.000000e+00
42 define double @constant_fold_fmuladd_f64() #0 {
43   %x = call double @llvm.fmuladd.f64(double 1.0, double 2.0, double 4.0) #0
44   ret double %x
45 }
46
47 attributes #0 = { nounwind readnone }