[PATCH] SCEV: Improve recognizing of consecutive loads/stores

Michael Zolotukhin mzolotukhin at apple.com
Thu May 22 05:31:47 PDT 2014


Hi,

This patch teaches SCEV to better handle expressions with sign-extends. That will allow SLP-vectorizer to recognize consecutive memory accesses better.

*** Issue ***
Currently, ScalarEvolution fails to figure out that the following expressions describe consecutive loads/stores:
A = ((8 * (sext i32 (2 * %i) to i64)) + @a)
B = ((8 * (sext i32 (1 + (2 * %i)) to i64)) + @a)

Due to sign-ext presence in the example above, SE fails to simplify (B-A) to a constant.

*** Proposed solution ***
If we transform B expression to the following form, SE will be able to figure out that A and B are consecutive:
B' = ((8 * (1 + (sext i32 (2 * %i) to i64))) + @a) 

The current patch implements transformation (sext (A + B*X)) to (A + sext (B*X)). This is legal only if several conditions are true:
1) A and B are positive constants (this could be easily extended to negative)
2) B is a power of 2
3) A < B

Similar transformation is applicable for AddRec expressions: sext{A,+,B} —> A + sext{0,+,B}. However, it’s worth noticing that canonicalization of AddRec expressions tends to accumulate all constants into the initial value, while this transformation tries to do the opposite - hoist the initial value out of AddRec.

I tested this patch on benchmarks, but saw nothing but noise (there were several degradations and improvements, but all of them disappeared after rerun).

Is this patch ok for trunk?

-------------- next part --------------
A non-text attachment was scrubbed...
Name: slp-consecutive-accesses.patch
Type: application/octet-stream
Size: 10570 bytes
Desc: not available
URL: <http://lists.llvm.org/pipermail/llvm-commits/attachments/20140522/c6fc874e/attachment.obj>
-------------- next part --------------


Thanks,
Michael


More information about the llvm-commits mailing list