This is an archive of the discontinued LLVM Phabricator instance.

[InstCombine] Don't use getFirstNonPHI in FoldIntegerTypedPHI
ClosedPublic

Authored by thegameg on Nov 8 2019, 10:14 AM.

Details

Summary

getFirstNonPHI iterates over all the instructions in a block until it finds a non-PHI.

Then, the loop starts from the beginning of the block and goes through all the instructions until it reaches the instruction found by getFirstNonPHI.

Instead of doing that, just stop when a non-PHI is found.

This reduces the compile-time of a test case discussed in https://reviews.llvm.org/D47023 by 13x.

Not entirely sure how to come up with a test case for this since it's a compile time issue that would significantly slow down running the tests.

Diff Detail

Event Timeline

thegameg created this revision.Nov 8 2019, 10:14 AM
Herald added a project: Restricted Project. · View Herald TranscriptNov 8 2019, 10:14 AM
Herald added a subscriber: hiraditya. · View Herald Transcript
fhahn added inline comments.Nov 13 2019, 2:50 AM
llvm/lib/Transforms/InstCombine/InstCombinePHI.cpp
183

Could you just use the iterator range BB->phis()? This should automatically iterate until it hits a non-phi instruction.

thegameg marked an inline comment as done.Nov 14 2019, 11:26 AM
thegameg added inline comments.
llvm/lib/Transforms/InstCombine/InstCombinePHI.cpp
183

For some reason using phis() gives me similar results as before when using getFirstNonPHI. I'll look into it.

fhahn accepted this revision.Nov 14 2019, 12:08 PM

LGTM

llvm/lib/Transforms/InstCombine/InstCombinePHI.cpp
183

Ah right, no worries then!

This revision is now accepted and ready to land.Nov 14 2019, 12:08 PM
This revision was automatically updated to reflect the committed changes.