[PATCH] Add the __qdbl intrinsic to the arm_acle.h header
Moritz Roth
moritz.roth at arm.com
Wed Jul 2 05:50:25 PDT 2014
Hi rengolin, compnerd,
Hi all,
ACLE section 9.4.2 defines the __qdbl intrinsic:
> int32_t __qdbl(int32_t);
> Doubles a signed 32-bit number, with saturation. __qdbl(x) is equal to __qadd(x,x) except that the argument x is evaluated only once.
> Sets the Q flag if the addition saturates.
Since we already have an arm_acle.h header file with __qadd implemented, it's trivial to implement this. I've also added a test that should make sure the argument is only evaluated once - this would catch e.g. if someone decided to do #define __qdbl(X) __qadd(X,X) instead, which evaluates X twice. Does this look reasonable?
Cheers
Moritz
http://reviews.llvm.org/D4363
Files:
lib/Headers/arm_acle.h
test/CodeGen/arm_acle.c
Index: lib/Headers/arm_acle.h
===================================================================
--- lib/Headers/arm_acle.h
+++ lib/Headers/arm_acle.h
@@ -90,6 +90,11 @@
__qsub(int32_t t, int32_t v) {
return __builtin_arm_qsub(t, v);
}
+
+static __inline__ int32_t __attribute__((always_inline, nodebug))
+__qdbl(int32_t t) {
+ return __builtin_arm_qadd(t, t);
+}
#endif
/* CRC32 intrinsics */
Index: test/CodeGen/arm_acle.c
===================================================================
--- test/CodeGen/arm_acle.c
+++ test/CodeGen/arm_acle.c
@@ -66,6 +66,15 @@
int32_t test_qsub(int32_t a, int32_t b) {
return __qsub(a, b);
}
+
+extern int32_t f();
+// AArch32-LABEL: test_qdbl
+// AArch32: [[VAR:%[a-z0-9]+]] = {{.*}} call {{.*}} @f
+// AArch32-NOT: call {{.*}} @f
+// AArch32: call i32 @llvm.arm.qadd(i32 [[VAR]], i32 [[VAR]])
+int32_t test_qdbl() {
+ return __qdbl(f());
+}
#endif
/* CRC32 intrinsics */
-------------- next part --------------
A non-text attachment was scrubbed...
Name: D4363.11025.patch
Type: text/x-patch
Size: 937 bytes
Desc: not available
URL: <http://lists.llvm.org/pipermail/cfe-commits/attachments/20140702/6dc2b059/attachment.bin>
More information about the cfe-commits
mailing list