[X86] Don't match TESTrr from (cmp (and X, Y), 0) during isel. Defer to post processing
authorCraig Topper <craig.topper@intel.com>
Wed, 19 Dec 2018 18:49:13 +0000 (18:49 +0000)
committerCraig Topper <craig.topper@intel.com>
Wed, 19 Dec 2018 18:49:13 +0000 (18:49 +0000)
commit84a00bd98a11011e8a0f2367c31988078b62e5ab
treebb184b3c2e9dfe92d1e11cb991f8d53b0d008371
parent291470347a2e4d7b6aa0ecb854e61f074cc80590
[X86] Don't match TESTrr from (cmp (and X, Y), 0) during isel. Defer to post processing

The (cmp (and X, Y) 0) pattern is greedy and ends up forming a TESTrr and consuming the and when it might be better to use one of the BMI/TBM like BLSR or BLSI.

This patch moves removes the pattern from isel and adds a post processing check to combine TESTrr+ANDrr into just a TESTrr. With this patch we are able to select the BMI/TBM instructions, but we'll also emit a TESTrr when the result is compared to 0. In many cases the peephole pass will be able to use optimizeCompareInstr to remove the TEST, but its probably not perfect.

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

llvm-svn: 349661
llvm/lib/Target/X86/X86ISelDAGToDAG.cpp
llvm/lib/Target/X86/X86InstrArithmetic.td
llvm/test/CodeGen/X86/bmi.ll
llvm/test/CodeGen/X86/tbm_patterns.ll