gnu/gcc/7686bcbb2b7b08688008a6a0e29e6561af1a9a98 tree-optimization/127130 - avoid peeled CHREC with UB
The following properly guards the peeled CHREC optimization
when we are analyzing a CHREC with non-wrapping overflow.
Otherwise we can introduce UB which can manifest via
infer_loop_bounds_from_signedness and thus wrong niter analysis.
This regresses gcc.dg/gomp/static-chunk-size-one.c because we
can no longer replace a signed IV via a peeled chrec and lack
other means.
PR tree-optimization/127130
* tree-scalar-evolution.cc (simplify_peeled_chrec):
Guard against signed integer overflow UB.
* gcc.dg/torture/pr127130-1.c: New testcase.
* gcc.dg/torture/pr127130-2.c: Likewise.
* gcc.dg/gomp/static-chunk-size-one.c: Adjust.
4 files changed