[llvm-commits] [llvm] r123105 - in /llvm/trunk: lib/Analysis/ScalarEvolution.cpp test/Analysis/ScalarEvolution/nsw.ll

Dan Gohman gohman at apple.com
Mon Jan 10 13:58:09 PST 2011


On Jan 8, 2011, at 6:28 PM, Chris Lattner wrote:

> Author: lattner
> Date: Sat Jan  8 20:28:48 2011
> New Revision: 123105
> 
> URL: http://llvm.org/viewvc/llvm-project?rev=123105&view=rev
> Log:
> teach SCEV analysis of PHI nodes that PHI recurences formed
> with GEP instructions are always NUW, because PHIs cannot wrap
> the end of the address space.
> 
> Modified:
>    llvm/trunk/lib/Analysis/ScalarEvolution.cpp
>    llvm/trunk/test/Analysis/ScalarEvolution/nsw.ll
> 
> Modified: llvm/trunk/lib/Analysis/ScalarEvolution.cpp
> URL: http://llvm.org/viewvc/llvm-project/llvm/trunk/lib/Analysis/ScalarEvolution.cpp?rev=123105&r1=123104&r2=123105&view=diff
> ==============================================================================
> --- llvm/trunk/lib/Analysis/ScalarEvolution.cpp (original)
> +++ llvm/trunk/lib/Analysis/ScalarEvolution.cpp Sat Jan  8 20:28:48 2011
> @@ -2719,6 +2719,11 @@
>                   HasNUW = true;
>                 if (OBO->hasNoSignedWrap())
>                   HasNSW = true;
> +              } else if (isa<GEPOperator>(BEValueV)) {
> +                // If the increment is a GEP, then we know it won't perform an
> +                // unsigned overflow, because the address space cannot be
> +                // wrapped around.
> +                HasNUW = true;


Hi Chris, this isn't safe unless the GEP has the inbounds flag.
inbounds is to GEP very nearly what nuw and nsw are to add and sub.

Dan





More information about the llvm-commits mailing list