Page MenuHomePhabricator

[LVI] Fix LVI compile time regression around constantFoldUser()
ClosedPublic

Authored by yamauchi on Aug 9 2017, 2:30 PM.

Details

Summary

Avoid checking each operand and calling getValueFromCondition() before calling
constantFoldUser() when the instruction type isn't supported by
constantFoldUser().

This fixes a large compile time regression in an internal build.

Event Timeline

yamauchi created this revision.Aug 9 2017, 2:30 PM
yamauchi updated this revision to Diff 110484.Aug 9 2017, 2:46 PM

Cleaned up.

sanjoy requested changes to this revision.Aug 9 2017, 2:52 PM
sanjoy added inline comments.
lib/Analysis/LazyValueInfo.cpp
1417

Please add an assert in constantFolderUser that this is true for its input. Also please s/Value *Val/User *U/

1495–1496

Don't you need to guard this too?

This revision now requires changes to proceed.Aug 9 2017, 2:52 PM
yamauchi updated this revision to Diff 110488.Aug 9 2017, 3:56 PM
yamauchi edited edge metadata.
yamauchi marked 2 inline comments as done.

Addressed comments.

sanjoy added inline comments.Aug 9 2017, 4:09 PM
lib/Analysis/LazyValueInfo.cpp
1497

Shouldn't this be canConstantFoldUser(Usr) && usesOperand(Usr, Condition)? Otherwise we're not really short-circuiting anything.

yamauchi updated this revision to Diff 110509.Aug 9 2017, 5:12 PM
yamauchi marked an inline comment as done.

Addressed comment.

sanjoy accepted this revision.Aug 9 2017, 6:33 PM

lgtm

lib/Analysis/LazyValueInfo.cpp
1377

I'd call this isOperationFoldable since we're not checking if Usr is foldable or not but only looking at its operation to see if it could possibly be constant folded.

1446–1449

s/checking the operands/linearly iterating over the operands unnecessarily/

s/large phi/instructions with many operands/ (I don't think "phi" is relevant here -- this could also have happened with a large call, invoke or GEP instruction).

1492

s/ValUsesConditionAndFoldable/ValUsesConditionAndMayBeFoldable/

This revision is now accepted and ready to land.Aug 9 2017, 6:33 PM
yamauchi updated this revision to Diff 110513.Aug 9 2017, 7:23 PM
yamauchi marked 3 inline comments as done.

Done.

yamauchi closed this revision.Aug 9 2017, 7:24 PM