<html>
    <head>
      <base href="https://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 --- - [InstCombine] SimplifyDemandedBits makes suboptimal transform"
   href="https://llvm.org/bugs/show_bug.cgi?id=28556">28556</a>
          </td>
        </tr>

        <tr>
          <th>Summary</th>
          <td>[InstCombine] SimplifyDemandedBits makes suboptimal transform
          </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>All
          </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>spatel+llvm@rotateright.com
          </td>
        </tr>

        <tr>
          <th>CC</th>
          <td>llvm-bugs@lists.llvm.org
          </td>
        </tr>

        <tr>
          <th>Classification</th>
          <td>Unclassified
          </td>
        </tr></table>
      <p>
        <div>
        <pre>define i5 @or_3_or_1(i3 %a) {
  %or1 = or i3 %a, 3
  %z = zext i3 %or1 to i5
  %or2 = or i5 %z, 1
  ret i5 %or2
}

The 2nd 'or' is covered by the 1st, but SimplifyDemandedBits calls
ShrinkDemandedConstant and causes this:

$ ./opt -instcombine -S sandwiches.ll 

define i5 @or_3_or_1(i3 %a) {
  %or1 = or i3 %a, 2      <--- shrink constant causing later 'or' to be needed
  %z = zext i3 %or1 to i5
  %or2 = or i5 %z, 1
  ret i5 %or2
}

I don't know if this is working as intended or if this is a bug.</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>