[llvm-commits] [llvm] r150690 - in /llvm/trunk: lib/Analysis/InstructionSimplify.cpp test/Transforms/InstSimplify/compare.ll

Duncan Sands baldrick at free.fr
Thu Feb 16 06:10:13 PST 2012


Hi Benjamin,

> InstSimplify: Ignore pointer casts when constant folding compares between pointers.

> --- llvm/trunk/lib/Analysis/InstructionSimplify.cpp (original)
> +++ llvm/trunk/lib/Analysis/InstructionSimplify.cpp Thu Feb 16 07:49:39 2012
> @@ -1591,8 +1591,11 @@
>     // to the case where LHS is a global variable address or null is pointless,
>     // since if both LHS and RHS are constants then we already constant folded
>     // the compare, and if only one of them is then we moved it to RHS already.
> -  if (isa<AllocaInst>(LHS)&&  (isa<GlobalValue>(RHS) || isa<AllocaInst>(RHS) ||
> -                               isa<ConstantPointerNull>(RHS)))
> +  Value *LHSPtr = LHS->stripPointerCasts();
> +  Value *RHSPtr = RHS->stripPointerCasts();

how about doing
   LHS = LHS->stripPointerCasts();
   RHS = RHS->stripPointerCasts();
right at the start of the routine?

Ciao, Duncan.



More information about the llvm-commits mailing list