This is an archive of the discontinued LLVM Phabricator instance.

ConstantFoldInstruction: avoid wasted calls to ConstantFoldConstantExpression
ClosedPublic

Authored by escha on Mar 12 2016, 4:10 PM.

Details

Summary

The loop here calls ConstantFoldConstantExpression before knowing if all the operands are constant, which can waste a lot of time. Cuts time spent in ConstantFoldInstruction (and callees) by ~20% in our tests. Should be NFC.

Diff Detail

Repository
rL LLVM

Event Timeline

escha updated this revision to Diff 50530.Mar 12 2016, 4:10 PM
escha retitled this revision from to ConstantFoldInstruction: avoid wasted calls to ConstantFoldConstantExpression.
escha updated this object.
escha added a reviewer: resistor.
escha set the repository for this revision to rL LLVM.
escha added a subscriber: llvm-commits.
escha updated this revision to Diff 50531.Mar 12 2016, 4:36 PM

Use llvm::all_of.

majnemer accepted this revision.Mar 12 2016, 8:04 PM
majnemer added a reviewer: majnemer.
majnemer added a subscriber: majnemer.

LGTM with nits.

lib/Analysis/ConstantFolding.cpp
986

I don't think you need the llvm:: qualifier.
Also, I think clang-format would not have a space between the capture and the parameter.

This revision is now accepted and ready to land.Mar 12 2016, 8:04 PM
escha accepted this revision.Mar 12 2016, 9:43 PM
escha closed this revision.
escha added a reviewer: escha.