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

            Bug ID: 22469
           Summary: Missing instcombine for mix of gep and bitcasts
           Product: libraries
           Version: trunk
          Hardware: PC
                OS: Linux
            Status: NEW
          Severity: normal
          Priority: P
         Component: Scalar Optimizations
          Assignee: [email protected]
          Reporter: [email protected]
                CC: [email protected]
    Classification: Unclassified

I ran across this test case the other day.  It really seems like we should be
able to represent this as a single GEP given that we know the size of the
pointers involved.  

; ModuleID = 'gep-test.ll'
target datalayout = "e-i64:64-f80:128-n8:16:32:64-S128"
target triple = "x86_64-unknown-linux"

%Type2 = type { [8 x i8] }
%Type1 = type { [8 x i8] }

; Function Attrs: nounwind readnone
define %Type2 addrspace(1)* addrspace(1)* @test(%Type2 addrspace(1)* readnone
%ptr, i64 %idx) #0 {
  %gep1 = getelementptr inbounds %Type2 addrspace(1)* %ptr, i64 8, i32 0, i64 0
  %bc1 = bitcast i8 addrspace(1)* %gep1 to %Type1 addrspace(1)* addrspace(1)*
  %gep2 = getelementptr inbounds %Type1 addrspace(1)* addrspace(1)* %bc1, i64
%idx
  %final = bitcast %Type1 addrspace(1)* addrspace(1)* %gep2 to %Type2
addrspace(1)* addrspace(1)*
  ret %Type2 addrspace(1)* addrspace(1)* %final
}

Note that we do emit a single "leaq" for this when run through LLC.  It's only
at the IR level that we're uglier than we need to be.

-- 
You are receiving this mail because:
You are on the CC list for the bug.
_______________________________________________
LLVMbugs mailing list
[email protected]
http://lists.cs.uiuc.edu/mailman/listinfo/llvmbugs

Reply via email to