<html>
    <head>
      <base href="https://bugs.llvm.org/">
    </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 - instCombine: incorrect fold of pointer comparison between globals"
   href="https://bugs.llvm.org/show_bug.cgi?id=50208">50208</a>
          </td>
        </tr>

        <tr>
          <th>Summary</th>
          <td>instCombine: incorrect fold of pointer comparison between globals
          </td>
        </tr>

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

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

        <tr>
          <th>Hardware</th>
          <td>All
          </td>
        </tr>

        <tr>
          <th>OS</th>
          <td>All
          </td>
        </tr>

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

        <tr>
          <th>Keywords</th>
          <td>miscompilation
          </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>nunoplopes@sapo.pt
          </td>
        </tr>

        <tr>
          <th>CC</th>
          <td>juneyoung.lee@sf.snu.ac.kr, llvm-bugs@lists.llvm.org, nikita.ppv@gmail.com, spatel+llvm@rotateright.com
          </td>
        </tr></table>
      <p>
        <div>
        <pre>test: Transforms/InstSimplify/ConstProp/icmp-null.ll
The transformation below is only correct if the gep is over i8*, and not with
non-byte-sized types. This is correct: <a href="https://alive2.llvm.org/ce/z/S_TsHW">https://alive2.llvm.org/ce/z/S_TsHW</a>

----------------------------------------
@g2 = global 4 bytes, align 4
@g = global 8 bytes, align 4

define i1 @null_gep_ne_global() {
  %__constexpr_0 = ptrtoint * @g2 to i64
  %gep = gep * null, 8 x i64 %__constexpr_0  ; <-- notice the 8 x
  %cmp = icmp ne * %gep, @g
  ret i1 %cmp
}
=>
@g2 = global 4 bytes, align 4
@g = global 8 bytes, align 4

define i1 @null_gep_ne_global() {
  ret i1 1
}
Transformation doesn't verify!

ERROR: Value mismatch

Example:

Source:
i64 %__constexpr_0 = #x924925b6db6f5564 (10540997870133138788,
-7905746203576412828)
* %gep = pointer(non-local, block_id=0, offset=-7905737407482647776)
i1 %cmp = #x0 (0)

SOURCE MEMORY STATE
===================
NON-LOCAL BLOCKS:
Block 0 >       size: 0 align: 1        alloc type: 0   address: 0
Block 1 >       size: 4 align: 4        alloc type: 0   address:
10540997870133138788
Block 2 >       size: 8 align: 4        alloc type: 0   address:
10541006666226903840

Target:
Source value: #x0 (0)
Target value: #x1 (1)</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>