[InstCombine] propagate fast-math-flags when folding fcmp+fpext, part 2

llvm-svn: 346242
This commit is contained in:
Sanjay Patel 2018-11-06 16:45:27 +00:00
parent 7c3ee4da42
commit 46bf3922c1
2 changed files with 7 additions and 4 deletions

View File

@ -5483,9 +5483,12 @@ Instruction *InstCombiner::visitFCmpInst(FCmpInst &I) {
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;
}
}
}

View File

@ -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