[llvm-bugs] [Bug 48115] New: Missed store elimination on conditional change

via llvm-bugs llvm-bugs at lists.llvm.org
Mon Nov 9 01:49:35 PST 2020


https://bugs.llvm.org/show_bug.cgi?id=48115

            Bug ID: 48115
           Summary: Missed store elimination on conditional change
           Product: libraries
           Version: trunk
          Hardware: PC
                OS: All
            Status: NEW
          Severity: enhancement
          Priority: P
         Component: Backend: X86
          Assignee: unassignedbugs at nondot.org
          Reporter: daan at dsprenkels.com
                CC: craig.topper at gmail.com, llvm-bugs at lists.llvm.org,
                    llvm-dev at redking.me.uk, pengfei.wang at intel.com,
                    spatel+llvm at rotateright.com

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: https://godbolt.org/z/Yz64eh

-- 
You are receiving this mail because:
You are on the CC list for the bug.
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://lists.llvm.org/pipermail/llvm-bugs/attachments/20201109/68f1b3d3/attachment.html>


More information about the llvm-bugs mailing list