[PATCH] D32252: [GVN] Add phi-translate for scalarpre as a temporary solution

Wei Mi via Phabricator via llvm-commits llvm-commits at lists.llvm.org
Wed Apr 19 15:45:46 PDT 2017


wmi created this revision.
Herald added a subscriber: Prazek.

Now phi-translate only exists in loadpre. 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];
long 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 support for phi-translate in scalarpre. This is only a temporary solution before the newpre based on newgvn is available.


Repository:
  rL LLVM

https://reviews.llvm.org/D32252

Files:
  include/llvm/Transforms/Scalar/GVN.h
  lib/Transforms/Scalar/GVN.cpp
  test/Transforms/GVN/PRE/phi-translate-2.ll
  test/Transforms/GVN/PRE/pre-gep-load.ll
  test/Transforms/GVN/PRE/pre-load.ll

-------------- next part --------------
A non-text attachment was scrubbed...
Name: D32252.95836.patch
Type: text/x-patch
Size: 13351 bytes
Desc: not available
URL: <http://lists.llvm.org/pipermail/llvm-commits/attachments/20170419/a5d2fe9f/attachment.bin>


More information about the llvm-commits mailing list