[llvm-commits] [llvm] r51268 - in /llvm/trunk: lib/Transforms/Scalar/InstructionCombining.cpp test/Transforms/InstCombine/sitofp.ll
Neil Booth
neil at daikokuya.co.uk
Mon May 19 15:47:20 PDT 2008
> + // See if the FP constant is top large for the integer. For example,
Typo.
> + // Okay, now we know that the FP constant fits in the range [SMIN, SMAX] but
> + // it may still be fractional. See if it is fractional by casting the FP
> + // value to the integer value and back, checking for equality. Don't do this
> + // for zero, because -0.0 is not fractional.
Perhaps this is better done as an APFloat method if I understand what
you're trying to do? It should be able to determine this reasonably
easily without introducing allocations / conversions, though I've not
thought about it a lot.
> // Handle fcmp with constant RHS
> if (Constant *RHSC = dyn_cast<Constant>(Op1)) {
> + // If the constant is a nan, see if we can fold the comparison based on it.
> + if (ConstantFP *CFP = dyn_cast<ConstantFP>(RHSC)) {
> + if (CFP->getValueAPF().isNaN()) {
> + if (FCmpInst::isOrdered(I.getPredicate())) // True if ordered and...
> + return ReplaceInstUsesWith(I, ConstantInt::get(Type::Int1Ty, 0));
> + if (FCmpInst::isUnordered(I.getPredicate())) // True if unordered or...
> + return ReplaceInstUsesWith(I, ConstantInt::get(Type::Int1Ty, 1));
> + if (FCmpInst::isUnordered(I.getPredicate())) // Undef on unordered.
> + return ReplaceInstUsesWith(I, UndefValue::get(Type::Int1Ty));
> +
Duplicate test?
Neil.
More information about the llvm-commits
mailing list