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

            Bug ID: 117119
           Summary: [12/13/14/15 Regression] ICE in int_cst_value, at
                    tree.cc:11115
           Product: gcc
           Version: 15.0
            Status: UNCONFIRMED
          Keywords: ice-on-valid-code
          Severity: normal
          Priority: P3
         Component: tree-optimization
          Assignee: unassigned at gcc dot gnu.org
          Reporter: stefansf at gcc dot gnu.org
  Target Milestone: ---
            Target: s390*-*-*

unsigned __int128 g_728;
int func_1_l_5011[8];
void func_1() {
  for (;; g_728 += 1)
    func_1_l_5011[g_728] ^= func_1_l_5011[g_728 + 5];
}
void main() {}

$ gcc -march=z16 -O3 tt.c
during GIMPLE pass: pcom
tt.c: In function 'func_1':
tt.c:1:51: internal compiler error: in int_cst_value, at tree.cc:11115
    1 | unsigned __int128 g_728;int func_1_l_5011[8];void func_1() {for (;;
g_728 += 1)func_1_l_5011[g_728] ^= func_1_l_5011[g_728 + 5];}void main() {}
      |                                                   ^~~~~~
0x3ea3829 internal_error(char const*, ...)
        /devel/gcc-0-vanilla/src/gcc/diagnostic-global-context.cc:517
0x3e65ae5 fancy_abort(char const*, int, char const*)
        /devel/gcc-0-vanilla/src/gcc/diagnostic.cc:1533
0x2af3a6d int_cst_value(tree_node const*)
        /devel/gcc-0-vanilla/src/gcc/tree.cc:11115
0x3ceca59 analyze_subscript_affine_affine
        /devel/gcc-0-vanilla/src/gcc/tree-data-ref.cc:4508
0x3cee1f5 analyze_siv_subscript
        /devel/gcc-0-vanilla/src/gcc/tree-data-ref.cc:4837
0x3cef013 analyze_overlapping_iterations
        /devel/gcc-0-vanilla/src/gcc/tree-data-ref.cc:5067
0x3cf0acd subscript_dependence_tester_1
        /devel/gcc-0-vanilla/src/gcc/tree-data-ref.cc:5604
0x3cf0ccd subscript_dependence_tester
        /devel/gcc-0-vanilla/src/gcc/tree-data-ref.cc:5654
0x3cf11f9 compute_affine_dependence(data_dependence_relation*, loop*)
        /devel/gcc-0-vanilla/src/gcc/tree-data-ref.cc:5731
0x3cf1577 compute_all_dependences(vec<data_reference*, va_heap, vl_ptr> const&,
vec<data_dependence_relation*, va_heap, vl_ptr>*, vec<loop*, va_heap, vl_ptr>
const&, bool)
        /devel/gcc-0-vanilla/src/gcc/tree-data-ref.cc:5798
0x3cf2f6b compute_data_dependences_for_loop(loop*, bool, vec<loop*, va_heap,
vl_ptr>*, vec<data_reference*, va_heap, vl_ptr>*,
vec<data_dependence_relation*, va_heap, vl_ptr>*)
        /devel/gcc-0-vanilla/src/gcc/tree-data-ref.cc:6282
0x26df4ad pcom_worker::tree_predictive_commoning_loop(bool)
        /devel/gcc-0-vanilla/src/gcc/tree-predcom.cc:3397
0x26dfb81 tree_predictive_commoning(bool)
        /devel/gcc-0-vanilla/src/gcc/tree-predcom.cc:3505
0x26dfcc7 run_tree_predictive_commoning
        /devel/gcc-0-vanilla/src/gcc/tree-predcom.cc:3540
0x26dfe01 execute
        /devel/gcc-0-vanilla/src/gcc/tree-predcom.cc:3585
Please submit a full bug report, with preprocessed source (by using
-freport-bug).
Please include the complete backtrace with any bug report.
See <https://gcc.gnu.org/bugs/> for instructions.

In initialize_matrix_A() for case POLYNOMIAL_CHREC the right-hand side is
checked whether it fits a HWI but in the recursive call for the left-hand side
where we hit case INTEGER_CST no check is done which means we ICE afterwards.

The following fixes it for me, though, I'm not sure whether there is a better
solution for this:

diff --git a/gcc/tree-data-ref.cc b/gcc/tree-data-ref.cc
index de234c65e94..82858cca68f 100644
--- a/gcc/tree-data-ref.cc
+++ b/gcc/tree-data-ref.cc
@@ -4087,7 +4087,7 @@ initialize_matrix_A (lambda_matrix A, tree chrec,
unsigned index, int mult)
       }

     case INTEGER_CST:
-      return chrec;
+      return cst_and_fits_in_hwi (chrec) ? chrec : chrec_dont_know;

     default:
       gcc_unreachable ();

Reply via email to