[llvm-dev] Vectorization fails when dealing with a lot of for loops.

Michael Kruse via llvm-dev llvm-dev at lists.llvm.org
Mon Aug 26 14:22:24 PDT 2019

There is some weird interaction between alias-analysis and the
vectorized code. For the first loop, alias-analysis is able to
determine that "output" is not aliasing with the read-only arrays:

LAA: Processing memory accesses...
  AST: Alias Set Tracker: 2 alias sets for 7 pointer values.
  AliasSet[0x16a131c3120, 1] must alias, No access Pointers: (double*
%arrayidx6, unknown)
  AliasSet[0x16a131c1e90, 6] may alias, No access Pointers: (double*
%arrayidx, unknown), (double* %arrayidx1, unknown), (double**
%_pointer.i, unknown), (i64* %_mask.i, unknown), (double* %arrayidx.i,
unknown), (double* %arrayidx5, unknown)

After vectorizing the first loop, it is not able to do this anymore
(did not investigate the why). When trying to vectorize the second
loop, it requires a runtime condition to guard against aliasing (for
which it needs to determine the loop bounds), but is unable to do so
because of the the and-mask of "G"/BracketAdapterWithMask:
%arrayidx.i159  --- or as SCEV: ((8 * %and.i158)<nsw> + %36)<nsw>

When removing one of the for-loops, the entire compute-function is
inlined into the run function and this problem is magically resolved.
Not sure why.

Would you file a bug report?


Am Fr., 23. Aug. 2019 um 10:43 Uhr schrieb manolis mi via llvm-dev
<llvm-dev at lists.llvm.org>:
> Hello, could you please have a look at this code posted on godbolt.org:
> https://godbolt.org/z/O-O-Q7
> The problem is that inside the compute function, only the first loop vectorizes while the rest copies of it don't. But if I remove any of the for loops, then the rest vectorize successfully. Could you please confirm that this is a bug, otherwise give me more insight on why the vectorization fails? The message "Cannot identify array bounds" is not helpful.
> Thank you for your time,
> Emmanouil Michalainas, CERN
> _______________________________________________
> LLVM Developers mailing list
> llvm-dev at lists.llvm.org
> https://lists.llvm.org/cgi-bin/mailman/listinfo/llvm-dev

More information about the llvm-dev mailing list