<html>
    <head>
      <base href="https://llvm.org/bugs/" />
    </head>
    <body><span class="vcard"><a class="email" href="mailto:david.majnemer@gmail.com" title="David Majnemer <david.majnemer@gmail.com>"> <span class="fn">David Majnemer</span></a>
</span> changed
              <a class="bz_bug_link 
          bz_status_RESOLVED  bz_closed"
   title="RESOLVED INVALID - The add instruction is incorrectly folded into icmp when there is an overflow by instcombine"
   href="https://llvm.org/bugs/show_bug.cgi?id=25986">bug 25986</a>
        <br>
             <table border="1" cellspacing="0" cellpadding="8">
          <tr>
            <th>What</th>
            <th>Removed</th>
            <th>Added</th>
          </tr>

         <tr>
           <td style="text-align:right;">Status</td>
           <td>NEW
           </td>
           <td>RESOLVED
           </td>
         </tr>

         <tr>
           <td style="text-align:right;">CC</td>
           <td>
                
           </td>
           <td>david.majnemer@gmail.com
           </td>
         </tr>

         <tr>
           <td style="text-align:right;">Component</td>
           <td>new bugs
           </td>
           <td>Scalar Optimizations
           </td>
         </tr>

         <tr>
           <td style="text-align:right;">Resolution</td>
           <td>---
           </td>
           <td>INVALID
           </td>
         </tr>

         <tr>
           <td style="text-align:right;">Product</td>
           <td>new-bugs
           </td>
           <td>libraries
           </td>
         </tr></table>
      <p>
        <div>
            <b><a class="bz_bug_link 
          bz_status_RESOLVED  bz_closed"
   title="RESOLVED INVALID - The add instruction is incorrectly folded into icmp when there is an overflow by instcombine"
   href="https://llvm.org/bugs/show_bug.cgi?id=25986#c1">Comment # 1</a>
              on <a class="bz_bug_link 
          bz_status_RESOLVED  bz_closed"
   title="RESOLVED INVALID - The add instruction is incorrectly folded into icmp when there is an overflow by instcombine"
   href="https://llvm.org/bugs/show_bug.cgi?id=25986">bug 25986</a>
              from <span class="vcard"><a class="email" href="mailto:david.majnemer@gmail.com" title="David Majnemer <david.majnemer@gmail.com>"> <span class="fn">David Majnemer</span></a>
</span></b>
        <pre>Hi Yuanrui,

I do not believe InstCombine is wrong here.

The value you chose for '%j' is 'i32 2147483647'.
The add instruction in '%inc' is 'add nsw i32 %j, 1'.  Notice the 'nsw' flag on
the add instruction, it means that '%inc' is poison if it sign overflows or
sign underflows (see <a href="http://llvm.org/docs/LangRef.html#poisonvalues">http://llvm.org/docs/LangRef.html#poisonvalues</a>)

This means that we have the following dynamic values:
%j = i32 2147483647
%inc = i32 poison
%cmp = i1 poison
%conv = i32 poison

If you want signed overflow/underflow to be well defined, remove the nsw flag
from the add instruction.</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>