[llvm-commits] [llvm] r123372 - in /llvm/trunk: lib/Analysis/InstructionSimplify.cpp test/Transforms/InstSimplify/2010-12-20-I1Arithmetic.ll

Duncan Sands baldrick at free.fr
Thu Jan 13 02:46:51 PST 2011


Hi Frits,

> On Thu, Jan 13, 2011 at 9:56 AM, Duncan Sands<baldrick at free.fr>  wrote:
>> +  // icmp<global/alloca*/null>,<global/alloca*/null>  - Global/Stack value
>> +  // addresses never equal each other!  We already know that Op0 != Op1.
>> +  if ((isa<GlobalValue>(LHS) || isa<AllocaInst>(LHS) ||
>> +       isa<ConstantPointerNull>(LHS))&&
>> +      (isa<GlobalValue>(RHS) || isa<AllocaInst>(RHS) ||
>> +       isa<ConstantPointerNull>(RHS)))
>> +    return ConstantInt::get(ITy, CmpInst::isFalseWhenEqual(Pred));
>
> This is pre-existing code you only moved, but it looks buggy: some
> globals may be null. In particular, 'extern_weak' declarations may be
> null at run time if no definition is ever linked in. I guess it
> probably dates from before extern_weak was introduced (possibly by way
> of -instcombine).
>
> Luckily, after trying it out, it seems that those cases are caught by
> constant folding (which seems to do the right thing) before this code
> is reached. Still, a note in the comment that this code depends on
> that might be in order.

I removed the wrong cases, which as you noted were never executed anyway.

Ciao, Duncan.



More information about the llvm-commits mailing list