diff options
author | Tim Northover <tnorthover@apple.com> | 2014-07-23 13:59:12 +0000 |
---|---|---|
committer | Tim Northover <tnorthover@apple.com> | 2014-07-23 13:59:12 +0000 |
commit | 14ff2df05c241297f0139f46c825dc333eea4b9c (patch) | |
tree | 92aaedf747b72e7831feee41019ded4140aa8f7d /llvm/lib/Target/ARM | |
parent | 7ad2a0e0c2bc323649507e72b112ad2060be100c (diff) | |
download | bcm5719-llvm-14ff2df05c241297f0139f46c825dc333eea4b9c.tar.gz bcm5719-llvm-14ff2df05c241297f0139f46c825dc333eea4b9c.zip |
ARM: spot SBFX-compatbile code expressed with sign_extend_inreg
We were assuming all SBFX-like operations would have the shl/asr form, but
often when the field being extracted is an i8 or i16, we end up with a
SIGN_EXTEND_INREG acting on a shift instead. Simple enough to check for though.
llvm-svn: 213754
Diffstat (limited to 'llvm/lib/Target/ARM')
-rw-r--r-- | llvm/lib/Target/ARM/ARMISelDAGToDAG.cpp | 20 |
1 files changed, 20 insertions, 0 deletions
diff --git a/llvm/lib/Target/ARM/ARMISelDAGToDAG.cpp b/llvm/lib/Target/ARM/ARMISelDAGToDAG.cpp index 38547cfae2e..f41e4dfea72 100644 --- a/llvm/lib/Target/ARM/ARMISelDAGToDAG.cpp +++ b/llvm/lib/Target/ARM/ARMISelDAGToDAG.cpp @@ -2361,6 +2361,25 @@ SDNode *ARMDAGToDAGISel::SelectV6T2BitfieldExtractOp(SDNode *N, return CurDAG->SelectNodeTo(N, Opc, MVT::i32, Ops); } } + + if (N->getOpcode() == ISD::SIGN_EXTEND_INREG) { + unsigned Width = cast<VTSDNode>(N->getOperand(1))->getVT().getSizeInBits(); + unsigned LSB = 0; + if (!isOpcWithIntImmediate(N->getOperand(0).getNode(), ISD::SRL, LSB) && + !isOpcWithIntImmediate(N->getOperand(0).getNode(), ISD::SRA, LSB)) + return nullptr; + + if (LSB + Width > 32) + return nullptr; + + SDValue Reg0 = CurDAG->getRegister(0, MVT::i32); + SDValue Ops[] = { N->getOperand(0).getOperand(0), + CurDAG->getTargetConstant(LSB, MVT::i32), + CurDAG->getTargetConstant(Width - 1, MVT::i32), + getAL(CurDAG), Reg0 }; + return CurDAG->SelectNodeTo(N, Opc, MVT::i32, Ops); + } + return nullptr; } @@ -2509,6 +2528,7 @@ SDNode *ARMDAGToDAGISel::Select(SDNode *N) { if (SDNode *I = SelectV6T2BitfieldExtractOp(N, false)) return I; break; + case ISD::SIGN_EXTEND_INREG: case ISD::SRA: if (SDNode *I = SelectV6T2BitfieldExtractOp(N, true)) return I; |