This is an archive of the discontinued LLVM Phabricator instance.

[InstSimplify] Don't call the heavy ConstantFoldInstruction for loads. Use the lighter ConstantFoldLoadFromConstPtr
AbandonedPublic

Authored by craig.topper on May 26 2017, 5:38 PM.

Details

Summary

Load instructions go through the default case of SimplifyInstruction and use the heavy ConstantFoldInstruction which tries to recursively constant fold any constantexpr operands. I believe this is harder than we try for other instructions in InstSimplify. We usually use some entry point like ConstantFoldBinaryOpOperands or ConstantFoldCompareInstOperands which bypass this logic.

This patch calls directly to ConstantFoldLoadFromConstPtr if the load has a constant pointer and isn't volatile.

On one benchmark cpp file I ran through callgrind, this showed instructions executed in SimplifyInstruction reduce by almost half.

Diff Detail

Event Timeline

craig.topper created this revision.May 26 2017, 5:38 PM
craig.topper abandoned this revision.Jun 9 2017, 3:04 PM

This seems to increase compile time on some tests. Abandoning while i figure out why.