[DAGCombine] Fold redundant select
authorSamuel Parker <sam.parker@arm.com>
Mon, 30 Jan 2023 09:36:15 +0000 (09:36 +0000)
committerSamuel Parker <sam.parker@arm.com>
Thu, 2 Feb 2023 09:43:21 +0000 (09:43 +0000)
commitbbdf24357932b064f2aa18ea1356b474e0220dde
tree147bfd65abc9222b9b8cad302fc09e47a71af295
parent46dc3d0b9b70bbe5def0c404975a3775976122b7
[DAGCombine] Fold redundant select

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/ARM/fpclamptosat.ll
llvm/test/CodeGen/ARM/fpclamptosat_vec.ll
llvm/test/CodeGen/RISCV/fpclamptosat.ll
llvm/test/CodeGen/RISCV/fpclamptosat_vec.ll
llvm/test/CodeGen/Thumb2/mve-fpclamptosat_vec.ll
llvm/test/CodeGen/WebAssembly/fpclamptosat.ll
llvm/test/CodeGen/WebAssembly/fpclamptosat_vec.ll
llvm/test/CodeGen/X86/fpclamptosat.ll
llvm/test/CodeGen/X86/fpclamptosat_vec.ll
llvm/test/CodeGen/X86/sdiv_fix_sat.ll