mirror of
https://github.com/c64scene-ar/llvm-6502.git
synced 2025-07-30 02:25:19 +00:00
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. git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@213754 91177308-0d34-0410-b5e6-96231b3b80d8
This commit is contained in:
@@ -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;
|
||||
|
Reference in New Issue
Block a user