[LLVMbugs] [Bug 19048] New: GEP on struct pointer obtained from bitcast canonicalized incorrectly

bugzilla-daemon at llvm.org bugzilla-daemon at llvm.org
Tue Mar 4 16:43:10 PST 2014


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

            Bug ID: 19048
           Summary: GEP on struct pointer obtained from bitcast
                    canonicalized incorrectly
           Product: libraries
           Version: trunk
          Hardware: PC
                OS: Linux
            Status: NEW
          Severity: normal
          Priority: P
         Component: Scalar Optimizations
          Assignee: unassignedbugs at nondot.org
          Reporter: benjamin at spacecurve.com
                CC: llvmbugs at cs.uiuc.edu
    Classification: Unclassified

Created attachment 12187
  --> http://llvm.org/bugs/attachment.cgi?id=12187&action=edit
Misoptimized testcase

In the attached code, if a datalayout declaration is present the instructions

  %variant_source = bitcast i16* %dataload_case_ptr to { i16, i64 }*
  %8 = getelementptr inbounds { i16, i64 }* %variant_source, i32 0, i32 1
  %9 = load i64* %8
  store i64 %9, i64* %1, align 8

get transformed by opt -O3 into

  %6 = getelementptr inbounds i16* %5, i64 4
  %7 = bitcast i16* %6 to i64*
  %8 = load i64* %7, align 8
  store i64 %8, i64* %1, align 8

If the datalayout is removed, the bitcast is instead deleted entirely and
retains the correct GEP form, at which point returning the datalayout once more
and re-optimizing correctly reduces the entire function to 'ret i8 1', which is
ideally what would happen regardless. Presumably the noncanonical form
interferes with further optimizations.

-- 
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/20140305/959f0804/attachment.html>


More information about the llvm-bugs mailing list