[llvm-bugs] [Bug 43594] New: [InstCombine] sign bit extract + trunc => icmp + zext?

via llvm-bugs llvm-bugs at lists.llvm.org
Mon Oct 7 12:49:02 PDT 2019


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

            Bug ID: 43594
           Summary: [InstCombine] sign bit extract + trunc => icmp + zext?
           Product: libraries
           Version: trunk
          Hardware: PC
                OS: Linux
            Status: NEW
          Severity: enhancement
          Priority: P
         Component: Scalar Optimizations
          Assignee: unassignedbugs at nondot.org
          Reporter: lebedev.ri at gmail.com
                CC: llvm-bugs at lists.llvm.org

https://godbolt.org/z/iSlCpW

For 

int good(unsigned long input) {
    return (signed long)input < 0;
}


we produce

define dso_local i32 @_Z4goodm(i64 %0) local_unnamed_addr #0 {
  %2 = lshr i64 %0, 63
  %3 = trunc i64 %2 to i32
  ret i32 %3
}


Should this be instead:

define dso_local i32 @_Z4goodm(i64 %0) local_unnamed_addr #0 {
  %2 = icmp slt i64 %0, 0
  %3 = zext i1 %2 to i32
  ret i32 %3
}

?

-- 
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/20191007/649718c6/attachment.html>


More information about the llvm-bugs mailing list