[InstCombine] Revisit user of newly one-use instructions
authorNikita Popov <npopov@redhat.com>
Wed, 31 May 2023 14:09:06 +0000 (16:09 +0200)
committerNikita Popov <npopov@redhat.com>
Wed, 14 Jun 2023 07:12:30 +0000 (09:12 +0200)
commitf7a977c7b3b4d8efebb92ed803585168df369831
tree09fffc42c122461e6e220b337e7c1c759663d64d
parent804306b382152017861f6cacc54d3d4d4c2e9076
[InstCombine] Revisit user of newly one-use instructions

Many folds in InstCombine are limited to one-use instructions. For
that reason, if the use-count of an instruction drops to one, it
makes sense to revisit that one user. This is one of the most
common reasons why InstCombine fails to finish in a single iteration.

Doing this revisit actually slightly improves compile-time, because
we save an extra InstCombine iteration in enough cases to make a
visible difference.

This is conceptually NFC, but not NFC in practice, because differences
in worklist order can result in slightly different folding behavior.

The regressed tests in or-shifted-masks.ll now require a sequence of
instcombine,early-cse,instcombine to fold fully. D152876 would make
these fold in a single instcombine run again.

Differential Revision: https://reviews.llvm.org/D151807
llvm/include/llvm/Transforms/Utils/InstructionWorklist.h
llvm/lib/Transforms/InstCombine/InstCombineInternal.h
llvm/test/Other/print-debug-counter.ll
llvm/test/Transforms/InstCombine/or-shifted-masks.ll