summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
-rw-r--r--llvm/lib/Transforms/InstCombine/InstCombineCompares.cpp12
-rw-r--r--llvm/test/Transforms/InstCombine/fcmp.ll2
2 files changed, 8 insertions, 6 deletions
diff --git a/llvm/lib/Transforms/InstCombine/InstCombineCompares.cpp b/llvm/lib/Transforms/InstCombine/InstCombineCompares.cpp
index c1c904b331a..2ff10f4fc40 100644
--- a/llvm/lib/Transforms/InstCombine/InstCombineCompares.cpp
+++ b/llvm/lib/Transforms/InstCombine/InstCombineCompares.cpp
@@ -5483,11 +5483,13 @@ Instruction *InstCombiner::visitFCmpInst(FCmpInst &I) {
}
}
- // fcmp (fpext x), (fpext y) -> fcmp x, y
- if (FPExtInst *LHSExt = dyn_cast<FPExtInst>(Op0))
- if (FPExtInst *RHSExt = dyn_cast<FPExtInst>(Op1))
- if (LHSExt->getSrcTy() == RHSExt->getSrcTy())
- return new FCmpInst(Pred, LHSExt->getOperand(0), RHSExt->getOperand(0));
+ // fcmp (fpext X), (fpext Y) -> fcmp X, Y
+ if (match(Op0, m_FPExt(m_Value(X))) && match(Op1, m_FPExt(m_Value(Y))) &&
+ X->getType() == Y->getType()) {
+ Instruction *NewFCmp = new FCmpInst(Pred, X, Y);
+ NewFCmp->copyFastMathFlags(&I);
+ return NewFCmp;
+ }
if (I.getType()->isVectorTy())
if (Instruction *Res = foldVectorCmp(I, Builder))
diff --git a/llvm/test/Transforms/InstCombine/fcmp.ll b/llvm/test/Transforms/InstCombine/fcmp.ll
index d48d75a7fca..b72adc19a8e 100644
--- a/llvm/test/Transforms/InstCombine/fcmp.ll
+++ b/llvm/test/Transforms/InstCombine/fcmp.ll
@@ -7,7 +7,7 @@ declare <2 x float> @llvm.fabs.v2f32(<2 x float>)
define i1 @test1(float %x, float %y) {
; CHECK-LABEL: @test1(
-; CHECK-NEXT: [[CMP:%.*]] = fcmp ogt float [[X:%.*]], [[Y:%.*]]
+; CHECK-NEXT: [[CMP:%.*]] = fcmp nnan ogt float [[X:%.*]], [[Y:%.*]]
; CHECK-NEXT: ret i1 [[CMP]]
;
%ext1 = fpext float %x to double
OpenPOWER on IntegriCloud