[PowerPC] Add negated abs test using llvm.abs intrinsic. NFC.
authorKai Luo <lkail@cn.ibm.com>
Tue, 17 Nov 2020 09:28:56 +0000 (09:28 +0000)
committerKai Luo <lkail@cn.ibm.com>
Tue, 17 Nov 2020 09:28:56 +0000 (09:28 +0000)
llvm/test/CodeGen/PowerPC/neg-abs.ll [new file with mode: 0644]

diff --git a/llvm/test/CodeGen/PowerPC/neg-abs.ll b/llvm/test/CodeGen/PowerPC/neg-abs.ll
new file mode 100644 (file)
index 0000000..b870bd3
--- /dev/null
@@ -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@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
+}