[InstCombine] Fold more intrinsics over selects
authorNikita Popov <npopov@redhat.com>
Fri, 31 Mar 2023 11:27:02 +0000 (13:27 +0200)
committerNikita Popov <npopov@redhat.com>
Fri, 31 Mar 2023 14:32:21 +0000 (16:32 +0200)
commit6261adfa51f2d93c8258e7b2d9811d607f3e50a5
tree9febd8f3e765605933907a3a77105e0559ee1441
parent943ef06420105cad23e3caea24d6a274cdb0316f
[InstCombine] Fold more intrinsics over selects

Move this handling to a centralized place and extend it to handle
saturating add/sub intrinsics.

I originally wanted to make this fully generic rather than
whitelist based, because this is legal and likely profitable for all
speculatable intrinsics. The caveat is that for vector selects,
the intrinsic can't perform cross-lane operations like a shuffle
or reduction, which we don't really expose as a generic property
right now. So for now I'm just extending the list.
llvm/lib/Transforms/InstCombine/InstCombineCalls.cpp
llvm/lib/Transforms/InstCombine/InstructionCombining.cpp
llvm/test/Transforms/InstCombine/intrinsic-select.ll