OSDN Git Service

[GVN] Add phi-translate support in scalarpre.
authorWei Mi <wmi@google.com>
Thu, 25 May 2017 21:49:02 +0000 (21:49 +0000)
committerWei Mi <wmi@google.com>
Thu, 25 May 2017 21:49:02 +0000 (21:49 +0000)
commitd1635911382ac70019dcda1032c8c961bb7e7d76
tree152e723be6a8fece4348897a5616a5ff001e0134
parent325c68628edf1e5056decaebcd574591fb1fd6ee
[GVN] Add phi-translate support in scalarpre.

Right now scalarpre doesn't have phi-translate support, so it will miss some
simple pre opportunities. Like the following testcase, current scalarpre cannot
recognize the last "a * b" is fully redundent because a and b used by the last
"a * b" expr are both defined by phis.

  long a[100], b[100], g1, g2, g3;
  __attribute__((pure)) long goo();

  void foo(long a, long b, long c, long d) {
    g1 = a * b;
    if (__builtin_expect(g2 > 3, 0)) {
      a = c;
      b = d;
      g2 = a * b;
    }
    g3 = a * b;      // fully redundant.
  }

The patch adds phi-translate support in scalarpre. This is only a temporary
solution before the newpre based on newgvn is available.

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

git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@303923 91177308-0d34-0410-b5e6-96231b3b80d8
include/llvm/Transforms/Scalar/GVN.h
lib/Transforms/Scalar/GVN.cpp
test/Transforms/GVN/PRE/phi-translate-2.ll [new file with mode: 0644]
test/Transforms/GVN/PRE/pre-gep-load.ll
test/Transforms/GVN/PRE/pre-load.ll