[llvm] [SimplifyLibCalls] Simplify cabs libcall if real or imaginary part of input is zero (PR #97976)

Hendrik Hübner via llvm-commits llvm-commits at lists.llvm.org
Wed Jul 10 02:48:36 PDT 2024


https://github.com/HendrikHuebner updated https://github.com/llvm/llvm-project/pull/97976

>From 3cd945746f29754a6456fa616f7b5c26a71aba79 Mon Sep 17 00:00:00 2001
From: hhuebner <ge84pip at mytum.de>
Date: Mon, 8 Jul 2024 01:33:49 +0200
Subject: [PATCH 1/4] Simplify cabs libcall if real or imaginary part is zero

---
 .../lib/Transforms/Utils/SimplifyLibCalls.cpp | 36 ++++++++++---
 .../Transforms/InstCombine/cabs-discrete.ll   | 54 +++++++++++++++++++
 2 files changed, 83 insertions(+), 7 deletions(-)

diff --git a/llvm/lib/Transforms/Utils/SimplifyLibCalls.cpp b/llvm/lib/Transforms/Utils/SimplifyLibCalls.cpp
index e61440e6e2daf..a2188422cd6f6 100644
--- a/llvm/lib/Transforms/Utils/SimplifyLibCalls.cpp
+++ b/llvm/lib/Transforms/Utils/SimplifyLibCalls.cpp
@@ -27,6 +27,7 @@
 #include "llvm/IR/Intrinsics.h"
 #include "llvm/IR/Module.h"
 #include "llvm/IR/PatternMatch.h"
+#include "llvm/Support/Casting.h"
 #include "llvm/Support/CommandLine.h"
 #include "llvm/Support/KnownBits.h"
 #include "llvm/Support/MathExtras.h"
@@ -1958,25 +1959,46 @@ static Value *optimizeBinaryDoubleFP(CallInst *CI, IRBuilderBase &B,
 
 // cabs(z) -> sqrt((creal(z)*creal(z)) + (cimag(z)*cimag(z)))
 Value *LibCallSimplifier::optimizeCAbs(CallInst *CI, IRBuilderBase &B) {
-  if (!CI->isFast())
-    return nullptr;
-
-  // Propagate fast-math flags from the existing call to new instructions.
-  IRBuilderBase::FastMathFlagGuard Guard(B);
-  B.setFastMathFlags(CI->getFastMathFlags());
-
   Value *Real, *Imag;
+
   if (CI->arg_size() == 1) {
     Value *Op = CI->getArgOperand(0);
     assert(Op->getType()->isArrayTy() && "Unexpected signature for cabs!");
     Real = B.CreateExtractValue(Op, 0, "real");
     Imag = B.CreateExtractValue(Op, 1, "imag");
+
   } else {
     assert(CI->arg_size() == 2 && "Unexpected signature for cabs!");
     Real = CI->getArgOperand(0);
     Imag = CI->getArgOperand(1);
   }
 
+  // if real or imaginary part is zero, simplify to abs(cimag(z))
+  // or abs(creal(z))
+  if (ConstantFP *ConstReal = dyn_cast<ConstantFP>(Real)) {
+    if (ConstReal->isZeroValue()) {
+      IRBuilderBase::FastMathFlagGuard Guard(B);
+      B.setFastMathFlags(CI->getFastMathFlags());
+      
+      return copyFlags(
+          *CI, B.CreateUnaryIntrinsic(Intrinsic::fabs, Imag, nullptr, "cabs"));
+    }
+  } else if (ConstantFP *ConstReal = dyn_cast<ConstantFP>(Imag)) {
+    if (ConstReal->isZeroValue()) {
+      IRBuilderBase::FastMathFlagGuard Guard(B);
+      B.setFastMathFlags(CI->getFastMathFlags());
+      return copyFlags(
+          *CI, B.CreateUnaryIntrinsic(Intrinsic::fabs, Real, nullptr, "cabs"));
+    }
+  }
+
+  if (!CI->isFast())
+    return nullptr;
+
+  // Propagate fast-math flags from the existing call to new instructions.
+  IRBuilderBase::FastMathFlagGuard Guard(B);
+  B.setFastMathFlags(CI->getFastMathFlags());
+
   Value *RealReal = B.CreateFMul(Real, Real);
   Value *ImagImag = B.CreateFMul(Imag, Imag);
 
diff --git a/llvm/test/Transforms/InstCombine/cabs-discrete.ll b/llvm/test/Transforms/InstCombine/cabs-discrete.ll
index 38aaf45e65fa4..7acd5edf61c40 100644
--- a/llvm/test/Transforms/InstCombine/cabs-discrete.ll
+++ b/llvm/test/Transforms/InstCombine/cabs-discrete.ll
@@ -40,6 +40,24 @@ define double @fast_cabs(double %real, double %imag) {
   ret double %call
 }
 
+define double @fast_cabs_zero_real(double %imag) {
+; CHECK-LABEL: @fast_cabs_zero_real(
+; CHECK-NEXT:    [[CABS:%.*]] = tail call double @llvm.fabs.f64(double [[IMAG:%.*]])
+; CHECK-NEXT:    ret double [[CABS]]
+;
+  %call = tail call double @cabs(double 0.0, double %imag)
+  ret double %call
+}
+
+define double @fast_cabs_zero_real(double %real) {
+; CHECK-LABEL: @fast_cabs_zero_real(
+; CHECK-NEXT:    [[CABS:%.*]] = tail call double @llvm.fabs.f64(double [[REAL:%.*]])
+; CHECK-NEXT:    ret double [[CABS]]
+;
+  %call = tail call double @cabs(double %real, 0.0)
+  ret double %call
+}
+
 define float @fast_cabsf(float %real, float %imag) {
 ; CHECK-LABEL: @fast_cabsf(
 ; CHECK-NEXT:    [[TMP1:%.*]] = fmul fast float [[REAL:%.*]], [[REAL]]
@@ -52,6 +70,24 @@ define float @fast_cabsf(float %real, float %imag) {
   ret float %call
 }
 
+define float @fast_cabsf_zero_real(float %imag) {
+; CHECK-LABEL: @fast_cabsf_zero_real(
+; CHECK-NEXT:    [[CABS:%.*]] = tail call float @llvm.fabs.f32(float [[IMAG:%.*]])
+; CHECK-NEXT:    ret float [[CABS]]
+;
+  %call = tail call float @cabsf(float 0.0, float %imag)
+  ret float %call
+}
+
+define float @fast_cabsf_zero_real(float %real) {
+; CHECK-LABEL: @fast_cabsf_zero_real(
+; CHECK-NEXT:    [[CABS:%.*]] = tail call float @llvm.fabs.f64(float [[REAL:%.*]])
+; CHECK-NEXT:    ret float [[CABS]]
+;
+  %call = tail call float @cabsf(float %real, 0.0)
+  ret float %call
+}
+
 define fp128 @fast_cabsl(fp128 %real, fp128 %imag) {
 ; CHECK-LABEL: @fast_cabsl(
 ; CHECK-NEXT:    [[TMP1:%.*]] = fmul fast fp128 [[REAL:%.*]], [[REAL]]
@@ -64,6 +100,24 @@ define fp128 @fast_cabsl(fp128 %real, fp128 %imag) {
   ret fp128 %call
 }
 
+define fp128 @fast_cabsl_zero_real(fp128 %imag) {
+; CHECK-LABEL: @fast_cabsl_zero_real(
+; CHECK-NEXT:    [[CABS:%.*]] = tail call fp128 @llvm.fabsl.f128(fp128 [[IMAG:%.*]])
+; CHECK-NEXT:    ret fp128 [[CABS]]
+;
+  %call = tail call fp128 @cabsl(double 0.0, fp128 %imag)
+  ret fp128 %call
+}
+
+define fp128 @fast_cabsl_zero_real(fp128 %real) {
+; CHECK-LABEL: @fast_cabsl_zero_real(
+; CHECK-NEXT:    [[CABS:%.*]] = tail call fp128 @llvm.fabs.f128(fp128 [[REAL:%.*]])
+; CHECK-NEXT:    ret fp128 [[CABS]]
+;
+  %call = tail call fp128 @cabsl(fp128 %real, 0.0)
+  ret fp128 %call
+}
+
 declare double @cabs(double %real, double %imag)
 declare float @cabsf(float %real, float %imag)
 declare fp128 @cabsl(fp128 %real, fp128 %imag)

>From 29cad74b93d34cf531b5bcf99f8bd930015627ed Mon Sep 17 00:00:00 2001
From: hhuebner <ge84pip at mytum.de>
Date: Mon, 8 Jul 2024 01:51:21 +0200
Subject: [PATCH 2/4] Add more tests

---
 llvm/lib/Transforms/Utils/SimplifyLibCalls.cpp |  1 -
 .../Transforms/InstCombine/cabs-discrete.ll    | 18 +++++++++---------
 2 files changed, 9 insertions(+), 10 deletions(-)

diff --git a/llvm/lib/Transforms/Utils/SimplifyLibCalls.cpp b/llvm/lib/Transforms/Utils/SimplifyLibCalls.cpp
index a2188422cd6f6..12eb8eed50426 100644
--- a/llvm/lib/Transforms/Utils/SimplifyLibCalls.cpp
+++ b/llvm/lib/Transforms/Utils/SimplifyLibCalls.cpp
@@ -1979,7 +1979,6 @@ Value *LibCallSimplifier::optimizeCAbs(CallInst *CI, IRBuilderBase &B) {
     if (ConstReal->isZeroValue()) {
       IRBuilderBase::FastMathFlagGuard Guard(B);
       B.setFastMathFlags(CI->getFastMathFlags());
-      
       return copyFlags(
           *CI, B.CreateUnaryIntrinsic(Intrinsic::fabs, Imag, nullptr, "cabs"));
     }
diff --git a/llvm/test/Transforms/InstCombine/cabs-discrete.ll b/llvm/test/Transforms/InstCombine/cabs-discrete.ll
index 7acd5edf61c40..68b962d90e2bd 100644
--- a/llvm/test/Transforms/InstCombine/cabs-discrete.ll
+++ b/llvm/test/Transforms/InstCombine/cabs-discrete.ll
@@ -49,12 +49,12 @@ define double @fast_cabs_zero_real(double %imag) {
   ret double %call
 }
 
-define double @fast_cabs_zero_real(double %real) {
-; CHECK-LABEL: @fast_cabs_zero_real(
+define double @fast_cabs_zero_imag(double %real) {
+; CHECK-LABEL: @fast_cabs_zero_imag(
 ; CHECK-NEXT:    [[CABS:%.*]] = tail call double @llvm.fabs.f64(double [[REAL:%.*]])
 ; CHECK-NEXT:    ret double [[CABS]]
 ;
-  %call = tail call double @cabs(double %real, 0.0)
+  %call = tail call double @cabs(double %real, double 0.0)
   ret double %call
 }
 
@@ -79,12 +79,12 @@ define float @fast_cabsf_zero_real(float %imag) {
   ret float %call
 }
 
-define float @fast_cabsf_zero_real(float %real) {
-; CHECK-LABEL: @fast_cabsf_zero_real(
+define float @fast_cabsf_zero_imag(float %real) {
+; CHECK-LABEL: @fast_cabsf_zero_imag(
 ; CHECK-NEXT:    [[CABS:%.*]] = tail call float @llvm.fabs.f64(float [[REAL:%.*]])
 ; CHECK-NEXT:    ret float [[CABS]]
 ;
-  %call = tail call float @cabsf(float %real, 0.0)
+  %call = tail call float @cabsf(float %real, float 0.0)
   ret float %call
 }
 
@@ -109,12 +109,12 @@ define fp128 @fast_cabsl_zero_real(fp128 %imag) {
   ret fp128 %call
 }
 
-define fp128 @fast_cabsl_zero_real(fp128 %real) {
-; CHECK-LABEL: @fast_cabsl_zero_real(
+define fp128 @fast_cabsl_zero_imag(fp128 %real) {
+; CHECK-LABEL: @fast_cabsl_zero_imag(
 ; CHECK-NEXT:    [[CABS:%.*]] = tail call fp128 @llvm.fabs.f128(fp128 [[REAL:%.*]])
 ; CHECK-NEXT:    ret fp128 [[CABS]]
 ;
-  %call = tail call fp128 @cabsl(fp128 %real, 0.0)
+  %call = tail call fp128 @cabsl(fp128 %real, fp128 0.0)
   ret fp128 %call
 }
 

>From 7e725db387bc78dddd2830103c08bdc79688ce11 Mon Sep 17 00:00:00 2001
From: hhuebner <ge84pip at mytum.de>
Date: Mon, 8 Jul 2024 22:19:21 +0200
Subject: [PATCH 3/4] Fix tests and handle signed zeros

---
 .../lib/Transforms/Utils/SimplifyLibCalls.cpp | 38 +++++++++++--------
 .../Transforms/InstCombine/cabs-discrete.ll   | 35 +++++++++++++++--
 2 files changed, 54 insertions(+), 19 deletions(-)

diff --git a/llvm/lib/Transforms/Utils/SimplifyLibCalls.cpp b/llvm/lib/Transforms/Utils/SimplifyLibCalls.cpp
index 12eb8eed50426..89c8c5bf08954 100644
--- a/llvm/lib/Transforms/Utils/SimplifyLibCalls.cpp
+++ b/llvm/lib/Transforms/Utils/SimplifyLibCalls.cpp
@@ -1962,37 +1962,45 @@ Value *LibCallSimplifier::optimizeCAbs(CallInst *CI, IRBuilderBase &B) {
   Value *Real, *Imag;
 
   if (CI->arg_size() == 1) {
+
+    if (!CI->isFast())
+      return nullptr;
+
     Value *Op = CI->getArgOperand(0);
     assert(Op->getType()->isArrayTy() && "Unexpected signature for cabs!");
+
     Real = B.CreateExtractValue(Op, 0, "real");
     Imag = B.CreateExtractValue(Op, 1, "imag");
 
   } else {
     assert(CI->arg_size() == 2 && "Unexpected signature for cabs!");
+
     Real = CI->getArgOperand(0);
     Imag = CI->getArgOperand(1);
-  }
 
-  // if real or imaginary part is zero, simplify to abs(cimag(z))
-  // or abs(creal(z))
-  if (ConstantFP *ConstReal = dyn_cast<ConstantFP>(Real)) {
-    if (ConstReal->isZeroValue()) {
-      IRBuilderBase::FastMathFlagGuard Guard(B);
-      B.setFastMathFlags(CI->getFastMathFlags());
-      return copyFlags(
-          *CI, B.CreateUnaryIntrinsic(Intrinsic::fabs, Imag, nullptr, "cabs"));
+    // if real or imaginary part is zero, simplify to abs(cimag(z))
+    // or abs(creal(z))
+    Value *AbsOp = nullptr;
+    if (ConstantFP *ConstReal = dyn_cast<ConstantFP>(Real)) {
+      if (ConstReal->isZero())
+        AbsOp = Imag;
+
+    } else if (ConstantFP *ConstImag = dyn_cast<ConstantFP>(Imag)) {
+      if (ConstImag->isZero())
+        AbsOp = Real;
     }
-  } else if (ConstantFP *ConstReal = dyn_cast<ConstantFP>(Imag)) {
-    if (ConstReal->isZeroValue()) {
+
+    if (AbsOp) {
       IRBuilderBase::FastMathFlagGuard Guard(B);
       B.setFastMathFlags(CI->getFastMathFlags());
+
       return copyFlags(
-          *CI, B.CreateUnaryIntrinsic(Intrinsic::fabs, Real, nullptr, "cabs"));
+          *CI, B.CreateUnaryIntrinsic(Intrinsic::fabs, AbsOp, nullptr, "cabs"));
     }
-  }
 
-  if (!CI->isFast())
-    return nullptr;
+    if (!CI->isFast())
+      return nullptr;
+  }
 
   // Propagate fast-math flags from the existing call to new instructions.
   IRBuilderBase::FastMathFlagGuard Guard(B);
diff --git a/llvm/test/Transforms/InstCombine/cabs-discrete.ll b/llvm/test/Transforms/InstCombine/cabs-discrete.ll
index 68b962d90e2bd..9d56598cb123a 100644
--- a/llvm/test/Transforms/InstCombine/cabs-discrete.ll
+++ b/llvm/test/Transforms/InstCombine/cabs-discrete.ll
@@ -49,6 +49,15 @@ define double @fast_cabs_zero_real(double %imag) {
   ret double %call
 }
 
+define double @fast_cabs_neg_zero_real(double %imag) {
+; CHECK-LABEL: @fast_cabs_neg_zero_real(
+; CHECK-NEXT:    [[CABS:%.*]] = tail call double @llvm.fabs.f64(double [[IMAG:%.*]])
+; CHECK-NEXT:    ret double [[CABS]]
+;
+  %call = tail call double @cabs(double -0.0, double %imag)
+  ret double %call
+}
+
 define double @fast_cabs_zero_imag(double %real) {
 ; CHECK-LABEL: @fast_cabs_zero_imag(
 ; CHECK-NEXT:    [[CABS:%.*]] = tail call double @llvm.fabs.f64(double [[REAL:%.*]])
@@ -79,9 +88,18 @@ define float @fast_cabsf_zero_real(float %imag) {
   ret float %call
 }
 
+define float @fast_cabsf_neg_zero_real(float %imag) {
+; CHECK-LABEL: @fast_cabsf_neg_zero_real(
+; CHECK-NEXT:    [[CABS:%.*]] = tail call float @llvm.fabs.f32(float [[IMAG:%.*]])
+; CHECK-NEXT:    ret float [[CABS]]
+;
+  %call = tail call float @cabsf(float -0.0, float %imag)
+  ret float %call
+}
+
 define float @fast_cabsf_zero_imag(float %real) {
 ; CHECK-LABEL: @fast_cabsf_zero_imag(
-; CHECK-NEXT:    [[CABS:%.*]] = tail call float @llvm.fabs.f64(float [[REAL:%.*]])
+; CHECK-NEXT:    [[CABS:%.*]] = tail call float @llvm.fabs.f32(float [[REAL:%.*]])
 ; CHECK-NEXT:    ret float [[CABS]]
 ;
   %call = tail call float @cabsf(float %real, float 0.0)
@@ -102,10 +120,10 @@ define fp128 @fast_cabsl(fp128 %real, fp128 %imag) {
 
 define fp128 @fast_cabsl_zero_real(fp128 %imag) {
 ; CHECK-LABEL: @fast_cabsl_zero_real(
-; CHECK-NEXT:    [[CABS:%.*]] = tail call fp128 @llvm.fabsl.f128(fp128 [[IMAG:%.*]])
+; CHECK-NEXT:    [[CABS:%.*]] = tail call fp128 @llvm.fabs.f128(fp128 [[IMAG:%.*]])
 ; CHECK-NEXT:    ret fp128 [[CABS]]
 ;
-  %call = tail call fp128 @cabsl(double 0.0, fp128 %imag)
+  %call = tail call fp128 @cabsl(fp128 0xL00000000000000000000000000000000, fp128 %imag)
   ret fp128 %call
 }
 
@@ -114,7 +132,16 @@ define fp128 @fast_cabsl_zero_imag(fp128 %real) {
 ; CHECK-NEXT:    [[CABS:%.*]] = tail call fp128 @llvm.fabs.f128(fp128 [[REAL:%.*]])
 ; CHECK-NEXT:    ret fp128 [[CABS]]
 ;
-  %call = tail call fp128 @cabsl(fp128 %real, fp128 0.0)
+  %call = tail call fp128 @cabsl(fp128 %real, fp128 0xL00000000000000000000000000000000)
+  ret fp128 %call
+}
+
+define fp128 @fast_cabsl_neg_zero_imag(fp128 %real) {
+; CHECK-LABEL: @fast_cabsl_neg_zero_imag(
+; CHECK-NEXT:    [[CABS:%.*]] = tail call fp128 @llvm.fabs.f128(fp128 [[REAL:%.*]])
+; CHECK-NEXT:    ret fp128 [[CABS]]
+;
+  %call = tail call fp128 @cabsl(fp128 %real, fp128 0xL80000000000000000000000000000000)
   ret fp128 %call
 }
 

>From f8e7763cec5b525b3921a61d11be40d922ac5713 Mon Sep 17 00:00:00 2001
From: hhuebner <ge84pip at mytum.de>
Date: Wed, 10 Jul 2024 11:47:41 +0200
Subject: [PATCH 4/4] Fix fp128 signed zero literal

---
 .../Transforms/InstCombine/cabs-discrete.ll   | 36 +++++++++----------
 1 file changed, 18 insertions(+), 18 deletions(-)

diff --git a/llvm/test/Transforms/InstCombine/cabs-discrete.ll b/llvm/test/Transforms/InstCombine/cabs-discrete.ll
index 9d56598cb123a..2e28ec9eb2ef8 100644
--- a/llvm/test/Transforms/InstCombine/cabs-discrete.ll
+++ b/llvm/test/Transforms/InstCombine/cabs-discrete.ll
@@ -40,8 +40,8 @@ define double @fast_cabs(double %real, double %imag) {
   ret double %call
 }
 
-define double @fast_cabs_zero_real(double %imag) {
-; CHECK-LABEL: @fast_cabs_zero_real(
+define double @cabs_zero_real(double %imag) {
+; CHECK-LABEL: @cabs_zero_real(
 ; CHECK-NEXT:    [[CABS:%.*]] = tail call double @llvm.fabs.f64(double [[IMAG:%.*]])
 ; CHECK-NEXT:    ret double [[CABS]]
 ;
@@ -51,15 +51,15 @@ define double @fast_cabs_zero_real(double %imag) {
 
 define double @fast_cabs_neg_zero_real(double %imag) {
 ; CHECK-LABEL: @fast_cabs_neg_zero_real(
-; CHECK-NEXT:    [[CABS:%.*]] = tail call double @llvm.fabs.f64(double [[IMAG:%.*]])
+; CHECK-NEXT:    [[CABS:%.*]] = tail call fast double @llvm.fabs.f64(double [[IMAG:%.*]])
 ; CHECK-NEXT:    ret double [[CABS]]
 ;
-  %call = tail call double @cabs(double -0.0, double %imag)
+  %call = tail call fast double @cabs(double -0.0, double %imag)
   ret double %call
 }
 
-define double @fast_cabs_zero_imag(double %real) {
-; CHECK-LABEL: @fast_cabs_zero_imag(
+define double @cabs_zero_imag(double %real) {
+; CHECK-LABEL: @cabs_zero_imag(
 ; CHECK-NEXT:    [[CABS:%.*]] = tail call double @llvm.fabs.f64(double [[REAL:%.*]])
 ; CHECK-NEXT:    ret double [[CABS]]
 ;
@@ -79,8 +79,8 @@ define float @fast_cabsf(float %real, float %imag) {
   ret float %call
 }
 
-define float @fast_cabsf_zero_real(float %imag) {
-; CHECK-LABEL: @fast_cabsf_zero_real(
+define float @cabsf_zero_real(float %imag) {
+; CHECK-LABEL: @cabsf_zero_real(
 ; CHECK-NEXT:    [[CABS:%.*]] = tail call float @llvm.fabs.f32(float [[IMAG:%.*]])
 ; CHECK-NEXT:    ret float [[CABS]]
 ;
@@ -90,15 +90,15 @@ define float @fast_cabsf_zero_real(float %imag) {
 
 define float @fast_cabsf_neg_zero_real(float %imag) {
 ; CHECK-LABEL: @fast_cabsf_neg_zero_real(
-; CHECK-NEXT:    [[CABS:%.*]] = tail call float @llvm.fabs.f32(float [[IMAG:%.*]])
+; CHECK-NEXT:    [[CABS:%.*]] = tail call fast float @llvm.fabs.f32(float [[IMAG:%.*]])
 ; CHECK-NEXT:    ret float [[CABS]]
 ;
-  %call = tail call float @cabsf(float -0.0, float %imag)
+  %call = tail call fast float @cabsf(float -0.0, float %imag)
   ret float %call
 }
 
-define float @fast_cabsf_zero_imag(float %real) {
-; CHECK-LABEL: @fast_cabsf_zero_imag(
+define float @cabsf_zero_imag(float %real) {
+; CHECK-LABEL: @cabsf_zero_imag(
 ; CHECK-NEXT:    [[CABS:%.*]] = tail call float @llvm.fabs.f32(float [[REAL:%.*]])
 ; CHECK-NEXT:    ret float [[CABS]]
 ;
@@ -118,8 +118,8 @@ define fp128 @fast_cabsl(fp128 %real, fp128 %imag) {
   ret fp128 %call
 }
 
-define fp128 @fast_cabsl_zero_real(fp128 %imag) {
-; CHECK-LABEL: @fast_cabsl_zero_real(
+define fp128 @cabsl_zero_real(fp128 %imag) {
+; CHECK-LABEL: @cabsl_zero_real(
 ; CHECK-NEXT:    [[CABS:%.*]] = tail call fp128 @llvm.fabs.f128(fp128 [[IMAG:%.*]])
 ; CHECK-NEXT:    ret fp128 [[CABS]]
 ;
@@ -127,8 +127,8 @@ define fp128 @fast_cabsl_zero_real(fp128 %imag) {
   ret fp128 %call
 }
 
-define fp128 @fast_cabsl_zero_imag(fp128 %real) {
-; CHECK-LABEL: @fast_cabsl_zero_imag(
+define fp128 @cabsl_zero_imag(fp128 %real) {
+; CHECK-LABEL: @cabsl_zero_imag(
 ; CHECK-NEXT:    [[CABS:%.*]] = tail call fp128 @llvm.fabs.f128(fp128 [[REAL:%.*]])
 ; CHECK-NEXT:    ret fp128 [[CABS]]
 ;
@@ -138,10 +138,10 @@ define fp128 @fast_cabsl_zero_imag(fp128 %real) {
 
 define fp128 @fast_cabsl_neg_zero_imag(fp128 %real) {
 ; CHECK-LABEL: @fast_cabsl_neg_zero_imag(
-; CHECK-NEXT:    [[CABS:%.*]] = tail call fp128 @llvm.fabs.f128(fp128 [[REAL:%.*]])
+; CHECK-NEXT:    [[CABS:%.*]] = tail call fast fp128 @llvm.fabs.f128(fp128 [[REAL:%.*]])
 ; CHECK-NEXT:    ret fp128 [[CABS]]
 ;
-  %call = tail call fp128 @cabsl(fp128 %real, fp128 0xL80000000000000000000000000000000)
+  %call = tail call fast fp128 @cabsl(fp128 %real, fp128 0xL00000000000000008000000000000000)
   ret fp128 %call
 }
 



More information about the llvm-commits mailing list