[llvm-commits] [llvm] r150978 - /llvm/trunk/lib/Transforms/InstCombine/InstCombineCompares.cpp

David Blaikie dblaikie at gmail.com
Mon Feb 20 10:58:42 PST 2012


On Mon, Feb 20, 2012 at 10:45 AM, Benjamin Kramer
<benny.kra at googlemail.com> wrote:
> Author: d0k
> Date: Mon Feb 20 12:45:10 2012
> New Revision: 150978
>
> URL: http://llvm.org/viewvc/llvm-project?rev=150978&view=rev
> Log:
> InstCombine: Removing the base from the address calculation is only safe when the GEPs are inbounds.

Worth a test case, too?

>
> Modified:
>    llvm/trunk/lib/Transforms/InstCombine/InstCombineCompares.cpp
>
> Modified: llvm/trunk/lib/Transforms/InstCombine/InstCombineCompares.cpp
> URL: http://llvm.org/viewvc/llvm-project/llvm/trunk/lib/Transforms/InstCombine/InstCombineCompares.cpp?rev=150978&r1=150977&r2=150978&view=diff
> ==============================================================================
> --- llvm/trunk/lib/Transforms/InstCombine/InstCombineCompares.cpp (original)
> +++ llvm/trunk/lib/Transforms/InstCombine/InstCombineCompares.cpp Mon Feb 20 12:45:10 2012
> @@ -610,7 +610,7 @@
>       // If we're comparing GEPs with two base pointers that only differ in type
>       // and both GEPs have only constant indices or just one use, then fold
>       // the compare with the adjusted indices.
> -      if (TD &&
> +      if (TD && GEPLHS->isInBounds() && GEPRHS->isInBounds() &&
>           (GEPLHS->hasAllConstantIndices() || GEPLHS->hasOneUse()) &&
>           (GEPRHS->hasAllConstantIndices() || GEPRHS->hasOneUse()) &&
>           PtrBase->stripPointerCasts() ==
>
>
> _______________________________________________
> llvm-commits mailing list
> llvm-commits at cs.uiuc.edu
> http://lists.cs.uiuc.edu/mailman/listinfo/llvm-commits




More information about the llvm-commits mailing list