DAG combine "and|or (select c, -1, 0), x" -> "select c, x, 0|-1"
authorStanislav Mekhanoshin <Stanislav.Mekhanoshin@amd.com>
Thu, 21 Jun 2018 16:02:05 +0000 (16:02 +0000)
committerStanislav Mekhanoshin <Stanislav.Mekhanoshin@amd.com>
Thu, 21 Jun 2018 16:02:05 +0000 (16:02 +0000)
commit22ee191c3ea92dd7054975c9e9074fbf3c3825f5
treea6ced5032526de4ef2d8e59d379fe05ec0a49acc
parent21a2973cc4c2d803ff680190a2ee17c15fb587dc
DAG combine "and|or (select c, -1, 0), x" -> "select c, x, 0|-1"

Allowed folding for "and/or" binops with non-constant operand if
arguments of select are 0/-1 values.

Normally this code with "and" opcode does not get to a DAG combiner
and simplified yet in the InstCombine. However AMDGPU produces it
during lowering and InstCombine has no chance to optimize it out.

In turn the same pattern with "or" opcode can reach DAG.

Differential Revision: https://reviews.llvm.org/D48301

llvm-svn: 335250
llvm/lib/CodeGen/SelectionDAG/DAGCombiner.cpp
llvm/test/CodeGen/AMDGPU/dagcombine-select.ll
llvm/test/CodeGen/AMDGPU/udivrem.ll
llvm/test/CodeGen/X86/dagcombine-select.ll