[all-commits] [llvm/llvm-project] cba4ac: [LV] Clamp VF hint when unsafe

Cullen Rhodes via All-commits all-commits at lists.llvm.org
Tue Dec 1 03:34:58 PST 2020


  Branch: refs/heads/temp-test-main
  Home:   https://github.com/llvm/llvm-project
  Commit: cba4accda08f90bbc96d7662ef6b1bb12a7733f2
      https://github.com/llvm/llvm-project/commit/cba4accda08f90bbc96d7662ef6b1bb12a7733f2
  Author: Cullen Rhodes <cullen.rhodes at arm.com>
  Date:   2020-12-01 (Tue, 01 Dec 2020)

  Changed paths:
    M llvm/lib/Transforms/Vectorize/LoopVectorize.cpp
    A llvm/test/Transforms/LoopVectorize/AArch64/unsafe-vf-hint-remark.ll
    A llvm/test/Transforms/LoopVectorize/unsafe-vf-hint-remark.ll

  Log Message:
  -----------
  [LV] Clamp VF hint when unsafe

In the following loop the dependence distance is 2 and can only be
vectorized if the vector length is no larger than this.

  void foo(int *a, int *b, int N) {
    #pragma clang loop vectorize(enable) vectorize_width(4)
    for (int i=0; i<N; ++i) {
      a[i + 2] = a[i] + b[i];
    }
  }

However, when specifying a VF of 4 via a loop hint this loop is
vectorized. According to [1][2], loop hints are ignored if the
optimization is not safe to apply.

This patch introduces a check to bail of vectorization if the user
specified VF is greater than the maximum feasible VF, unless explicitly
forced with '-force-vector-width=X'.

[1] https://llvm.org/docs/LangRef.html#llvm-loop-vectorize-and-llvm-loop-interleave
[2] https://clang.llvm.org/docs/LanguageExtensions.html#extensions-for-loop-hint-optimizations

Reviewed By: sdesmalen, fhahn, Meinersbur

Differential Revision: https://reviews.llvm.org/D90687




More information about the All-commits mailing list