https://gcc.gnu.org/bugzilla/show_bug.cgi?id=114041

--- Comment #7 from Jakub Jelinek <jakub at gcc dot gnu.org> ---
There is just INTEGER_TYPE test in all graphite*, so
2024-02-27  Jakub Jelinek  <ja...@redhat.com>

        PR tree-optimization/114041
        * graphite-sese-to-poly.cc (add_conditions_to_domain): Handle
        BITINT_TYPE like INTEGER_TYPE.

        * gcc.dg/graphite/run-id-pr114041.c: New test.

--- gcc/graphite-sese-to-poly.cc.jj     2024-01-03 11:51:29.136764430 +0100
+++ gcc/graphite-sese-to-poly.cc        2024-02-27 18:56:06.536686265 +0100
@@ -391,8 +391,11 @@ add_conditions_to_domain (poly_bb_p pbb)
       {
       case GIMPLE_COND:
          {
-            /* Don't constrain on anything else than INTEGER_TYPE.  */
-           if (TREE_CODE (TREE_TYPE (gimple_cond_lhs (stmt))) != INTEGER_TYPE)
+            /* Don't constrain on anything else than INTEGER_TYPE
+              or BITINT_TYPE.  */
+           tree cmp_type = TREE_TYPE (gimple_cond_lhs (stmt));
+           if (TREE_CODE (cmp_type) != INTEGER_TYPE
+               && TREE_CODE (cmp_type) != BITINT_TYPE)
               break;

            gcond *cond_stmt = as_a <gcond *> (stmt);
--- gcc/testsuite/gcc.dg/graphite/run-id-pr114041.c.jj  2024-02-27
18:42:26.864025806 +0100
+++ gcc/testsuite/gcc.dg/graphite/run-id-pr114041.c     2024-02-27
18:43:07.310466262 +0100
@@ -0,0 +1,23 @@
+/* PR tree-optimization/114041 */
+/* { dg-require-effective-target bitint } */
+/* { dg-options "-O -fgraphite-identity" } */
+
+unsigned a[24], b[24];
+
+__attribute__((noipa)) unsigned
+foo (unsigned _BitInt(8) x)
+{
+  for (int i = 0; i < 24; ++i)
+    a[i] = i;
+  unsigned e = __builtin_stdc_bit_ceil (x);
+  for (int i = 0; i < 24; ++i)
+    b[i] = i;
+  return e;
+}
+
+int
+main ()
+{
+  if (foo (0) != 1)
+    __builtin_abort ();
+}

fixes it.

Reply via email to