[llvm] c2460c3 - [PowerPC] Add negated abs test using llvm.abs intrinsic. NFC.

Kai Luo via llvm-commits llvm-commits at lists.llvm.org
Tue Nov 17 01:31:14 PST 2020


Author: Kai Luo
Date: 2020-11-17T09:28:56Z
New Revision: c2460c3254a0de7a63c082474cc5dc73fe10b7b0

URL: https://github.com/llvm/llvm-project/commit/c2460c3254a0de7a63c082474cc5dc73fe10b7b0
DIFF: https://github.com/llvm/llvm-project/commit/c2460c3254a0de7a63c082474cc5dc73fe10b7b0.diff

LOG: [PowerPC] Add negated abs test using llvm.abs intrinsic. NFC.

Added: 
    llvm/test/CodeGen/PowerPC/neg-abs.ll

Modified: 
    

Removed: 
    


################################################################################
diff  --git a/llvm/test/CodeGen/PowerPC/neg-abs.ll b/llvm/test/CodeGen/PowerPC/neg-abs.ll
new file mode 100644
index 000000000000..b870bd3ce195
--- /dev/null
+++ b/llvm/test/CodeGen/PowerPC/neg-abs.ll
@@ -0,0 +1,19 @@
+; NOTE: Assertions have been autogenerated by utils/update_llc_test_checks.py
+; RUN: llc -ppc-asm-full-reg-names -verify-machineinstrs \
+; RUN:   -mtriple=powerpc64le-linux-gnu < %s | FileCheck \
+; RUN:   -check-prefix=CHECK-LE %s
+
+declare i64 @llvm.abs.i64(i64, i1 immarg)
+
+define i64 at neg_abs(i64 %x) {
+; CHECK-LE-LABEL: neg_abs:
+; CHECK-LE:       # %bb.0:
+; CHECK-LE-NEXT:    sradi r4, r3, 63
+; CHECK-LE-NEXT:    add r3, r3, r4
+; CHECK-LE-NEXT:    xor r3, r3, r4
+; CHECK-LE-NEXT:    neg r3, r3
+; CHECK-LE-NEXT:    blr
+  %abs = tail call i64 @llvm.abs.i64(i64 %x, i1 true)
+  %neg = sub nsw i64 0, %abs
+  ret i64 %neg
+}


        


More information about the llvm-commits mailing list