[ConstantFold] Supports compares in ConstantFoldInstOperands()
authorNikita Popov <npopov@redhat.com>
Thu, 30 Jun 2022 09:02:36 +0000 (11:02 +0200)
committerNikita Popov <npopov@redhat.com>
Thu, 30 Jun 2022 09:05:24 +0000 (11:05 +0200)
commita6d4b4138ffcffabfacef12d1d903a44882ec933
treeda65e048f3ff32a3bb0f429f71fa92fb91ae3575
parented7d351309f7b1e87062b87b4ba8fa9eb324420a
[ConstantFold] Supports compares in ConstantFoldInstOperands()

Support compares in ConstantFoldInstOperands(), instead of
forcing the use of ConstantFoldCompareInstOperands(). Also handle
insertvalue (extractvalue was already handled).

This removes a footgun, where many uses of ConstantFoldInstOperands()
need a separate check for compares beforehand. It's particularly
insidious if called on a constant expression, because it doesn't
fail in that case, but will just not do DL-dependent folding.
llvm/lib/Analysis/ConstantFolding.cpp
llvm/lib/Analysis/InstructionSimplify.cpp
llvm/lib/Analysis/ScalarEvolution.cpp
llvm/lib/Transforms/Utils/SimplifyCFG.cpp