<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 --- - Check address space when optimizing gep+cast"
   href="http://llvm.org/bugs/show_bug.cgi?id=19270">19270</a>
          </td>
        </tr>

        <tr>
          <th>Summary</th>
          <td>Check address space when optimizing gep+cast
          </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>wujingyue@gmail.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=12304" name="attach_12304" title="unoptimized">attachment 12304</a> <a href="attachment.cgi?id=12304&action=edit" title="unoptimized">[details]</a></span>
unoptimized

visitGetElementPtr in InstructionCombining.cpp gets rid of unnecessary pointer
casts in gep (cast X). However, this optimization may change the address space
of the result pointer type, and cause type mismatch. 

I attached a very simple test to reproduce this issue. Run:

opt -S -O3 gep.ll -o gep.opt.ll
opt -verify gep.opt.ll -disable-output

The verifier will complain about the type mismatch. 

I attached a patch that disables this optimization when the address space of
the source is different from that of the destination. If it looks good to you,
I'll send it to llvm-commits for review. 

Jingyue</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>