[llvm-bugs] [Bug 38450] New: cmp+store is not optimized to an unconditional store

via llvm-bugs llvm-bugs at lists.llvm.org
Sun Aug 5 06:55:12 PDT 2018


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

            Bug ID: 38450
           Summary: cmp+store is not optimized to an unconditional store
           Product: new-bugs
           Version: trunk
          Hardware: PC
                OS: All
            Status: NEW
          Severity: enhancement
          Priority: P
         Component: new bugs
          Assignee: unassignedbugs at nondot.org
          Reporter: gonzalobg88 at gmail.com
                CC: chandlerc at gmail.com, hfinkel at anl.gov,
                    llvm-bugs at lists.llvm.org, llvm-dev at redking.me.uk,
                    spatel+llvm at rotateright.com

See https://godbolt.org/g/5W5q2K , the following LLVM-IR:

define void @foo(i32* noalias nocapture dereferenceable(4) %x) {
start:
  %0 = load i32, i32* %x, align 4
  %1 = icmp eq i32 %0, 0
  br i1 %1, label %bb2, label %bb1

bb1:
  store i32 0, i32* %x, align 4
  br label %bb2

bb2:
  ret void
}

does not optimize to anything better with opt -O3. Using llc, it generates the
following x86_64 assembly code (https://godbolt.org/g/RX81Sn): 

    cmpl    $0, (%rdi)
    je      .LBB0_2
    movl    $0, (%rdi)
.LBB0_2:  
    retq

I would expect this to just generate "movl $0, (%rdi); retq".

-- 
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/20180805/3f6cf2c6/attachment.html>


More information about the llvm-bugs mailing list