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: [email protected]
          Reporter: [email protected]
                CC: [email protected], [email protected],
                    [email protected]
    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.
_______________________________________________
llvm-bugs mailing list
[email protected]
http://lists.llvm.org/cgi-bin/mailman/listinfo/llvm-bugs

Reply via email to