public inbox for gcc-patches@gcc.gnu.org
 help / color / mirror / Atom feed
* [PATCH][committed] aarch64: PR target/108140 Handle NULL target in data intrinsic expansion
@ 2022-12-19 11:17 Kyrylo Tkachov
  0 siblings, 0 replies; only message in thread
From: Kyrylo Tkachov @ 2022-12-19 11:17 UTC (permalink / raw)
  To: gcc-patches

[-- Attachment #1: Type: text/plain, Size: 716 bytes --]

Hi all,

In this PR we ICE when expanding the __rbit builtin with a NULL target rtx.
I *think* that only happens when the result is unused and hence maybe we shouldn't be expanding
any RTL at all, but the ICE here is easily fixed by deriving the mode from the type of the expression
rather than the target.

This patch does that.
Bootstrapped and tested on aarch64-none-linux-gnu.
Pushing to trunk and a GCC 12 version later after some baking time.
Thanks,
Kyrill

gcc/ChangeLog:

	PR target/108140
	* config/aarch64/aarch64-builtins.cc
	(aarch64_expand_builtin_data_intrinsic): Handle NULL target.

gcc/testsuite/ChangeLog:

	PR target/108140
	* gcc.target/aarch64/acle/pr108140.c: New test.

[-- Attachment #2: rbit-mode.patch --]
[-- Type: application/octet-stream, Size: 1283 bytes --]

diff --git a/gcc/config/aarch64/aarch64-builtins.cc b/gcc/config/aarch64/aarch64-builtins.cc
index b533082592822b002561192246d5500f11ecfe4c..5c9f727b255baa35e5876ed46819432e75cbc99c 100644
--- a/gcc/config/aarch64/aarch64-builtins.cc
+++ b/gcc/config/aarch64/aarch64-builtins.cc
@@ -2648,7 +2648,7 @@ static rtx
 aarch64_expand_builtin_data_intrinsic (unsigned int fcode, tree exp, rtx target)
 {
   expand_operand ops[2];
-  machine_mode mode = GET_MODE (target);
+  machine_mode mode = TYPE_MODE (TREE_TYPE (exp));
   create_output_operand (&ops[0], target, mode);
   create_input_operand (&ops[1], expand_normal (CALL_EXPR_ARG (exp, 0)), mode);
   enum insn_code icode;
diff --git a/gcc/testsuite/gcc.target/aarch64/acle/pr108140.c b/gcc/testsuite/gcc.target/aarch64/acle/pr108140.c
new file mode 100644
index 0000000000000000000000000000000000000000..967928a7dca73c6d309312c17388ed9dae9905f4
--- /dev/null
+++ b/gcc/testsuite/gcc.target/aarch64/acle/pr108140.c
@@ -0,0 +1,15 @@
+/* PR target/108140  */
+/* { dg-do compile } */
+/* { dg-options "-O2" } */
+
+#include<arm_acle.h>
+
+int
+main(int argc, char *argv[])
+{
+	unsigned long long input = argc-1;
+	unsigned long long v = __clz(__rbit(input));
+	__builtin_printf("%d %d\n", argc, v >= 64 ? 123 : 456);
+	return 0;
+}
+

^ permalink raw reply	[flat|nested] only message in thread

only message in thread, other threads:[~2022-12-19 11:17 UTC | newest]

Thread overview: (only message) (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2022-12-19 11:17 [PATCH][committed] aarch64: PR target/108140 Handle NULL target in data intrinsic expansion Kyrylo Tkachov

This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for read-only IMAP folder(s) and NNTP newsgroup(s).