summaryrefslogtreecommitdiff
path: root/lib/Target
diff options
context:
space:
mode:
authorRichard Sandiford <rsandifo@linux.vnet.ibm.com>2013-12-06 09:56:50 +0000
committerRichard Sandiford <rsandifo@linux.vnet.ibm.com>2013-12-06 09:56:50 +0000
commit8bf51dc72bffd9a2e2fcc3d3e0215c859eb1d60f (patch)
treef0777e41bbb52fea983f97eecd72d83ed1e8a4ab /lib/Target
parente3a804ba21634f835a4bbfba0ca44dbb1c21ea9d (diff)
downloadllvm-8bf51dc72bffd9a2e2fcc3d3e0215c859eb1d60f.tar.gz
llvm-8bf51dc72bffd9a2e2fcc3d3e0215c859eb1d60f.tar.bz2
llvm-8bf51dc72bffd9a2e2fcc3d3e0215c859eb1d60f.tar.xz
[SystemZ] Extend the use of C(L)GFR
instcombine prefers to put extended operands first, so this patch handles that case for C(L)GFR. git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@196579 91177308-0d34-0410-b5e6-96231b3b80d8
Diffstat (limited to 'lib/Target')
-rw-r--r--lib/Target/SystemZ/SystemZISelLowering.cpp21
1 files changed, 19 insertions, 2 deletions
diff --git a/lib/Target/SystemZ/SystemZISelLowering.cpp b/lib/Target/SystemZ/SystemZISelLowering.cpp
index 0340a876ee..f4a6b2406c 100644
--- a/lib/Target/SystemZ/SystemZISelLowering.cpp
+++ b/lib/Target/SystemZ/SystemZISelLowering.cpp
@@ -1207,10 +1207,14 @@ static bool shouldSwapCmpOperands(SDValue Op0, SDValue Op1,
if (COp1 && COp1->getZExtValue() == 0)
return false;
+ // Also keep natural memory operands second if the loaded value is
+ // only used here. Several comparisons have memory forms.
+ if (isNaturalMemoryOperand(Op1, ICmpType) && Op1.hasOneUse())
+ return false;
+
// Look for cases where Cmp0 is a single-use load and Cmp1 isn't.
// In that case we generally prefer the memory to be second.
- if ((isNaturalMemoryOperand(Op0, ICmpType) && Op0.hasOneUse()) &&
- !(isNaturalMemoryOperand(Op1, ICmpType) && Op1.hasOneUse())) {
+ if (isNaturalMemoryOperand(Op0, ICmpType) && Op0.hasOneUse()) {
// The only exceptions are when the second operand is a constant and
// we can use things like CHHSI.
if (!COp1)
@@ -1227,6 +1231,19 @@ static bool shouldSwapCmpOperands(SDValue Op0, SDValue Op1,
return false;
return true;
}
+
+ // Try to promote the use of CGFR and CLGFR.
+ unsigned Opcode0 = Op0.getOpcode();
+ if (ICmpType != SystemZICMP::UnsignedOnly && Opcode0 == ISD::SIGN_EXTEND)
+ return true;
+ if (ICmpType != SystemZICMP::SignedOnly && Opcode0 == ISD::ZERO_EXTEND)
+ return true;
+ if (ICmpType != SystemZICMP::SignedOnly &&
+ Opcode0 == ISD::AND &&
+ Op0.getOperand(1).getOpcode() == ISD::Constant &&
+ cast<ConstantSDNode>(Op0.getOperand(1))->getZExtValue() == 0xffffffff)
+ return true;
+
return false;
}