[PATCH] D32998: [WIP] SROA for method argument

Hiroshi Inoue via Phabricator via llvm-commits llvm-commits at lists.llvm.org
Tue May 9 05:52:47 PDT 2017


inouehrs created this revision.



  struct record {
      long long a;
      int b;
      int c;
  };
  
  int func(struct record r) {
      for (int i = 0; i < r.c; i++)
          r.b++;
      return r.b;
  }

When updating r.b (or r.c as well), LLVM generates redundant instructions on some platforms (such as x86_64, ppc64); here, r.b and r.c are packed into one 64-bit GPR when the struct is passed as a method argument.
This patch splits a store of an aggregate that comes from a method argument based on the format of the aggregate (here, struct.record) to avoid the above problem.
Since this optimization depends on ABI (how to pass an aggregate as a method argument), hence I enabled this only ppc64 so far. x86_64 also suffers from inefficient code for the above example.


https://reviews.llvm.org/D32998

Files:
  include/llvm/Analysis/TargetTransformInfo.h
  include/llvm/Analysis/TargetTransformInfoImpl.h
  include/llvm/Transforms/Scalar/SROA.h
  lib/Analysis/TargetTransformInfo.cpp
  lib/Target/PowerPC/PPCTargetTransformInfo.cpp
  lib/Target/PowerPC/PPCTargetTransformInfo.h
  lib/Transforms/Scalar/SROA.cpp

-------------- next part --------------
A non-text attachment was scrubbed...
Name: D32998.98271.patch
Type: text/x-patch
Size: 11006 bytes
Desc: not available
URL: <http://lists.llvm.org/pipermail/llvm-commits/attachments/20170509/ce0c07ac/attachment.bin>


More information about the llvm-commits mailing list