diff options
author | Matt Arsenault <Matthew.Arsenault@amd.com> | 2014-03-05 00:02:00 +0000 |
---|---|---|
committer | Matt Arsenault <Matthew.Arsenault@amd.com> | 2014-03-05 00:02:00 +0000 |
commit | 34fae3adef064533271387aed32b2b1ccfa6d6cf (patch) | |
tree | 66db2a7818cadddadd28a8429f7cd1a8bdea374f /test | |
parent | 175c634d88e260f378e97ce5fc7b2010a6255a94 (diff) | |
download | llvm-34fae3adef064533271387aed32b2b1ccfa6d6cf.tar.gz llvm-34fae3adef064533271387aed32b2b1ccfa6d6cf.tar.bz2 llvm-34fae3adef064533271387aed32b2b1ccfa6d6cf.tar.xz |
Allow constant folding of fma and fmuladd
git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@202914 91177308-0d34-0410-b5e6-96231b3b80d8
Diffstat (limited to 'test')
-rw-r--r-- | test/Transforms/InstCombine/constant-fold-math.ll | 39 |
1 files changed, 39 insertions, 0 deletions
diff --git a/test/Transforms/InstCombine/constant-fold-math.ll b/test/Transforms/InstCombine/constant-fold-math.ll new file mode 100644 index 0000000000..00fceb1915 --- /dev/null +++ b/test/Transforms/InstCombine/constant-fold-math.ll @@ -0,0 +1,39 @@ +; RUN: opt -S -instcombine < %s | FileCheck %s + +declare float @llvm.fma.f32(float, float, float) #0 +declare float @llvm.fmuladd.f32(float, float, float) #0 + +declare double @llvm.fma.f64(double, double, double) #0 +declare double @llvm.fmuladd.f64(double, double, double) #0 + + + +; CHECK-LABEL: @constant_fold_fma_f32 +; CHECK-NEXT: ret float 6.000000e+00 +define float @constant_fold_fma_f32() #0 { + %x = call float @llvm.fma.f32(float 1.0, float 2.0, float 4.0) #0 + ret float %x +} + +; CHECK-LABEL: @constant_fold_fmuladd_f32 +; CHECK-NEXT: ret float 6.000000e+00 +define float @constant_fold_fmuladd_f32() #0 { + %x = call float @llvm.fmuladd.f32(float 1.0, float 2.0, float 4.0) #0 + ret float %x +} + +; CHECK-LABEL: @constant_fold_fma_f64 +; CHECK-NEXT: ret double 6.000000e+00 +define double @constant_fold_fma_f64() #0 { + %x = call double @llvm.fma.f64(double 1.0, double 2.0, double 4.0) #0 + ret double %x +} + +; CHECK-LABEL: @constant_fold_fmuladd_f64 +; CHECK-NEXT: ret double 6.000000e+00 +define double @constant_fold_fmuladd_f64() #0 { + %x = call double @llvm.fmuladd.f64(double 1.0, double 2.0, double 4.0) #0 + ret double %x +} + +attributes #0 = { nounwind readnone } |