[PATCH] D154579: [InstCombine] Only perform one iteration

Nikita Popov via Phabricator via llvm-commits llvm-commits at lists.llvm.org
Fri Jul 7 01:52:17 PDT 2023


nikic added a comment.

In D154579#4477942 <https://reviews.llvm.org/D154579#4477942>, @goldstein.w.n wrote:

>> All instructions are initially pushed to the worklist. The initial order is (roughly) in program order / RPO.
>> All newly inserted instructions get added to the worklist.
>> When an instruction is folded, its users get added back to the worklist.
>> When the use-count of an instruction decreases, it gets added back to the worklist.
>> ...plus a bunch of other heuristics on when we should revisit instructions.
>
> What does it look like if instead of decreasing iteration count, we change re-insertion
> logic based on iteration?
> I.e:
> iteration 1 -> do everything
> iteration 2+ -> only re-add newly created insn or insn that are now single-use.

I don't think I understand your suggestion here. This sparse reprocessing is what the worklist is for -- and we do want to perform the reprocessing as part of the same iteration, not a later one, to make sure that folds working on later instructions see already folded operands, even if arriving at them requires multiple folds. If we delayed all reprocessing until a second iteration, folds would see operands after a single round of folding was applied to them, rather than in their final form.


CHANGES SINCE LAST ACTION
  https://reviews.llvm.org/D154579/new/

https://reviews.llvm.org/D154579



More information about the llvm-commits mailing list