diff options
author | Weiming Zhao <weimingz@codeaurora.org> | 2014-05-13 00:40:58 +0000 |
---|---|---|
committer | Weiming Zhao <weimingz@codeaurora.org> | 2014-05-13 00:40:58 +0000 |
commit | 0449d522a66512af6e7b999d46445c7f7e4b8536 (patch) | |
tree | a13fa03ee781ae3062773d6ea6fc7aaa9188cb0f /lib | |
parent | 5204fedd35f17c093dcdc90b759b416aaa7fa977 (diff) | |
download | llvm-0449d522a66512af6e7b999d46445c7f7e4b8536.tar.gz llvm-0449d522a66512af6e7b999d46445c7f7e4b8536.tar.bz2 llvm-0449d522a66512af6e7b999d46445c7f7e4b8536.tar.xz |
Folding into CSEL when there is ZEXT between SETCC and ADD
Normally, patterns like (add x, (setcc cc ...)) will be folded into
(csel x, x+1, not cc). However, if there is a ZEXT after SETCC, they
won't be folded. This patch recognizes the ZEXT and allows the
generation of CSINC.
This patch fixes bug 19680.
git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@208660 91177308-0d34-0410-b5e6-96231b3b80d8
Diffstat (limited to 'lib')
-rw-r--r-- | lib/Target/ARM64/ARM64ISelLowering.cpp | 14 |
1 files changed, 11 insertions, 3 deletions
diff --git a/lib/Target/ARM64/ARM64ISelLowering.cpp b/lib/Target/ARM64/ARM64ISelLowering.cpp index 1d27e86e21..546343a0fe 100644 --- a/lib/Target/ARM64/ARM64ISelLowering.cpp +++ b/lib/Target/ARM64/ARM64ISelLowering.cpp @@ -6600,8 +6600,16 @@ static bool isSetCC(SDValue Op, SetCCInfoAndKind &SetCCInfo) { return TValue->isOne() && FValue->isNullValue(); } +// Returns true if Op is setcc or zext of setcc. +static bool isSetCCOrZExtSetCC(const SDValue& Op, SetCCInfoAndKind &Info) { + if (isSetCC(Op, Info)) + return true; + return ((Op.getOpcode() == ISD::ZERO_EXTEND) && + isSetCC(Op->getOperand(0), Info)); +} + // The folding we want to perform is: -// (add x, (setcc cc ...) ) +// (add x, [zext] (setcc cc ...) ) // --> // (csel x, (add x, 1), !cc ...) // @@ -6613,9 +6621,9 @@ static SDValue performSetccAddFolding(SDNode *Op, SelectionDAG &DAG) { SetCCInfoAndKind InfoAndKind; // If neither operand is a SET_CC, give up. - if (!isSetCC(LHS, InfoAndKind)) { + if (!isSetCCOrZExtSetCC(LHS, InfoAndKind)) { std::swap(LHS, RHS); - if (!isSetCC(LHS, InfoAndKind)) + if (!isSetCCOrZExtSetCC(LHS, InfoAndKind)) return SDValue(); } |