[llvm] [InstCombine] Fold more 'fcmp' 'select' instrs idioms into 'fabs' (PR #83381)
Yashwant Singh via llvm-commits
llvm-commits at lists.llvm.org
Mon Mar 18 00:00:44 PDT 2024
yashssh wrote:
Thanks for the example @andykaylor!
I tried a change that sets `fast` flag on `phi` nodes created by SROA
```
diff --git a/llvm/lib/Transforms/Utils/PromoteMemoryToRegister.cpp b/llvm/lib/Transforms/Utils/PromoteMemoryToRegister.cpp
index 88b05aab8db4..1d85c7e0d8a6 100644
--- a/llvm/lib/Transforms/Utils/PromoteMemoryToRegister.cpp
+++ b/llvm/lib/Transforms/Utils/PromoteMemoryToRegister.cpp
@@ -1056,6 +1056,22 @@ bool PromoteMem2Reg::QueuePhiNode(BasicBlock *BB, unsigned AllocaNo,
// BasicBlock.
PN = PHINode::Create(Allocas[AllocaNo]->getAllocatedType(), getNumPreds(BB),
Allocas[AllocaNo]->getName() + "." + Twine(Version++));
+
+ if(BB->getParent()->hasFnAttribute("unsafe-fp-math")){
+ PN->setFast(true);
+ }
+
PN->insertBefore(BB->begin());
++NumPHIInsert;
PhiToAllocaMap[PN] = AllocaNo;
```
Is this the direction you were hinting towards?
https://github.com/llvm/llvm-project/pull/83381
More information about the llvm-commits
mailing list