[PATCH] AArch64:

Tim Northover t.p.northover at gmail.com
Thu Feb 13 06:48:34 PST 2014


Hi all,

This patch is intended to address one issue and help with a couple more at once, so might need some explanation.

The immediate bug we have is that duplicated LLVM IR can be emitted for non-SISD AArch64 NEON intrinsics (currently, I think only vld/vst are affected). First,  EmitAArch64ScalarBuiltinExpr tries to categorise any __builtin_neon_XYZ call, and in the process it emits each argument to LLVM IR. If that fails they get emitted again later by the function that really handles them. Obviously, if the argument expression has side-effects, this is a very bad thing. For example:

    #include <arm_neon.h>

    void *foo(void) {
      printf("Don't do that.\n");
      return 0;
    }
    float32x2_t bar(void) {
      return vld1_f32(foo());
    }

will print the string twice. This patch adds a lookup table which is checked before actually calling EmitAArch64ScalarBuiltinExpr, to remove that possibiltiy.

On its own, it would be a fairly baroque solution to the problem, but I also have two more goals:

1. A very large percentage of the cases in that function are identical, just setting 3 parameters and breaking. If those parameters are put into the table too we don't need them. Eventually this should reduce code size and hopefully compile time as well ("binary search + few switch cases" should be quicker than "many switch cases").

2. This table has the potential to be used by other backends, particularly ARM64 while we're all working out what should go where.

I intend to continue with this to gain the full benefits, but this initial patch shows the direction and solves an existing problem so I thought I'd get opinions.

How does it look?

Cheers.

Tim.

http://llvm-reviews.chandlerc.com/D2764

Files:
  lib/CodeGen/CGBuiltin.cpp
  test/CodeGen/aarch64-neon-ld-sideeffect.c
  utils/TableGen/NeonEmitter.cpp
-------------- next part --------------
A non-text attachment was scrubbed...
Name: D2764.1.patch
Type: text/x-patch
Size: 19052 bytes
Desc: not available
URL: <http://lists.llvm.org/pipermail/cfe-commits/attachments/20140213/9a992312/attachment.bin>


More information about the cfe-commits mailing list