[PATCH] D36800: Add rewrite by-reference parameter pass

Hongbin Zheng via Phabricator via llvm-commits llvm-commits at lists.llvm.org
Wed Aug 16 23:00:57 PDT 2017


etherzhhb added a comment.

In https://reviews.llvm.org/D36800#844026, @grosser wrote:

> It's certainly not too late. Until now it seemed to me like a very specific optimization for gfortran. I did not see any such examples before. If we can generalize this, we can certainly try to upstream this. Could you share some of the examples you are seeing?


"by-reference" is one side, another side is the function return something via a pointer argument (e.g. the opencl sincos function)[1]:

  int *p;
  a = return_via_p(p);

We want to transform it to:

  { a, b } = return_via_p();
  *p = b;

Also, a pointer can be read-modify-write:

  int *p;
  a = read_modify_write_p(p);

we want to transform it to:

  int *p;
  int pin = *p;
  {a, b} = read_modify_write_p(pin);
  *p = b;

[1]https://www.khronos.org/registry/OpenCL/sdk/1.0/docs/man/xhtml/sin.html


Repository:
  rL LLVM

https://reviews.llvm.org/D36800





More information about the llvm-commits mailing list