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

            Bug ID: 52216
           Summary: [AArch64] improve codegen for -abs(x)
           Product: libraries
           Version: trunk
          Hardware: PC
                OS: All
            Status: NEW
          Severity: enhancement
          Priority: P
         Component: Backend: AArch64
          Assignee: unassignedb...@nondot.org
          Reporter: spatel+l...@rotateright.com
                CC: arnaud.degrandmai...@arm.com,
                    llvm-bugs@lists.llvm.org, smithp...@googlemail.com,
                    ties.st...@arm.com

Splitting off from what was originally in bug 50991 (but that was fixed for x86
only):

define i32 @nabs32(i32 %0) {
  %2 = tail call i32 @llvm.abs.i32(i32 %0, i1 true)
  %3 = sub nsw i32 0, %2
  ret i32 %3
}

define i64 @nabs64(i64 %0) {
  %2 = tail call i64 @llvm.abs.i64(i64 %0, i1 true) #3
  %3 = sub nsw i64 0, %2
  ret i64 %3
}

declare i32 @llvm.abs.i32(i32, i1 immarg)
declare i64 @llvm.abs.i64(i64, i1 immarg)

----------------------------------------------------------------------------

% llc -o - nabs.ll -mtriple=aarch64
nabs32:                                 // @nabs32
        cmp     w0, #0
        cneg    w8, w0, mi
        neg     w0, w8
        ret

nabs64:                                 // @nabs64
        cmp     x0, #0
        cneg    x8, x0, mi
        neg     x0, x8
        ret

----------------------------------------------------------------------------

gcc does better on these:
https://godbolt.org/z/GbYha3Kso
...but note that i8 and possibly i16 are better as-is with clang.

-- 
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