diff options
author | Devang Patel <dpatel@apple.com> | 2012-02-13 23:05:18 +0000 |
---|---|---|
committer | Devang Patel <dpatel@apple.com> | 2012-02-13 23:05:18 +0000 |
commit | 698452bc7e838e3a355029539d7f0be974d4d81d (patch) | |
tree | 58bc250e7be7e48167e0978a983be7258ddb0680 /llvm/lib/Transforms | |
parent | eb6e01533aeb86b5a2df6a373803350bb56ed555 (diff) | |
download | bcm5719-llvm-698452bc7e838e3a355029539d7f0be974d4d81d.tar.gz bcm5719-llvm-698452bc7e838e3a355029539d7f0be974d4d81d.zip |
Check against umin while converting fcmp into an icmp.
llvm-svn: 150425
Diffstat (limited to 'llvm/lib/Transforms')
-rw-r--r-- | llvm/lib/Transforms/InstCombine/InstCombineCompares.cpp | 11 |
1 files changed, 11 insertions, 0 deletions
diff --git a/llvm/lib/Transforms/InstCombine/InstCombineCompares.cpp b/llvm/lib/Transforms/InstCombine/InstCombineCompares.cpp index 4a59d7055e9..bb7763ddeb6 100644 --- a/llvm/lib/Transforms/InstCombine/InstCombineCompares.cpp +++ b/llvm/lib/Transforms/InstCombine/InstCombineCompares.cpp @@ -2714,6 +2714,17 @@ Instruction *InstCombiner::FoldFCmp_IntToFP_Cst(FCmpInst &I, return ReplaceInstUsesWith(I, ConstantInt::getTrue(I.getContext())); return ReplaceInstUsesWith(I, ConstantInt::getFalse(I.getContext())); } + } else { + // See if the RHS value is < UnsignedMin. + APFloat SMin(RHS.getSemantics(), APFloat::fcZero, false); + SMin.convertFromAPInt(APInt::getMinValue(IntWidth), true, + APFloat::rmNearestTiesToEven); + if (SMin.compare(RHS) == APFloat::cmpGreaterThan) { // umin > 12312.0 + if (Pred == ICmpInst::ICMP_NE || Pred == ICmpInst::ICMP_UGT || + Pred == ICmpInst::ICMP_UGE) + return ReplaceInstUsesWith(I, ConstantInt::getTrue(I.getContext())); + return ReplaceInstUsesWith(I, ConstantInt::getFalse(I.getContext())); + } } // Okay, now we know that the FP constant fits in the range [SMIN, SMAX] or |