[all-commits] [llvm/llvm-project] c19c0a: [AArch64][SVE] Fix bug in lowering of fixed-length...

Joe Ellis via All-commits all-commits at lists.llvm.org
Fri Apr 23 07:55:59 PDT 2021


  Branch: refs/heads/main
  Home:   https://github.com/llvm/llvm-project
  Commit: c19c0ad6813d05802d4f9e7a7d25b897beb87525
      https://github.com/llvm/llvm-project/commit/c19c0ad6813d05802d4f9e7a7d25b897beb87525
  Author: Joe Ellis <joe.ellis at arm.com>
  Date:   2021-04-23 (Fri, 23 Apr 2021)

  Changed paths:
    M llvm/lib/Target/AArch64/AArch64ISelLowering.cpp
    M llvm/test/CodeGen/AArch64/sve-fixed-length-int-div.ll
    M llvm/test/CodeGen/AArch64/sve-fixed-length-int-rem.ll

  Log Message:
  -----------
  [AArch64][SVE] Fix bug in lowering of fixed-length integer vector divides

The function AArch64TargetLowering::LowerFixedLengthVectorIntDivideToSVE
previously assumed the operands were full vectors, but this is not
always true. This function would produce bogus if the division operands
are not full vectors, resulting in miscompiles when dividing 8-bit or
16-bit vectors.

The fix is to perform an extend + div + truncate for non-full vectors,
instead of the usual unpacking and unzipping logic. This is an additive
change which reduces the non-full integer vector divisions to a pattern
recognised by the existing lowering logic.

For future reference, an example of code that would miscompile before
this patch is below:

     1  int8_t foo(unsigned N, int8_t *a, int8_t *b, int8_t *c) {
     2      int8_t result = 0;
     3      for (int i = 0; i < N; ++i) {
     4          result += (a[i] / b[i]) / c[i];
     5      }
     6      return result;
     7  }

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




More information about the All-commits mailing list