[PATCH] D152366: [LoopVectorize] Allow inner loop runtime checks to be hoisted above an outer loop

Ayal Zaks via Phabricator via llvm-commits llvm-commits at lists.llvm.org
Tue Jun 27 11:27:42 PDT 2023


Ayal added inline comments.


================
Comment at: llvm/test/Transforms/LoopVectorize/runtime-checks-hoist.ll:147
+;   }
+; }
+; We decide to do full runtime checks here (as opposed to diff checks) due to
----------------
This raises a thought, which may deserve a separate patch:
In this example the runtime checks should be optimized into a form independent of the enclosing i loop and hoisted out of it w/o expansion - and w/o asking a flag, as an obvious loop invariant unswitching opportunity.

I.e., instead of checking if intervals dst[i*n : i*n+n) and src[i*n : i*n + n) intersect, suffice to check if dst[0 : n) and src[0 : n) intersect. When checking if the end SCEV point of one precedes the start SCEV of the other, try to cancel common addends, or check if the SCEV of their difference is positive - subject to wrapping?

This also holds for the motivating memcopy example w/o the additional load, which is also worth adding a test for? Perhaps the first diff_checks() test above can serve as a better example where expansion is indeed necessary in order to loop unswitch a (non invariant) runtime check.

Wonder if the SPEC2017 significant cases are invariant(?)


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

https://reviews.llvm.org/D152366



More information about the llvm-commits mailing list