[PATCH] D79294: [InstSimplify] Remove known bits constant folding
Nikita Popov via Phabricator via llvm-commits
llvm-commits at lists.llvm.org
Sat May 2 12:42:51 PDT 2020
nikic created this revision.
nikic added reviewers: spatel, lebedev.ri.
Herald added a project: LLVM.
Herald added a subscriber: llvm-commits.
If SimplifyInstruction() does not succeed in simplifying the instruction, it will compute the known bits of the instruction in the hope that all bits are known and the instruction can be folded to a constant. I have removed a similar optimization from InstCombine in D75801 <https://reviews.llvm.org/D75801>, and would like to drop this one as well.
On average, we spend 1% of total compile-time <http://llvm-compile-time-tracker.com/compare.php?from=8148b116474614c176d69de8c246fc21494faf5f&to=7474795d8138e491979f56e64b789f1459cc349b&stat=instructions> performing this known bits calculation. However, if we introduce some additional statistics for known bits computations and how many of them succeed in simplifying the instruction we get (on test-suite):
instsimplify.NumKnownBits: 216
instsimplify.NumKnownBitsComputed: 13828375
valuetracking.NumKnownBitsComputed: 45860806
Out of ~14M known bits calculations (accounting for approximately one third of all known bits calculations), only 0.0015% succeed in producing a constant. Those cases where we do succeed to compute all known bits will get folded by other passes like InstCombine later. On test-suite, only `lencod.test` and `GCC-C-execute-pr44858.test` show a hash difference after this change.
There are of course "regressions" in InstSimplify tests, because some things that were previously handled by InstSimplify are now only handled by InstCombine. I will comment inline.
One final thing to note here is that all this affects only the SimplifyInstruction() API, not the individual per-instruction-kind Simplify APIs, which never try to use KnownBits in this way.
Repository:
rG LLVM Github Monorepo
https://reviews.llvm.org/D79294
Files:
lib/Analysis/InstructionSimplify.cpp
test/Analysis/ValueTracking/knownnonzero-shift.ll
test/Analysis/ValueTracking/knownzero-shift.ll
test/Transforms/GVN/PRE/volatile.ll
test/Transforms/InstSimplify/assume.ll
test/Transforms/InstSimplify/call.ll
test/Transforms/InstSimplify/or.ll
test/Transforms/InstSimplify/shift-knownbits.ll
-------------- next part --------------
A non-text attachment was scrubbed...
Name: D79294.261655.patch
Type: text/x-patch
Size: 11434 bytes
Desc: not available
URL: <http://lists.llvm.org/pipermail/llvm-commits/attachments/20200502/c51d74fe/attachment.bin>
More information about the llvm-commits
mailing list