On 1/6/25 9:01 AM, Richard Biener wrote:
Note unrolling doesn't introduce UB - it makes conditional UB
"obvious".
That's fair and it's how I often view these kinds of things when they
pop out via jump threading.
So unless the condition guarding the UB unrolling exposes is visibly
false to the compiler but we fail
to exploit that (missed optimization) there's not much that we can do.
I think "folding" away the UB
like what Jeff proposes trades false negatives for the false positive
diagnostics.
I hadn't looked at it in that way, but I can certainly see that point of
view. Of course the counter to that is all kinds of optimizations can
do the same.
That said - I think for these unroller exposed cases of apparent false
positives we should improve
the path pruning in the unroller itself. For the other cases the path
diagnostic might help clarify
that the UB happens on the 'n-th' iteration of the loop when some
additional condition is true/false.
Agreed.
So in the end Jeff - I think your patch isn't a good approach for the
issue at hand.
Understood. It was an idea, I don't mind setting it aside.
Jeff