[LLVMbugs] [Bug 892] NEW: [scalarrepl] Should be able to scalarrepl 'union's with pointers in them

bugzilla-daemon at cs.uiuc.edu bugzilla-daemon at cs.uiuc.edu
Tue Aug 29 23:17:40 PDT 2006


http://llvm.org/bugs/show_bug.cgi?id=892

           Summary: [scalarrepl] Should be able to scalarrepl 'union's with
                    pointers in them
           Product: libraries
           Version: 1.0
          Platform: Macintosh
        OS/Version: MacOS X
            Status: NEW
          Severity: enhancement
          Priority: P2
         Component: Scalar Optimizations
        AssignedTo: unassignedbugs at nondot.org
        ReportedBy: sabre at nondot.org


Consider:
#include <cassert>
struct Val {
  int *A, B;
  Val() : A(0), B(2) {}
};
Val foo();
void bar(Val X, Val Y);

void test(Val Op) {
  bar(Op, foo());
}
on X86.

We currently generate really horrible code, because we are not able to eliminate any intermediate 'Val' 
objects.  We should do the right thing in three places, but don't do any of them:

1. llvm-gcc4 is lowering the 'pass struct by value' code into bad code that casts the address of the 
struct to a long*, then loads/stores the entire struct at once.  It doesn't need to do this.  In this specific 
case on X86, it can pass the two elements and get the same effect.
2. ScalarRepl doesn't understand the pointer cast in this case, because one element of the struct is a 
pointer (it handles {int,int} fine).
3. The code generator should handle this, because the 'long' load/stores gets split into 2x i32 loads, 
which should be forward prop'd.  However, because it's not using (even trivial) alias analysis, it doesn't 
get this.

We should fix this problem at all of these levels.

-Chris



------- You are receiving this mail because: -------
You are on the CC list for the bug, or are watching someone who is.



More information about the llvm-bugs mailing list