<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 --- - Simplify store values that can be proven constant"
   href="https://llvm.org/bugs/show_bug.cgi?id=23055">23055</a>
          </td>
        </tr>

        <tr>
          <th>Summary</th>
          <td>Simplify store values that can be proven constant
          </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>josh.klontz@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=14110" name="attach_14110" title="Minimum reproducing example">attachment 14110</a> <a href="attachment.cgi?id=14110&action=edit" title="Minimum reproducing example">[details]</a></span>
Minimum reproducing example

InstCombiner successfully simplifies return values when they can be proven
constant, but misses the same optimization opportunity for store values. This
is illustrated in the attached minimum reproducing example:

  ; ModuleID = 'simplify_constant_store.ll'

  ; Function Attrs: nounwind
  declare void @llvm.assume(i1) #0

  ; Function Attrs: nounwind
  define i32 @convert_grayscale(i32, i32* nocapture) #0 {
  entry:
    %2 = icmp eq i32 %0, 3
    tail call void @llvm.assume(i1 %2)
    %3 = add nuw nsw i32 %0, 1
    store i32 %3, i32* %1, align 4
    ret i32 %3
  }

  attributes #0 = { nounwind }

`ret i32 %3` is correctly simplified to `ret i32 4`. `store i32 %3, i32* %1,
align 4` could be simplified to `store i32 4, i32* %1, align 4`, but is not.</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>