[PATCH] D104479: [PartiallyInlineLibCalls] Disable sqrt expansion for strictfp.

Craig Topper via Phabricator via llvm-commits llvm-commits at lists.llvm.org
Thu Jun 17 11:34:42 PDT 2021


craig.topper created this revision.
craig.topper added reviewers: andrew.w.kaylor, kpn, pengfei.
Herald added a subscriber: hiraditya.
craig.topper requested review of this revision.
Herald added a project: LLVM.

This pass emits a floating point compare and a conditional branch,
but if strictfp is enabled we don't emit a constrained compare
intrinsic. Fix this by disabling the pass.


Repository:
  rG LLVM Github Monorepo

https://reviews.llvm.org/D104479

Files:
  llvm/lib/Transforms/Scalar/PartiallyInlineLibCalls.cpp
  llvm/test/Transforms/PartiallyInlineLibCalls/strictfp.ll


Index: llvm/test/Transforms/PartiallyInlineLibCalls/strictfp.ll
===================================================================
--- /dev/null
+++ llvm/test/Transforms/PartiallyInlineLibCalls/strictfp.ll
@@ -0,0 +1,12 @@
+; RUN: opt -S -partially-inline-libcalls -mtriple=x86_64-unknown-linux-gnu < %s | FileCheck %s
+; RUN: opt -S -passes=partially-inline-libcalls -mtriple=x86_64-unknown-linux-gnu < %s | FileCheck %s
+
+define float @f(float %val) {
+; CHECK-LABEL: @f
+; CHECK: call{{.*}}@sqrtf
+; CHECK-NOT: call{{.*}}@sqrtf
+  %res = tail call float @sqrtf(float %val) strictfp
+  ret float %res
+}
+
+declare float @sqrtf(float)
Index: llvm/lib/Transforms/Scalar/PartiallyInlineLibCalls.cpp
===================================================================
--- llvm/lib/Transforms/Scalar/PartiallyInlineLibCalls.cpp
+++ llvm/lib/Transforms/Scalar/PartiallyInlineLibCalls.cpp
@@ -121,7 +121,7 @@
       if (!Call || !(CalledFunc = Call->getCalledFunction()))
         continue;
 
-      if (Call->isNoBuiltin())
+      if (Call->isNoBuiltin() || Call->isStrictFP())
         continue;
 
       // Skip if function either has local linkage or is not a known library


-------------- next part --------------
A non-text attachment was scrubbed...
Name: D104479.352807.patch
Type: text/x-patch
Size: 1176 bytes
Desc: not available
URL: <http://lists.llvm.org/pipermail/llvm-commits/attachments/20210617/68263f5a/attachment.bin>


More information about the llvm-commits mailing list