[llvm-bugs] [Bug 43649] New: Suboptimal code for llvm.ssub.sat.i32
    via llvm-bugs 
    llvm-bugs at lists.llvm.org
       
    Fri Oct 11 08:04:21 PDT 2019
    
    
  
https://bugs.llvm.org/show_bug.cgi?id=43649
            Bug ID: 43649
           Summary: Suboptimal code for llvm.ssub.sat.i32
           Product: new-bugs
           Version: unspecified
          Hardware: PC
                OS: Linux
            Status: NEW
          Severity: enhancement
          Priority: P
         Component: new bugs
          Assignee: unassignedbugs at nondot.org
          Reporter: tspiteri at ieee.org
                CC: htmldeveloper at gmail.com, llvm-bugs at lists.llvm.org
The following IR:
    define i32 @_ZN7example14saturating_sub17h23583ee3c8b034a4E(i32 %a, i32 %b)
unnamed_addr #0 !dbg !5 {
    start:
      %0 = tail call i32 @llvm.ssub.sat.i32(i32 %a, i32 %b) #2, !dbg !8
      ret i32 %0, !dbg !15
    }
    declare i32 @llvm.ssub.sat.i32(i32, i32) #1
    attributes #0 = { nounwind nonlazybind readnone uwtable
"probe-stack"="__rust_probestack" "target-cpu"="x86-64" }
    attributes #1 = { nounwind readnone speculatable }
    attributes #2 = { nounwind }
results in the following asm:
    example::saturating_sub:
        xor     eax, eax
        mov     ecx, edi
        sub     ecx, esi
        setns   al
        add     eax, 2147483647
        sub     edi, esi
        cmovno  eax, edi
        ret
I think the `mov ecx, edi` and `sub ecx, esi` instructions should be replaced
by a `cmp esi, edi` instruction.
-- 
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/20191011/b9c60f1c/attachment.html>
    
    
More information about the llvm-bugs
mailing list