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

Tobias Burnus <burnus at gcc dot gnu.org> changed:

           What    |Removed                     |Added
----------------------------------------------------------------------------
           Keywords|                            |ice-on-valid-code
     Ever confirmed|0                           |1
             Status|UNCONFIRMED                 |NEW
   Last reconfirmed|                            |2022-07-26

--- Comment #1 from Tobias Burnus <burnus at gcc dot gnu.org> ---
My impression is that the ICE is due to having
  fold_build2_loc (0, PLUS_EXPR, type, op0, op1)
with
(gdb) p debug_tree(type)
 <pointer_type 0x7ffff6feda80 [...]
(gdb) p debug_tree(op0)
 <integer_cst 0x7ffff7128b70 type <pointer_type 0x7ffff6feda80> constant 256>
(gdb) p debug_tree(op1)
 <var_decl 0x7ffff7148480 p.0
    type <pointer_type 0x7ffff6feda80  [...]

Namely: variable PLUS_EXPR integer_cst  - instead of a POINTER_PLUS_EXPR.


Patch would be something like the following – except that there are several
additional PLUS_EXPR in that function and that fold_build_pointer_plus assumes
that the first argument is the pointer and the second the offset, which is
converted via convert_to_ptrofftype_loc ...

--- a/gcc/omp-expand.cc
+++ b/gcc/omp-expand.cc
@@ -6882 +6882,4 @@ expand_omp_simd (struct omp_region *region, struct
omp_for_data *fd)
-             t = fold_build2 (PLUS_EXPR, TREE_TYPE (t), t, t2);
+             if (POINTER_TYPE_P (TREE_TYPE (t)))
+               t = fold_build_pointer_plus (t, t2);
+             else
+               t = fold_build2 (PLUS_EXPR, TREE_TYPE (t), t, t2);

Reply via email to