aarch64: Fix uint64_t[8] usage after including "arm_neon.h" [PR124126]

aarch64_init_ls64_builtins_types currently creates an array with type uint64_t[8]
and then sets the mode to V8DI. The problem here is if you used that array
type before, you would get a mode of BLK.
This causes an ICE in some cases, with the C++ front-end with -g, you would
get "type variant differs by TYPE_MODE" and in some cases even without -g,
"canonical types differ for identical types".

The fix is to do build_distinct_type_copy of the array in aarch64_init_ls64_builtins_types
before assigning the mode to that copy. We keep the same ls64 structures correct and
user provided arrays are not influenced when "arm_neon.h" is included.

Build and tested on aarch64-linux-gnu.

	PR target/124126

gcc/ChangeLog:

	* config/aarch64/aarch64-builtins.cc (aarch64_init_ls64_builtins_types): Copy
	the array type before setting the mode.

gcc/testsuite/ChangeLog:

	* g++.target/aarch64/pr124126-1.C: New test.

Signed-off-by: Andrew Pinski <andrew.pinski@oss.qualcomm.com>
This commit is contained in:
Andrew Pinski
2026-02-17 14:03:44 -08:00
parent 0c3b30c71c
commit 5eecb51ad7
2 changed files with 16 additions and 0 deletions

View File

@@ -2321,6 +2321,7 @@ aarch64_init_ls64_builtins_types (void)
const char *tuple_type_name = "__arm_data512_t";
tree node_type = get_typenode_from_name (UINT64_TYPE);
tree array_type = build_array_type_nelts (node_type, 8);
array_type = build_distinct_type_copy (array_type);
SET_TYPE_MODE (array_type, V8DImode);
gcc_assert (TYPE_MODE_RAW (array_type) == TYPE_MODE (array_type));

View File

@@ -0,0 +1,15 @@
/* { dg-do compile } */
/* { dg-additional-options "-g" } */
/* PR target/124126 */
/* Make sure an array of uint64_t[8] works when
used before the inlcude of arm_acle.h. */
typedef unsigned long uint64_t;
void executeSuperscalar(uint64_t (*r)[8]);
#include "arm_acle.h"
void initDatasetItem() {
uint64_t rl[8];
executeSuperscalar(&rl);
}