]> git.ipfire.org Git - thirdparty/gcc.git/commitdiff
expmed: Fix up CONST_POLY_INT case of make_tree [PR125621]
authorAlex Coplan <alex.coplan@arm.com>
Fri, 5 Jun 2026 15:51:47 +0000 (16:51 +0100)
committerAlex Coplan <alex.coplan@arm.com>
Tue, 9 Jun 2026 12:56:53 +0000 (13:56 +0100)
The PR showed us ICEing in build_poly_int_cst because we have type set
to a non-type tree node (a var_decl).  A closer look shows this is
because we pass the wrong variable to wide_int_to_tree in
expmed.cc:make_tree: we pass t instead of type, where t is
uninitialized at the point of the call.  Fixed thusly.

I also took the opportunity to move the CONST_POLY_INT case out of the
default: section into its own case of the switch.

gcc/ChangeLog:

PR middle-end/125621
* expmed.cc (make_tree): Fix CONST_POLY_INT case to pass type
instead of t, move it to its own switch case.

gcc/testsuite/ChangeLog:

PR middle-end/125621
* gcc.target/aarch64/torture/pr125621.c: New test.

gcc/expmed.cc
gcc/testsuite/gcc.target/aarch64/torture/pr125621.c [new file with mode: 0644]

index 3e8a6affde7b165faa4c3c62d96fd73e48ef0b3c..e4433384c591360361e79d46e48e946e8411e2ed 100644 (file)
@@ -5417,6 +5417,9 @@ make_tree (tree type, rtx x)
       t = wide_int_to_tree (type, rtx_mode_t (x, TYPE_MODE (type)));
       return t;
 
+    case CONST_POLY_INT:
+      return wide_int_to_tree (type, const_poly_int_value (x));
+
     case CONST_DOUBLE:
       STATIC_ASSERT (HOST_BITS_PER_WIDE_INT * 2 <= MAX_BITSIZE_MODE_ANY_INT);
       if (TARGET_SUPPORTS_WIDE_INT == 0 && GET_MODE (x) == VOIDmode)
@@ -5508,9 +5511,6 @@ make_tree (tree type, rtx x)
       /* fall through.  */
 
     default:
-      if (CONST_POLY_INT_P (x))
-       return wide_int_to_tree (t, const_poly_int_value (x));
-
       t = build_decl (RTL_LOCATION (x), VAR_DECL, NULL_TREE, type);
 
       /* If TYPE is a POINTER_TYPE, we might need to convert X from
diff --git a/gcc/testsuite/gcc.target/aarch64/torture/pr125621.c b/gcc/testsuite/gcc.target/aarch64/torture/pr125621.c
new file mode 100644 (file)
index 0000000..32f18d2
--- /dev/null
@@ -0,0 +1,7 @@
+/* { dg-do compile } */
+/* { dg-options "-march=armv8.2-a+sve -fsanitize=undefined" } */
+#include <arm_sve.h>
+
+long foo(long x) {
+  return (long)svcntd() * x;
+}