This is an archive of the discontinued LLVM Phabricator instance.

[UnJ] Pull code out into a separate function NFC
ClosedPublic

Authored by dmgreen on Jul 31 2018, 7:19 AM.

Details

Summary

Pulled this code out into a common isInnerLoopIterationCountInvariant
function as it seems generally useful.

Diff Detail

Repository
rL LLVM

Event Timeline

dmgreen created this revision.Jul 31 2018, 7:19 AM
dmgreen updated this revision to Diff 159267.Aug 6 2018, 3:10 AM

Renamed to hasConsistentIterationCount, as per comments in D50062.

SjoerdMeijer added inline comments.Aug 9 2018, 6:24 AM
include/llvm/Transforms/Utils/LoopUtils.h
493 ↗(On Diff #159267)

Bike shedding names: I was wondering if "consistent" is the right word here. I think what this function does is best described in the implementation:

// Get whether count is invariant to the outer loop

I think "invariant" is describing it better.

lib/Transforms/Utils/LoopUtils.cpp
1524 ↗(On Diff #159267)

nit: I think I would have called SubLoop InnerLoop.

Ah, sorry, I now see HasConsistentIterationCounts has been suggested in that other ticket. Oh well, as I said, I was bike shedding names (but still think 'invariant' is better :-)) Anyway, please ignore if you disagree.

Meinersbur accepted this revision.Aug 9 2018, 2:41 PM

Ah, sorry, I now see HasConsistentIterationCounts has been suggested in that other ticket. Oh well, as I said, I was bike shedding names (but still think 'invariant' is better :-)) Anyway, please ignore if you disagree.

I suggested the name because the term 'consistent' was used in the D50062 function's comment (which seems to have been replicated here). That is, invariant could have been used in that original comment as well.

I am fine if using 'invariant', I don't have a preference.

Overall, LGTM in either case.

include/llvm/Transforms/Utils/LoopUtils.h
493 ↗(On Diff #159267)

I suggested the name because the term 'consistent' was used in the D50062 function's comment (which seems to have been replicated here). 'Invariant' would be ok as well.

This revision is now accepted and ready to land.Aug 9 2018, 2:41 PM

Thanks. I'll go with Invariant as it speaks to what the underlying implementation is doing.

This revision was automatically updated to reflect the committed changes.