<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 - Missed store elimination on conditional change"
   href="https://bugs.llvm.org/show_bug.cgi?id=48115">48115</a>
          </td>
        </tr>

        <tr>
          <th>Summary</th>
          <td>Missed store elimination on conditional change
          </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>enhancement
          </td>
        </tr>

        <tr>
          <th>Priority</th>
          <td>P
          </td>
        </tr>

        <tr>
          <th>Component</th>
          <td>Backend: X86
          </td>
        </tr>

        <tr>
          <th>Assignee</th>
          <td>unassignedbugs@nondot.org
          </td>
        </tr>

        <tr>
          <th>Reporter</th>
          <td>daan@dsprenkels.com
          </td>
        </tr>

        <tr>
          <th>CC</th>
          <td>craig.topper@gmail.com, llvm-bugs@lists.llvm.org, llvm-dev@redking.me.uk, pengfei.wang@intel.com, spatel+llvm@rotateright.com
          </td>
        </tr></table>
      <p>
        <div>
        <pre>The following IR:

```
target datalayout =
"e-m:e-p270:32:32-p271:32:32-p272:64:64-i64:64-f80:128-n8:16:32:64-S128"
target triple = "x86_64-unknown-linux-gnu"

define void @cmov(i64* nocapture align 8 dereferenceable(8) %a, i64 %b, i1
zeroext %cond) unnamed_addr #0 {
  %_9 = load i64, i64* %a, align 8
  %1 = select i1 %cond, i64 %b, i64 %_9
  store i64 %1, i64* %a, align 8
  ret void
}
```

is compiled to the following X86:

```
cmov:                                   # @cmov
        test    edx, edx
        jne     .LBB0_2
        mov     rsi, qword ptr [rdi]
.LBB0_2:
        mov     qword ptr [rdi], rsi    # (*) could be eliminated
        ret
```

This assembly snippet has a store that could be eliminated.

Godbolt: <a href="https://godbolt.org/z/Yz64eh">https://godbolt.org/z/Yz64eh</a></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>