[llvm-bugs] [Bug 29110] New: GVN Load widening eliminates PRE opportunities

via llvm-bugs llvm-bugs at lists.llvm.org
Tue Aug 23 14:50:04 PDT 2016


https://llvm.org/bugs/show_bug.cgi?id=29110

            Bug ID: 29110
           Summary: GVN Load widening eliminates PRE opportunities
           Product: clang
           Version: trunk
          Hardware: PC
                OS: Linux
            Status: NEW
          Severity: normal
          Priority: P
         Component: LLVM Codegen
          Assignee: unassignedclangbugs at nondot.org
          Reporter: danielcdh at gmail.com
                CC: davidxl at google.com, llvm-bugs at lists.llvm.org,
                    wmi at google.com
    Classification: Unclassified

void bar();

struct a{
  long long p;
  int x;
  int y;
};

int foo(struct a *t) {
  int ret = 0;
  for(;;) {
    switch(t->x) {
      case 1:
        bar();
        t->x = 2;
        break;
      case 2:
        ret += t->y;
        bar();
        t->x = 3;
        break;
      case 3:
        bar();
        break;
      case 4:
        return ret;
    }
  }
}

In function foo(), the load of t->x is partially redundant on case 1&2. In GVN,
the read of t->y in case 2 in combined to the load of t->x with a widen load.
As a result, PRE cannot happen on t->x, thus we have an extra load on case 1
and 2 for every iteration.

Load widening can eliminate one load in the expense of:
1. one trunc operation to the lower load
2. one shift operation to the higher load
3. potential to block PRE opportunity

Looks to me the benefit of this optimization does not justify its constraints.

Thoughts?

-- 
You are receiving this mail because:
You are on the CC list for the bug.
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://lists.llvm.org/pipermail/llvm-bugs/attachments/20160823/608f3613/attachment.html>


More information about the llvm-bugs mailing list