]> git.ipfire.org Git - thirdparty/gcc.git/commitdiff
tree-optimization/110506 - ICE in pattern recog with TYPE_PRECISION
authorRichard Biener <rguenther@suse.de>
Mon, 3 Jul 2023 07:17:06 +0000 (09:17 +0200)
committerRichard Biener <rguenther@suse.de>
Mon, 3 Jul 2023 08:02:25 +0000 (10:02 +0200)
The following re-orders checks to make sure we check TYPE_PRECISION
on an integral type.

PR tree-optimization/110506
* tree-vect-patterns.cc (vect_recog_rotate_pattern): Re-order
TYPE_PRECISION access with INTEGRAL_TYPE_P check.

* gcc.dg/pr110506-2.c: New testcase.

gcc/testsuite/gcc.dg/pr110506-2.c [new file with mode: 0644]
gcc/tree-vect-patterns.cc

diff --git a/gcc/testsuite/gcc.dg/pr110506-2.c b/gcc/testsuite/gcc.dg/pr110506-2.c
new file mode 100644 (file)
index 0000000..aabca0f
--- /dev/null
@@ -0,0 +1,18 @@
+/* { dg-do compile } */
+/* { dg-options "-O2" } */
+
+typedef unsigned uint32_t;
+typedef uint32_t uint32x4 __attribute__((vector_size(16)));
+typedef struct {
+  uint32x4 b, d;
+} prng_t;
+prng_t prng_rand_128_r_x;
+int main_flags;
+int main() {
+  uint32_t ref_crc[] = {7, 3};
+  uint32x4 e = (prng_rand_128_r_x.b << 27) + (prng_rand_128_r_x.b >> 32 - 27);
+  prng_rand_128_r_x.d = e;
+  if (ref_crc[main_flags])
+    __builtin_abort ();
+  return 0;
+}
index 25f7f8e1e440e356ca3796642a59812e108eb421..de20e9d59cb1be41feab1cab8d801e9243acd950 100644 (file)
@@ -3726,8 +3726,8 @@ vect_recog_rotate_pattern (vec_info *vinfo,
     return NULL;
 
   if (TREE_CODE (oprnd0) != SSA_NAME
-      || TYPE_PRECISION (TREE_TYPE (lhs)) != TYPE_PRECISION (type)
-      || !INTEGRAL_TYPE_P (type))
+      || !INTEGRAL_TYPE_P (type)
+      || TYPE_PRECISION (TREE_TYPE (lhs)) != TYPE_PRECISION (type))
     return NULL;
 
   stmt_vec_info def_stmt_info;