[PATCH] D101916: [LoopVectorize] Fix crash for predicated instructions with scalable VF

Caroline via Phabricator via llvm-commits llvm-commits at lists.llvm.org
Wed May 19 03:46:15 PDT 2021


CarolineConcatto marked 4 inline comments as done.
CarolineConcatto added inline comments.


================
Comment at: llvm/lib/Transforms/Vectorize/LoopVectorize.cpp:5607
+  // tail when the scalar epilogue is not allowed.
+  if (loopHasScalarWithPredication(MaxScalableVF, !isScalarEpilogueAllowed())) {
+    reportVectorizationInfo(
----------------
sdesmalen wrote:
> In the previous iteration you changed this condition, but this didn't affect the test. Can you add a test that exercises this change?
Thank you @sdesmalen 
I added the test as you suggested for when the loop does not need predication and the epilogue is not allowed.
This path is only triggered with the flag:

```
prefer-predicate-over-epilogue=predicate-dont-vectorize
```
Otherwise isScalarEpilogueAllowed() is true and the loop can vectorize. That is the reason the second test has

```
; CHECK:  sdiv <vscale x 4 x i32> 
```


================
Comment at: llvm/test/Transforms/LoopVectorize/scalable-predicate-instruction.ll:13
+; The division should not allow the loop vectorization
+; It can only vectorize when division by zero is garanteed not to happen
+
----------------
fhahn wrote:
> david-arm wrote:
> > nit: Simple typo - it should be `guaranteed`.
> Would it be more accurate to say this can only be vectorized by scalarizing the division for now which cannot be done for scalable vectors at the moment? 
Thank you @fhahn,
Is the explanation better now?
I added that it will be possible when llvm.vp is implemented.


================
Comment at: llvm/test/Transforms/LoopVectorize/scalable-predicate-instruction.ll:16
+define void  @predicate_instruction_with_scalableVF(i32* %a, i32* %b, i32* %cond, i64 %n)  #0 {
+; CHECK-LABEL: @predicate_instruction_with_scalableVF(
+; CHECK-NEXT:  entry:
----------------
sdesmalen wrote:
> Instead of checking the output to be exactly this, is it sufficient to just check no vector type is being used?
> e.g. CHECK-NOT: <vscale x 4>
Thank you @sdesmalen,
There is no problem. I have changed to check only SDIV.
Is that better?


Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D101916



More information about the llvm-commits mailing list