gnu/gcc/ebe50ecf876fee0b5ce991d302eaef8670325710 tree-optimization/125652 - wrong code with SCEV
The following fixes a latent issue in chrec_fold_plus_poly_poly
which suffers from being prone to signed overflow UB in the way
it associates additions when accumulating two polynomical CHRECs.
Similar to r16-2781-gafafae097232e7 the following catches the
obvious cases when constants are involved without trying to address
the actual underlying issue.
PR tree-optimization/125652
* tree-chrec.cc (chrec_fold_plus_poly_poly): Avoid UB
integer overflow in accumulating CHREC_RIGHT.
* gcc.dg/torture/pr125652.c: New testcase.
(cherry picked from commit de3a13dd7f6c2856e96fc2b7924f9b34b638940f)
2 files changed