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

            Bug ID: 42178
           Summary: Missed canonicalization for usub.sat(a, b) + b
           Product: libraries
           Version: trunk
          Hardware: PC
                OS: Linux
            Status: NEW
          Severity: enhancement
          Priority: P
         Component: Scalar Optimizations
          Assignee: unassignedb...@nondot.org
          Reporter: david.bolvan...@gmail.com
                CC: llvm-bugs@lists.llvm.org

#define T unsigned

T do_shift(T a, T b)
    {
    return a - ((a - b) & - (T)(a < b));
}

Current trunk:
do_shift:                               # @do_shift
        xor     eax, eax
        sub     esi, edi
        cmovae  eax, esi
        add     eax, edi
        ret

Clang 8:
do_shift:                               # @do_shift
        mov     eax, edi
        cmp     esi, edi
        cmova   eax, esi
        ret

define dso_local i32 @do_shift(i32, i32) local_unnamed_addr #0 {
  %3 = tail call i32 @llvm.usub.sat.i32(i32 %1, i32 %0)
  %4 = add i32 %3, %0
  ret i32 %4
}

As noted by nikic: "Looks like an instcombine fail: usub.sat(a, b) + b should
be canonicalized to umax(a, b)."

-- 
You are receiving this mail because:
You are on the CC list for the bug.
_______________________________________________
llvm-bugs mailing list
llvm-bugs@lists.llvm.org
https://lists.llvm.org/cgi-bin/mailman/listinfo/llvm-bugs

Reply via email to