[PATCH] D95455: [InstCombine] Preserve FMF for powi simplifications.
Valeriy Dmitriev via Phabricator via llvm-commits
llvm-commits at lists.llvm.org
Tue Jan 26 11:11:22 PST 2021
vdmitrie updated this revision to Diff 319358.
Repository:
rG LLVM Github Monorepo
CHANGES SINCE LAST ACTION
https://reviews.llvm.org/D95455/new/
https://reviews.llvm.org/D95455
Files:
llvm/lib/Transforms/InstCombine/InstCombineCalls.cpp
llvm/test/Transforms/InstCombine/intrinsics.ll
Index: llvm/test/Transforms/InstCombine/intrinsics.ll
===================================================================
--- llvm/test/Transforms/InstCombine/intrinsics.ll
+++ llvm/test/Transforms/InstCombine/intrinsics.ll
@@ -22,9 +22,9 @@
define void @powi(double %V, double *%P) {
; CHECK-LABEL: @powi(
-; CHECK-NEXT: [[A:%.*]] = fdiv double 1.000000e+00, [[V:%.*]]
+; CHECK-NEXT: [[A:%.*]] = fdiv fast double 1.000000e+00, [[V:%.*]]
; CHECK-NEXT: store volatile double [[A]], double* [[P:%.*]], align 8
-; CHECK-NEXT: [[D:%.*]] = fmul double [[V]], [[V]]
+; CHECK-NEXT: [[D:%.*]] = fmul nnan double [[V]], [[V]]
; CHECK-NEXT: store volatile double [[D]], double* [[P]], align 8
; CHECK-NEXT: ret void
;
Index: llvm/lib/Transforms/InstCombine/InstCombineCalls.cpp
===================================================================
--- llvm/lib/Transforms/InstCombine/InstCombineCalls.cpp
+++ llvm/lib/Transforms/InstCombine/InstCombineCalls.cpp
@@ -886,15 +886,14 @@
case Intrinsic::powi:
if (ConstantInt *Power = dyn_cast<ConstantInt>(II->getArgOperand(1))) {
// 0 and 1 are handled in instsimplify
-
// powi(x, -1) -> 1/x
if (Power->isMinusOne())
- return BinaryOperator::CreateFDiv(ConstantFP::get(CI.getType(), 1.0),
- II->getArgOperand(0));
+ return BinaryOperator::CreateFDivFMF(ConstantFP::get(CI.getType(), 1.0),
+ II->getArgOperand(0), II);
// powi(x, 2) -> x*x
if (Power->equalsInt(2))
- return BinaryOperator::CreateFMul(II->getArgOperand(0),
- II->getArgOperand(0));
+ return BinaryOperator::CreateFMulFMF(II->getArgOperand(0),
+ II->getArgOperand(0), II);
}
break;
-------------- next part --------------
A non-text attachment was scrubbed...
Name: D95455.319358.patch
Type: text/x-patch
Size: 1865 bytes
Desc: not available
URL: <http://lists.llvm.org/pipermail/llvm-commits/attachments/20210126/2bf370c6/attachment.bin>
More information about the llvm-commits
mailing list