]> git.ipfire.org Git - thirdparty/gcc.git/commitdiff
tree-optimization/112505 - bit-precision induction vectorization
authorRichard Biener <rguenther@suse.de>
Thu, 11 Jan 2024 13:00:33 +0000 (14:00 +0100)
committerRichard Biener <rguenther@suse.de>
Fri, 21 Jun 2024 09:21:07 +0000 (11:21 +0200)
Vectorization of bit-precision inductions isn't implemented but we
don't check this, instead we ICE during transform.

PR tree-optimization/112505
* tree-vect-loop.c (vectorizable_induction): Reject
bit-precision induction.

* gcc.dg/vect/pr112505.c: New testcase.

(cherry picked from commit ec345df53556ec581590347f71c3d9ff3cdbca76)

gcc/testsuite/gcc.dg/vect/pr112505.c [new file with mode: 0644]
gcc/tree-vect-loop.c

diff --git a/gcc/testsuite/gcc.dg/vect/pr112505.c b/gcc/testsuite/gcc.dg/vect/pr112505.c
new file mode 100644 (file)
index 0000000..56546c1
--- /dev/null
@@ -0,0 +1,14 @@
+/* { dg-do compile } */
+/* { dg-additional-options "-O3" } */
+
+short int w9;
+struct T {
+  short a : 14;
+  int b;
+};
+struct T v;
+void zc()
+{
+  for(int i = 0; i < 4; i ++)
+    w9 *= v.b ? v.a-- < 0 : 0;
+}
index 48dbdc244908afce09fa37761f3583c1998bd243..0c1f7e49ed98401367373483a2ad66b43b0ec2e1 100644 (file)
@@ -8032,6 +8032,15 @@ vectorizable_induction (loop_vec_info loop_vinfo,
 
   step_expr = STMT_VINFO_LOOP_PHI_EVOLUTION_PART (stmt_info);
   gcc_assert (step_expr != NULL_TREE);
+  if (INTEGRAL_TYPE_P (TREE_TYPE (step_expr))
+      && !type_has_mode_precision_p (TREE_TYPE (step_expr)))
+    {
+      if (dump_enabled_p ())
+       dump_printf_loc (MSG_MISSED_OPTIMIZATION, vect_location,
+                        "bit-precision induction vectorization not "
+                        "supported.\n");
+      return false;
+    }
   tree step_vectype = get_same_sized_vectype (TREE_TYPE (step_expr), vectype);
 
   /* Check for backend support of PLUS/MINUS_EXPR. */