[X86] Prevent LowerSELECT from causing suboptimal codegen for __builtin_ffs(X) - 1.
authorCraig Topper <craig.topper@intel.com>
Mon, 8 Jun 2020 18:26:11 +0000 (11:26 -0700)
committerCraig Topper <craig.topper@intel.com>
Mon, 8 Jun 2020 18:46:56 +0000 (11:46 -0700)
commit2328cab16ccd8f17fee782c29fb844662c089fbb
treec6999269b860c58bd7fab4735db51b245c335131
parentf3d8a9397003b6645f19a4dd11cc1165ce75bd7d
[X86] Prevent LowerSELECT from causing suboptimal codegen for __builtin_ffs(X) - 1.

LowerSELECT sees the CMP with 0 and wants to use a trick with SUB
and SBB. But we can use the flags from the BSF/TZCNT.

Fixes PR46203.

Differential Revision: https://reviews.llvm.org/D81312
llvm/lib/Target/X86/X86ISelLowering.cpp
llvm/test/CodeGen/X86/dagcombine-select.ll