Skip to content

Commit e2d552c

Browse files
committed
Update ARMISelLowering.cpp
1 parent 146e3a8 commit e2d552c

File tree

1 file changed

+26
-2
lines changed

1 file changed

+26
-2
lines changed

llvm/lib/Target/ARM/ARMISelLowering.cpp

Lines changed: 26 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -20242,8 +20242,32 @@ static bool optimizeLogicalImm(SDValue Op, unsigned Imm, const APInt &Demanded,
2024220242
// Otherwise, create a machine node so that target independent DAG combine
2024320243
// doesn't undo this optimization.
2024420244
} else {
20245-
// Temporarily disable this optimization to avoid crashes
20246-
return false;
20245+
// bic/orn/eon
20246+
if (isLegalLogicalImmediate(NewImm, Subtarget)) {
20247+
SDValue EncConst = TLO.DAG.getTargetConstant(NewImm, DL, VT);
20248+
New = SDValue(
20249+
TLO.DAG.getMachineNode(NewOpc, DL, VT, Op.getOperand(0), EncConst),
20250+
0);
20251+
} else if ((Op.getOpcode() == ISD::AND ||
20252+
(Subtarget->isThumb2() && Op.getOpcode() == ISD::OR)) &&
20253+
isLegalLogicalImmediate(~NewImm, Subtarget)) {
20254+
20255+
if (Op.getOpcode() == ISD::OR) {
20256+
// ORN
20257+
NewOpc = ARM::t2ORNri;
20258+
} else {
20259+
// AND -> BIC
20260+
NewOpc = Subtarget->isThumb()
20261+
? Subtarget->isThumb2() ? ARM::t2BICri : ARM::tBIC
20262+
: ARM::BICri;
20263+
}
20264+
SDValue EncConst = TLO.DAG.getTargetConstant(~NewImm, DL, VT);
20265+
New = SDValue(
20266+
TLO.DAG.getMachineNode(NewOpc, DL, VT, Op.getOperand(0), EncConst),
20267+
0);
20268+
} else {
20269+
return false;
20270+
}
2024720271
}
2024820272

2024920273
return TLO.CombineTo(Op, New);

0 commit comments

Comments
 (0)