[llvm] r346242 - [InstCombine] propagate fast-math-flags when folding fcmp+fpext, part 2
Sanjay Patel via llvm-commits
llvm-commits at lists.llvm.org
Tue Nov 6 08:45:27 PST 2018
Author: spatel
Date: Tue Nov 6 08:45:27 2018
New Revision: 346242
URL: http://llvm.org/viewvc/llvm-project?rev=346242&view=rev
Log:
[InstCombine] propagate fast-math-flags when folding fcmp+fpext, part 2
Modified:
llvm/trunk/lib/Transforms/InstCombine/InstCombineCompares.cpp
llvm/trunk/test/Transforms/InstCombine/fcmp.ll
Modified: llvm/trunk/lib/Transforms/InstCombine/InstCombineCompares.cpp
URL: http://llvm.org/viewvc/llvm-project/llvm/trunk/lib/Transforms/InstCombine/InstCombineCompares.cpp?rev=346242&r1=346241&r2=346242&view=diff
==============================================================================
--- llvm/trunk/lib/Transforms/InstCombine/InstCombineCompares.cpp (original)
+++ llvm/trunk/lib/Transforms/InstCombine/InstCombineCompares.cpp Tue Nov 6 08:45:27 2018
@@ -5483,9 +5483,12 @@ Instruction *InstCombiner::visitFCmpInst
Fabs.clearSign();
if (!Lossy &&
((Fabs.compare(APFloat::getSmallestNormalized(FPSem)) !=
- APFloat::cmpLessThan) || Fabs.isZero()))
- // TODO: Propagate FMF.
- return new FCmpInst(Pred, X, ConstantFP::get(C->getContext(), F));
+ APFloat::cmpLessThan) || Fabs.isZero())) {
+ Instruction *NewFCmp =
+ new FCmpInst(Pred, X, ConstantFP::get(C->getContext(), F));
+ NewFCmp->copyFastMathFlags(&I);
+ return NewFCmp;
+ }
}
}
Modified: llvm/trunk/test/Transforms/InstCombine/fcmp.ll
URL: http://llvm.org/viewvc/llvm-project/llvm/trunk/test/Transforms/InstCombine/fcmp.ll?rev=346242&r1=346241&r2=346242&view=diff
==============================================================================
--- llvm/trunk/test/Transforms/InstCombine/fcmp.ll (original)
+++ llvm/trunk/test/Transforms/InstCombine/fcmp.ll Tue Nov 6 08:45:27 2018
@@ -18,7 +18,7 @@ define i1 @test1(float %x, float %y) {
define i1 @test2(float %a) {
; CHECK-LABEL: @test2(
-; CHECK-NEXT: [[CMP:%.*]] = fcmp ogt float [[A:%.*]], 1.000000e+00
+; CHECK-NEXT: [[CMP:%.*]] = fcmp ninf ogt float [[A:%.*]], 1.000000e+00
; CHECK-NEXT: ret i1 [[CMP]]
;
%ext = fpext float %a to double
More information about the llvm-commits
mailing list