[PATCH] D147750: [LAA/LV] Simplify stride speculation logic [nfc-ish]

Peixin Qiao via Phabricator via llvm-commits llvm-commits at lists.llvm.org
Fri Apr 7 01:54:58 PDT 2023


peixin added a comment.

Why do you remove the `StrideSet`? It can be used to check the const stride in cost model very fast. Now, you check if it is constant one in PSE. The question is if the const one in PSE is the stride?

Also, it seems that removing the `StrideSet` will cause the const stride of non-one (such as 4) in D147539 <https://reviews.llvm.org/D147539> hard to check in cost model.

In addition, I don't figure out how this help replacing the symbolic stride with constants in vectory body. To perform the replacement, we have the following options:

1. Emit the constants when generating the vector body. In this way, we need to check every `mul` operation, which seems to be expansive.
2. Get all the predicates from PSE and check them, which is done in D147378 <https://reviews.llvm.org/D147378>.
3. Use the `StrideSet` in LAA and get the predicate using PSE.

Maybe you have better idea and this patch can help?



================
Comment at: llvm/lib/Transforms/Vectorize/LoopVectorize.cpp:6432
 
-static bool isStrideMul(Instruction *I, LoopVectorizationLegality *Legal) {
-  return Legal->hasStride(I->getOperand(0)) ||
-         Legal->hasStride(I->getOperand(1));
+static bool isOne(const SCEV *S) {
+  auto *C = dyn_cast<SCEVConstant>(S);
----------------
SCEV already has the interface `isOne`.
https://github.com/llvm/llvm-project/blob/5f036799f4d39c1aa5a6fac0e972050373e9fa78/llvm/lib/Analysis/ScalarEvolution.cpp#L450-L454


Repository:
  rG LLVM Github Monorepo

CHANGES SINCE LAST ACTION
  https://reviews.llvm.org/D147750/new/

https://reviews.llvm.org/D147750



More information about the llvm-commits mailing list