[DAGCombine] Fold redundant select
authorSamuel Parker <sam.parker@arm.com>
Wed, 15 Feb 2023 10:32:16 +0000 (10:32 +0000)
committerSamuel Parker <sam.parker@arm.com>
Wed, 15 Feb 2023 10:32:16 +0000 (10:32 +0000)
commitc7f9344d0f8f6a00adab138037e2e7b406ef2b69
tree898cbccef072b7c376c4386e083a52d2dabf1c4a
parentc3228714cc0eec0cb9244922d713f495045e655d
[DAGCombine] Fold redundant select

Recommit bbdf24357932b064f2aa18ea1356b474e0220dde.

Original commit message:

If a chain of two selects share a true/false value and are controlled
by two setcc nodes, that are never both true, we can fold away one of
the selects. So, the following:
(select (setcc X, const0, eq), Y,
  (select (setcc X, const1, eq), Z, Y))

Can be combined to:
  select (setcc X, const1, eq) Z, Y

Differential Revision: https://reviews.llvm.org/D142535
llvm/lib/CodeGen/SelectionDAG/DAGCombiner.cpp
llvm/test/CodeGen/AArch64/redundant-select.ll [new file with mode: 0644]
llvm/test/CodeGen/RISCV/fpclamptosat_vec.ll
llvm/test/CodeGen/WebAssembly/fpclamptosat.ll
llvm/test/CodeGen/WebAssembly/fpclamptosat_vec.ll
llvm/test/CodeGen/X86/fpclamptosat_vec.ll