[PATCH] D69897: Add #pragma clang loop aligned

Hal Finkel via Phabricator via cfe-commits cfe-commits at lists.llvm.org
Wed Nov 6 10:55:03 PST 2019


hfinkel added inline comments.


================
Comment at: clang/docs/LanguageExtensions.rst:3135
+
+This predicates all the array references inside the loop to be aligned. The aligned access to them can increase fetch time and increase the performance. 
+
----------------
hfinkel wrote:
> lebedev.ri wrote:
> > What does this actually mean, in the end?
> > Will it assume that whatever alignment is required
> > for whatever vectorization width chosen,
> > is the actual alignment?
> Also, just arrays, or also pointers?
> Currently, it is using 32 bit.

You'll need to use the preferred alignment of the element type.

> By pointers, if you mean pointers to arrays? Then Yes.

No, I mean pointers.

What do you intend for these cases:

  double A[Size], B[Size];

  void foo() {
  #pragma clang loop aligned
    for (int i = 0; i < n; ++i) {
      A[i] = B[i] + 1;
    }
  }

or this:

  void foo(double *A, double *B) {
  #pragma clang loop aligned
    for (int i = 0; i < n; ++i) {
      A[i] = B[i] + 1;
    }
  }

or this:

  void foo(double *A, double *B, double *C) {
  #pragma clang loop aligned
    for (int i = 0; i < n; ++i) {
      A[i] = B[i] + *C + 1;
    }
  }

or this:

  void foo(double *A, double *B) {
  #pragma clang loop aligned
    for (int i = 0; i < n; ++i) {
      *A++ = *B++ + 1;
    }
  }

what about arrays of structs?


Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D69897





More information about the cfe-commits mailing list