]> granicus.if.org Git - llvm/commit
[X86] Move matching of (and (srl/sra, C), (1<<C) - 1) to BEXTR/BEXTRI instruction...
authorCraig Topper <craig.topper@intel.com>
Tue, 12 Sep 2017 17:40:25 +0000 (17:40 +0000)
committerCraig Topper <craig.topper@intel.com>
Tue, 12 Sep 2017 17:40:25 +0000 (17:40 +0000)
commita0e0fb714cd7fa34ae06b163164cfb9a3e409541
tree4e85cefbfc2da9822261ce01c615a628ef340cfb
parentf983a56642416b2978dbd99d3839f791138f64a6
[X86] Move matching of (and (srl/sra, C), (1<<C) - 1) to BEXTR/BEXTRI instruction to custom isel

Recognizing this pattern during DAG combine hides information about the 'and' and the shift from other combines. I think it should be recognized at isel so its as late as possible. But it can't be done with table based isel because you need to be able to look at both immediates. This patch moves it to custom isel in X86ISelDAGToDAG.cpp.

This does break a couple tests in tbm_patterns because we are now emitting an and_flag node or (cmp and, 0) that we dont' recognize yet. We already had this problem for several other TBM patterns so I think this fine and we can address of them together.

I've also fixed a bug where the combine to BEXTR was preventing us from using a trick of zero extending AH to handle extracts of bits 15:8. We might still want to use BEXTR if it enables load folding. But honestly I hope we narrowed the load instead before got to isel.

I think we should probably also support matching BEXTR from (srl/srl (and mask << C), C). But that should be a different patch.

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

git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@313054 91177308-0d34-0410-b5e6-96231b3b80d8
lib/Target/X86/X86ISelDAGToDAG.cpp
lib/Target/X86/X86ISelLowering.cpp
lib/Target/X86/X86ISelLowering.h
lib/Target/X86/X86InstrInfo.td
test/CodeGen/X86/bmi.ll
test/CodeGen/X86/tbm_patterns.ll