[LLVMdev] SCEV not simplifying

Nuno Lopes nunoplopes at sapo.pt
Sun Jun 17 20:03:17 PDT 2012


Hi,

So SCEV cannot simplify that expression to -1 because of overflow issues 
(take e.g. src=0x7FFF..).
If you compile with 64 bits integers, then the sexts disappear and so SCEV 
can do the simplification.
Depending on what you want to do, you may want to either do not extend src 
and dst to 64 bits or add a NSW flag to the computations. That will 
hopefully make SCEV push the sext outside and then perform the 
simplification. You can also take a look at 
ScalarEvolution::SimplifyICmpOperands().

Nuno


-----Original Message-----
From: Preston Briggs
Sent: Saturday, June 16, 2012 3:52 AM
To: LLVM Developers Mailing List
Subject: [LLVMdev] SCEV not simplifying


I have a pair of SCEVs that appear different to me.
However, when I compute the difference, it's not known to be non-zero.

    src = (sext i32 %n to i64)
    dst = (sext i32 (1 + %n) to i64)
    delta = ((sext i32 %n to i64) + (-1 * (sext i32 (1 + %n) to i64)))

Is this behavior expected?

If I repeat the experiment with 64-bit ints (or unsigned),
things work out like I expect. 32-bit unsigned is also bad.

Thanks,
Preston 




More information about the llvm-dev mailing list