<html>
    <head>
      <base href="http://llvm.org/bugs/" />
    </head>
    <body><table border="1" cellspacing="0" cellpadding="8">
        <tr>
          <th>Bug ID</th>
          <td><a class="bz_bug_link 
          bz_status_NEW "
   title="NEW --- - GEP on struct pointer obtained from bitcast canonicalized incorrectly"
   href="http://llvm.org/bugs/show_bug.cgi?id=19048">19048</a>
          </td>
        </tr>

        <tr>
          <th>Summary</th>
          <td>GEP on struct pointer obtained from bitcast canonicalized incorrectly
          </td>
        </tr>

        <tr>
          <th>Product</th>
          <td>libraries
          </td>
        </tr>

        <tr>
          <th>Version</th>
          <td>trunk
          </td>
        </tr>

        <tr>
          <th>Hardware</th>
          <td>PC
          </td>
        </tr>

        <tr>
          <th>OS</th>
          <td>Linux
          </td>
        </tr>

        <tr>
          <th>Status</th>
          <td>NEW
          </td>
        </tr>

        <tr>
          <th>Severity</th>
          <td>normal
          </td>
        </tr>

        <tr>
          <th>Priority</th>
          <td>P
          </td>
        </tr>

        <tr>
          <th>Component</th>
          <td>Scalar Optimizations
          </td>
        </tr>

        <tr>
          <th>Assignee</th>
          <td>unassignedbugs@nondot.org
          </td>
        </tr>

        <tr>
          <th>Reporter</th>
          <td>benjamin@spacecurve.com
          </td>
        </tr>

        <tr>
          <th>CC</th>
          <td>llvmbugs@cs.uiuc.edu
          </td>
        </tr>

        <tr>
          <th>Classification</th>
          <td>Unclassified
          </td>
        </tr></table>
      <p>
        <div>
        <pre>Created <span class=""><a href="attachment.cgi?id=12187" name="attach_12187" title="Misoptimized testcase">attachment 12187</a> <a href="attachment.cgi?id=12187&action=edit" title="Misoptimized testcase">[details]</a></span>
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.</pre>
        </div>
      </p>
      <hr>
      <span>You are receiving this mail because:</span>
      
      <ul>
          <li>You are on the CC list for the bug.</li>
      </ul>
    </body>
</html>