summaryrefslogtreecommitdiffstats
path: root/llvm/lib
diff options
context:
space:
mode:
authorRoman Lebedev <lebedev.ri@gmail.com>2018-05-07 21:52:11 +0000
committerRoman Lebedev <lebedev.ri@gmail.com>2018-05-07 21:52:11 +0000
commitcc42d08b1daf6874e7b65986443510bfc5e0abc3 (patch)
treeade7212a0b263366809902766925ee60d779acd4 /llvm/lib
parent45fc2c83e60265f3772ba86b9b832f3d540ef049 (diff)
downloadbcm5719-llvm-cc42d08b1daf6874e7b65986443510bfc5e0abc3.tar.gz
bcm5719-llvm-cc42d08b1daf6874e7b65986443510bfc5e0abc3.zip
[DagCombiner] Not all 'andn''s work with immediates.
Summary: Split off from D46031. In masked merge case, this degrades IPC by decreasing instruction count. {F6108777} The next patch should be able to recover and improve this. This also affects the transform @spatel have added in D27489 / rL289738, and the test coverage for X86 was missing. But after i have added it, and looked at the changes in MCA, i'm somewhat confused. {F6093591} {F6093592} {F6093593} I'd say this regression is an improvement, since `IPC` increased in that case? Reviewers: spatel, craig.topper Reviewed By: spatel Subscribers: andreadb, llvm-commits, spatel Differential Revision: https://reviews.llvm.org/D46493 llvm-svn: 331684
Diffstat (limited to 'llvm/lib')
-rw-r--r--llvm/lib/CodeGen/SelectionDAG/DAGCombiner.cpp4
-rw-r--r--llvm/lib/Target/X86/X86ISelLowering.cpp11
-rw-r--r--llvm/lib/Target/X86/X86ISelLowering.h2
3 files changed, 17 insertions, 0 deletions
diff --git a/llvm/lib/CodeGen/SelectionDAG/DAGCombiner.cpp b/llvm/lib/CodeGen/SelectionDAG/DAGCombiner.cpp
index 322e9be0083..b809bbc1c6c 100644
--- a/llvm/lib/CodeGen/SelectionDAG/DAGCombiner.cpp
+++ b/llvm/lib/CodeGen/SelectionDAG/DAGCombiner.cpp
@@ -5428,6 +5428,10 @@ SDValue DAGCombiner::unfoldMaskedMerge(SDNode *N) {
if (!TLI.hasAndNot(M))
return SDValue();
+ // If Y is a constant, check that 'andn' works with immediates.
+ if (!TLI.hasAndNot(Y))
+ return SDValue();
+
SDLoc DL(N);
SDValue LHS = DAG.getNode(ISD::AND, DL, VT, X, M);
diff --git a/llvm/lib/Target/X86/X86ISelLowering.cpp b/llvm/lib/Target/X86/X86ISelLowering.cpp
index 128faffd7cd..0c75fd78dd7 100644
--- a/llvm/lib/Target/X86/X86ISelLowering.cpp
+++ b/llvm/lib/Target/X86/X86ISelLowering.cpp
@@ -4743,6 +4743,9 @@ bool X86TargetLowering::isMaskAndCmp0FoldingBeneficial(
}
bool X86TargetLowering::hasAndNotCompare(SDValue Y) const {
+ // A mask and compare against constant is ok for an 'andn' too
+ // even though the BMI instruction doesn't have an immediate form.
+
if (!Subtarget.hasBMI())
return false;
@@ -4754,6 +4757,14 @@ bool X86TargetLowering::hasAndNotCompare(SDValue Y) const {
return true;
}
+bool X86TargetLowering::hasAndNot(SDValue Y) const {
+ // x86 can't form 'andn' with an immediate.
+ if (isa<ConstantSDNode>(Y))
+ return false;
+
+ return hasAndNotCompare(Y);
+}
+
MVT X86TargetLowering::hasFastEqualityCompare(unsigned NumBits) const {
MVT VT = MVT::getIntegerVT(NumBits);
if (isTypeLegal(VT))
diff --git a/llvm/lib/Target/X86/X86ISelLowering.h b/llvm/lib/Target/X86/X86ISelLowering.h
index e12585ab67e..58d0c9d92af 100644
--- a/llvm/lib/Target/X86/X86ISelLowering.h
+++ b/llvm/lib/Target/X86/X86ISelLowering.h
@@ -834,6 +834,8 @@ namespace llvm {
bool hasAndNotCompare(SDValue Y) const override;
+ bool hasAndNot(SDValue Y) const override;
+
bool convertSetCCLogicToBitwiseLogic(EVT VT) const override {
return VT.isScalarInteger();
}
OpenPOWER on IntegriCloud