http://gcc.gnu.org/bugzilla/show_bug.cgi?id=34723
Jeffrey A. Law <law at redhat dot com> changed: What |Removed |Added ---------------------------------------------------------------------------- Blocks|19794 | --- Comment #5 from Jeffrey A. Law <law at redhat dot com> --- So "useless" really means threading from outside to an empty latch means the entire loop is being peeled. Reviewing the discussions between Zdenek, Dorit and myself, it was Zdenek's contention that threading should never peel loops, leaving that to another pass. The code to not thread to an empty latch block is a heuristic to avoid peeling. What I don't get is why we don't use changes in the loop structure to identify cases where we're peeling a loop rather than threading to an exit edge (which we certainly want to allow). Perhaps there wasn't enough infrastructure for that in place in 2005.. Regardless of that, it looks like Zdenek's goal was to avoid peeling in DOM and instead leave that to other passes which can make better estimates about whether or not peeling is useful. I'm not 100% convinced that's the best thing to do, but I don't think it's something we can/should revisit during stage3. I'm removing this from the jump threading tracker as after reviewing the old discussion, the threader is roughly doing what it's supposed to do. Not sure how to best address the PR since this is a case where peeling is actually quite cheap -- we don't have a good way to estimate when the duplicated code from peeling for the most part just optimizes away, as it does in this testcase.