[PATCH] D123372: [PowerPC] add XLC compat builtin __abs
ChenZheng via Phabricator via cfe-commits
cfe-commits at lists.llvm.org
Wed Apr 20 02:36:14 PDT 2022
This revision was landed with ongoing or failed builds.
This revision was automatically updated to reflect the committed changes.
Closed by commit rG3c776c70a76e: [PowerPC] add XLC compat builtin __abs (authored by shchenz).
Repository:
rG LLVM Github Monorepo
CHANGES SINCE LAST ACTION
https://reviews.llvm.org/D123372/new/
https://reviews.llvm.org/D123372
Files:
clang/lib/Basic/Targets/PPC.cpp
clang/test/CodeGen/PowerPC/builtins-ppc-xlcompat-macros.c
Index: clang/test/CodeGen/PowerPC/builtins-ppc-xlcompat-macros.c
===================================================================
--- clang/test/CodeGen/PowerPC/builtins-ppc-xlcompat-macros.c
+++ clang/test/CodeGen/PowerPC/builtins-ppc-xlcompat-macros.c
@@ -12,6 +12,19 @@
// Required for size_t. Usually found in stddef.h.
typedef __SIZE_TYPE__ size_t;
+// BOTH-LABEL: @testabs(
+// BOTH-NEXT: entry:
+// BOTH-NEXT: [[A_ADDR:%.*]] = alloca i32, align 4
+// BOTH-NEXT: store i32 [[A:%.*]], i32* [[A_ADDR]], align 4
+// BOTH-NEXT: [[TMP0:%.*]] = load i32, i32* [[A_ADDR]], align 4
+// BOTH-NEXT: [[NEG:%.*]] = sub nsw i32 0, [[TMP0]]
+// BOTH-NEXT: [[ABSCOND:%.*]] = icmp slt i32 [[TMP0]], 0
+// BOTH-NEXT: [[ABS:%.*]] = select i1 [[ABSCOND]], i32 [[NEG]], i32 [[TMP0]]
+// BOTH-NEXT: ret i32 [[ABS]]
+signed int testabs(signed int a) {
+ return __abs(a);
+}
+
// 64BIT-LABEL: @testlabs(
// 64BIT-NEXT: entry:
// 64BIT-NEXT: [[A_ADDR:%.*]] = alloca i64, align 8
Index: clang/lib/Basic/Targets/PPC.cpp
===================================================================
--- clang/lib/Basic/Targets/PPC.cpp
+++ clang/lib/Basic/Targets/PPC.cpp
@@ -208,6 +208,7 @@
Builder.defineMacro("__dcbf", "__builtin_dcbf");
Builder.defineMacro("__fmadd", "__builtin_fma");
Builder.defineMacro("__fmadds", "__builtin_fmaf");
+ Builder.defineMacro("__abs", "__builtin_abs");
Builder.defineMacro("__labs", "__builtin_labs");
Builder.defineMacro("__llabs", "__builtin_llabs");
Builder.defineMacro("__popcnt4", "__builtin_popcount");
-------------- next part --------------
A non-text attachment was scrubbed...
Name: D123372.423852.patch
Type: text/x-patch
Size: 1570 bytes
Desc: not available
URL: <http://lists.llvm.org/pipermail/cfe-commits/attachments/20220420/2b67d600/attachment-0001.bin>
More information about the cfe-commits
mailing list