]> git.ipfire.org Git - thirdparty/gcc.git/commitdiff
arm: PR target/109939 Correct signedness of return type of __ssat intrinsics
authorKyrylo Tkachov <kyrylo.tkachov@arm.com>
Wed, 24 May 2023 08:33:04 +0000 (09:33 +0100)
committerKyrylo Tkachov <kyrylo.tkachov@arm.com>
Thu, 8 Jun 2023 08:54:14 +0000 (09:54 +0100)
As the PR says we shouldn't be using qualifier_unsigned for the return type of the __ssat intrinsics.
UNSIGNED_SAT_BINOP_UNSIGNED_IMM_QUALIFIERS already exists for that.
This was just a thinko.
This patch fixes this and the warning with -Wconversion goes away.

Bootstrapped and tested on arm-none-linux-gnueabihf.

gcc/ChangeLog:

PR target/109939
* config/arm/arm-builtins.cc (SAT_BINOP_UNSIGNED_IMM_QUALIFIERS): Use
qualifier_none for the return operand.

gcc/testsuite/ChangeLog:

PR target/109939
* gcc.target/arm/pr109939.c: New test.

(cherry picked from commit 95542a6ec4b350c653b793b7c36a8210b0e9a89d)

gcc/config/arm/arm-builtins.cc
gcc/testsuite/gcc.target/arm/pr109939.c [new file with mode: 0644]

index 36a40a1dc8011c6e74c2967190fef8b8b0c86cf1..557d6f68fd1709d423953dcf8b0253aedf1d325f 100644 (file)
@@ -97,7 +97,7 @@ arm_binop_imm_qualifiers[SIMD_MAX_BUILTIN_ARGS]
 /* T (T, unsigned immediate).  */
 static enum arm_type_qualifiers
 arm_sat_binop_imm_qualifiers[SIMD_MAX_BUILTIN_ARGS]
-  = { qualifier_unsigned, qualifier_none, qualifier_unsigned_immediate };
+  = { qualifier_none, qualifier_none, qualifier_unsigned_immediate };
 #define SAT_BINOP_UNSIGNED_IMM_QUALIFIERS \
   (arm_sat_binop_imm_qualifiers)
 
diff --git a/gcc/testsuite/gcc.target/arm/pr109939.c b/gcc/testsuite/gcc.target/arm/pr109939.c
new file mode 100644 (file)
index 0000000..aafda7c
--- /dev/null
@@ -0,0 +1,14 @@
+/* { dg-do compile } */
+/* { dg-require-effective-target arm_sat_ok } */
+/* { dg-add-options arm_sat } */
+/* { dg-additional-options "-O -Wall -Wconversion" } */
+
+#include <arm_acle.h>
+
+int dbg_ssat_out;
+int dbg_ssat_in;
+
+void test_arm_ssat(void)
+{
+    dbg_ssat_out = __ssat(dbg_ssat_in, 16);
+}