This is an archive of the discontinued LLVM Phabricator instance.

[NFC][DSE]Change 'do-while' to 'for' loop to simplify code structure
ClosedPublic

Authored by ebrevnov on Apr 22 2021, 4:01 AM.

Details

Summary

With 'for' loop there is is a single place where 'Current' is adjusted. It helps to avoid copy paste and makes a bit easy to understand overall loop controll flow.

Diff Detail

Event Timeline

ebrevnov created this revision.Apr 22 2021, 4:01 AM
ebrevnov requested review of this revision.Apr 22 2021, 4:01 AM
Herald added a project: Restricted Project. · View Herald TranscriptApr 22 2021, 4:01 AM
fhahn added inline comments.Jun 28 2021, 9:02 AM
llvm/lib/Transforms/Scalar/DeadStoreElimination.cpp
1391–1392

The braces here and at the other changed lines are now redundant. Would be good to remove them.

1450–1451

perhaps it would be simpler to just have the break as last statement of the loop?

ebrevnov updated this revision to Diff 355136.Jun 29 2021, 1:20 AM

Fixed as requested

ebrevnov marked 2 inline comments as done.Jun 29 2021, 1:21 AM
ebrevnov added inline comments.
llvm/lib/Transforms/Scalar/DeadStoreElimination.cpp
1450–1451

Good suggestion. Done.

fhahn accepted this revision.Jun 29 2021, 1:23 AM

LGTM, this looks like a nice simplification to ensure Current is updated correctly at the end of each iteration. Thanks!

This revision is now accepted and ready to land.Jun 29 2021, 1:23 AM
This revision was landed with ongoing or failed builds.Jul 1 2021, 8:01 PM
This revision was automatically updated to reflect the committed changes.