1 ; RUN: opt -S -instcombine < %s | FileCheck %s
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
7 declare double @llvm.fma.f64(double, double, double) #0
8 declare double @llvm.fmuladd.f64(double, double, double) #0
10 declare double @llvm.sqrt.f64(double) #0
13 ; CHECK-LABEL: @constant_fold_fma_f32
14 ; CHECK-NEXT: ret float 6.000000e+00
15 define float @constant_fold_fma_f32() #0 {
16 %x = call float @llvm.fma.f32(float 1.0, float 2.0, float 4.0) #0
20 ; CHECK-LABEL: @constant_fold_fma_v4f32
21 ; CHECK-NEXT: ret <4 x float> <float 1.200000e+01, float 1.400000e+01, float 1.600000e+01, float 1.800000e+01>
22 define <4 x float> @constant_fold_fma_v4f32() #0 {
23 %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>)
27 ; CHECK-LABEL: @constant_fold_fmuladd_f32
28 ; CHECK-NEXT: ret float 6.000000e+00
29 define float @constant_fold_fmuladd_f32() #0 {
30 %x = call float @llvm.fmuladd.f32(float 1.0, float 2.0, float 4.0) #0
34 ; CHECK-LABEL: @constant_fold_fma_f64
35 ; CHECK-NEXT: ret double 6.000000e+00
36 define double @constant_fold_fma_f64() #0 {
37 %x = call double @llvm.fma.f64(double 1.0, double 2.0, double 4.0) #0
41 ; CHECK-LABEL: @constant_fold_fmuladd_f64
42 ; CHECK-NEXT: ret double 6.000000e+00
43 define double @constant_fold_fmuladd_f64() #0 {
44 %x = call double @llvm.fmuladd.f64(double 1.0, double 2.0, double 4.0) #0
50 ; CHECK-LABEL: @constant_fold_frem_f32
51 ; CHECK-NEXT: ret float 0x41A61B2000000000
52 define float @constant_fold_frem_f32() #0 {
53 %x = frem float 0x43cbfcd960000000, 0xc1e2b34a00000000
59 ; CHECK-LABEL: @constant_fold_frem_f64
60 ; CHECK-NEXT: ret double 0.000000e+00
61 define double @constant_fold_frem_f64() {
62 %x = frem double 0x43E0000000000000, 1.000000e+00
66 attributes #0 = { nounwind readnone }