[llvm-commits] [llvm] r124368 - in /llvm/trunk: lib/Transforms/IPO/MergeFunctions.cpp test/Transforms/MergeFunc/vector.ll

Chris Lattner clattner at apple.com
Thu Jan 27 10:11:48 PST 2011


On Jan 27, 2011, at 12:38 AM, Nick Lewycky wrote:
> URL: http://llvm.org/viewvc/llvm-project?rev=124368&view=rev
> Log:
> Fix surprising missed optimization in mergefunc where we forgot to consider
> that relationships like "i8* null" is equivalent to "i32* null".

Nice!

> +++ llvm/trunk/lib/Transforms/IPO/MergeFunctions.cpp Thu Jan 27 02:38:19 2011
> @@ -460,9 +460,18 @@

> +  if (isa<Constant>(V1)) {
> +    if (V1 == V2) return true;
> +    const Constant *C1 = cast<Constant>(V1);

Please use dyn_cast in the if instead of isa+cast.

> +    const Constant *C2 = dyn_cast<Constant>(V2);
> +    if (!C2) return false;
> +    // TODO: constant expressions with GEP or references to F1 or F2.
> +    if (C1->isNullValue() && C2->isNullValue() &&
> +	isEquivalentType(C1->getType(), C2->getType()))
> +      return true;

isEquivalentType accepts intptr_t and void* as equiv, so this will merge null with (intptr)0 right?

> +    return C1->getType()->canLosslesslyBitCastTo(C2->getType()) &&
> +      C1 == ConstantExpr::getBitCast(const_cast<Constant*>(C2), C1->getType());
> +  }

Urr?  What is this about?  This needs a comment at the very least.

-Chris



More information about the llvm-commits mailing list