[InstCombine] Guard against many users when swapping icmp operands
authorNikita Popov <npopov@redhat.com>
Mon, 27 Feb 2023 10:56:36 +0000 (11:56 +0100)
committerNikita Popov <npopov@redhat.com>
Mon, 27 Feb 2023 11:12:33 +0000 (12:12 +0100)
commit47f9109dff80a1abbe2705ee71dc0882b1d62274
tree13b1eba2b848a5855adf1a267a7b58981205a206
parent398cddf6acecfb12b5997c2d639ee3cf31b787ad
[InstCombine] Guard against many users when swapping icmp operands

This addresses the compile-time regression reported on D144369.
If we don't fold constant operands early, then we might end up
walking very large use lists of constants here. Explicitly exclude
constants, and also limit the number of inspected users to avoid
degenerate cases like this.

This entire transform shouldn't be part of InstCombine in the
first place though.
llvm/lib/Transforms/InstCombine/InstCombineCompares.cpp