OSDN Git Service

[GVN] Recommit the patch "Add phi-translate support in scalarpre".
authorWei Mi <wmi@google.com>
Sat, 27 May 2017 00:54:19 +0000 (00:54 +0000)
committerWei Mi <wmi@google.com>
Sat, 27 May 2017 00:54:19 +0000 (00:54 +0000)
commitc8237e4e744209d5ae4bd3b818edb68d1f4de195
treee4966781e616084a4c144edc2ae126e39e457017
parentc6a4b1a1de43dec325b9ba5593e85a0cd1b899fb
[GVN] Recommit the patch "Add phi-translate support in scalarpre".

The recommit is to fix a bug about ExtractValue and InsertValue ops. For those
ops, some varargs inside GVN::Expression are not value numbers but raw index
numbers. It is wrong to do phi-translate for raw index numbers, and the fix is
to stop doing that.

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@304050 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