summaryrefslogtreecommitdiffstats
path: root/llvm/lib
diff options
context:
space:
mode:
authorLang Hames <lhames@gmail.com>2014-04-21 08:18:53 +0000
committerLang Hames <lhames@gmail.com>2014-04-21 08:18:53 +0000
commit5aa6ee80b699c2afc1e185148846e75af97eff98 (patch)
tree3280ecaf4503871888e275a1eb0205f629a9296b /llvm/lib
parent589441820e5047ebb64a91cebb283500dbc9d481 (diff)
downloadbcm5719-llvm-5aa6ee80b699c2afc1e185148846e75af97eff98.tar.gz
bcm5719-llvm-5aa6ee80b699c2afc1e185148846e75af97eff98.zip
[X86] ISEL (and X, <constant mask>) to BZHI when BMI2 is available.
Generating BZHI in the variable mask case, i.e. (and X, (sub (shl 1, N), 1)), was already supported, but we were missing the constant-mask case. This patch fixes that. <rdar://problem/15480077> llvm-svn: 206738
Diffstat (limited to 'llvm/lib')
-rw-r--r--llvm/lib/Target/X86/X86ISelLowering.cpp14
1 files changed, 14 insertions, 0 deletions
diff --git a/llvm/lib/Target/X86/X86ISelLowering.cpp b/llvm/lib/Target/X86/X86ISelLowering.cpp
index 306fb7e199d..d867414a98d 100644
--- a/llvm/lib/Target/X86/X86ISelLowering.cpp
+++ b/llvm/lib/Target/X86/X86ISelLowering.cpp
@@ -18503,6 +18503,20 @@ static SDValue PerformAndCombine(SDNode *N, SelectionDAG &DAG,
}
} // BEXTR
+ // Check for BZHI with contiguous mask: (and X, 0x0..0f..f)
+ // This should be checked after BEXTR - when X is a shift, a BEXTR is
+ // preferrable.
+ if (Subtarget->hasBMI2()) {
+ if (ConstantSDNode *C = dyn_cast<ConstantSDNode>(N1)) {
+ uint64_t Mask = C->getZExtValue();
+ if (isMask_64(Mask)) {
+ unsigned LZ = CountTrailingOnes_64(Mask);
+ return DAG.getNode(X86ISD::BZHI, DL, VT, N0,
+ DAG.getConstant(LZ, MVT::i8));
+ }
+ }
+ }
+
return SDValue();
}
OpenPOWER on IntegriCloud