Reapply [InstSimplify] Support all instructions in simplifyWithOpReplaced()
authorNikita Popov <npopov@redhat.com>
Mon, 24 Apr 2023 13:22:20 +0000 (15:22 +0200)
committerNikita Popov <npopov@redhat.com>
Tue, 25 Apr 2023 13:45:32 +0000 (15:45 +0200)
commit9d92f479c3fb708ea0cad8aa6fa70fd46f753123
tree333a1c4a45de1ab41d88376f6026ea223f5c6b55
parente50b4ea8be0bdd48fb1ab6b9ab659ae02eaaa318
Reapply [InstSimplify] Support all instructions in simplifyWithOpReplaced()

Relative to the previous attempt, this includes a bailout for phi
nodes, whose arguments might refer to a previous cycle iteration.

We did not hit this before by a fortunate deficiency of the
ConstantFoldInstOperands() API, which doesn't handle phi nodes,
unlike ConstantFoldInstruction().

-----

Instead of hardcoding a few instruction kinds, use the generic
interface now that we have it.

The primary effect of this is that intrinsics are now supported.

It's worth noting that this is still limited in that it does not
support vectors, so we can't remove e.g. existing fshl special
cases.
llvm/lib/Analysis/InstructionSimplify.cpp
llvm/test/Transforms/InstSimplify/select-maxmin.ll