[Bug tree-optimization/98758] [9/10 Regression] ice in lambda_matrix_right_hermite by r9-3927

rguenth at gcc dot gnu.org gcc-bugzilla@gcc.gnu.org
Wed Jan 20 08:54:55 GMT 2021


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

--- Comment #6 from Richard Biener <rguenth at gcc dot gnu.org> ---
(In reply to David Binderman from comment #5)
> Minor quibble over the patch. I notice that integer division by abs_b occurs.
> 
> Belt and braces, but is zero a legal value for abs_b ? 
> 
> If so, it might be worth putting in some code to avoid divide by zero.
> 
> If not, it might be worth putting in some code to show the future
> readers of the code that integer division by zero doesn't happen.

The code is (more fully quoted)

              while (S[i][j] != 0)
                {
                  lambda_int sigma, factor, a, b;

                  a = S[i-1][j];
                  b = S[i][j];
                  sigma = ((a < 0) ^ (b < 0)) ? -1: 1;
                  unsigned HOST_WIDE_INT abs_a = absu_hwi (a);
                  unsigned HOST_WIDE_INT abs_b = absu_hwi (b);
                  factor = sigma * (lambda_int)(abs_a / abs_b);

                  lambda_matrix_row_add (S, n, i, i-1, -factor);
                  std::swap (S[i], S[i-1]); 

                  lambda_matrix_row_add (U, m, i, i-1, -factor);
                  std::swap (U[i], U[i-1]); 
                }

so b is not zero.  I'm investigating how to handle possible overflow
in lambda_matrix_row_add still.


More information about the Gcc-bugs mailing list