Skip to content

Commit 0139ebe

Browse files
committed
Address review comments and add i64 bounds tests
1 parent df6e831 commit 0139ebe

File tree

3 files changed

+300
-132
lines changed

3 files changed

+300
-132
lines changed

llvm/lib/Target/AArch64/AArch64ISelDAGToDAG.cpp

Lines changed: 3 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -508,7 +508,6 @@ class AArch64DAGToDAGISel : public SelectionDAGISel {
508508
bool SelectAllActivePredicate(SDValue N);
509509
bool SelectAnyPredicate(SDValue N);
510510

511-
template <int Bits>
512511
bool SelectCmpBranchUImm6Operand(SDNode *P, SDValue N, SDValue &Imm);
513512
};
514513

@@ -7493,14 +7492,10 @@ bool AArch64DAGToDAGISel::SelectSMETileSlice(SDValue N, unsigned MaxSize,
74937492
return true;
74947493
}
74957494

7496-
template <int Bits>
74977495
bool AArch64DAGToDAGISel::SelectCmpBranchUImm6Operand(SDNode *P, SDValue N,
74987496
SDValue &Imm) {
7499-
ConstantSDNode *C = dyn_cast<ConstantSDNode>(P->getOperand(1));
7500-
if (!C)
7501-
return false;
7502-
7503-
AArch64CC::CondCode CC = static_cast<AArch64CC::CondCode>(C->getZExtValue());
7497+
AArch64CC::CondCode CC =
7498+
static_cast<AArch64CC::CondCode>(P->getConstantOperandVal(1));
75047499
if (auto *CN = dyn_cast<ConstantSDNode>(N)) {
75057500
// Check conservatively if the immediate fits the valid range [0, 64).
75067501
// Immediate variants for GE and HS definitely need to be decremented
@@ -7538,8 +7533,7 @@ bool AArch64DAGToDAGISel::SelectCmpBranchUImm6Operand(SDNode *P, SDValue N,
75387533
if (CN->getAPIntValue().uge(LowerBound) &&
75397534
CN->getAPIntValue().ult(UpperBound)) {
75407535
SDLoc DL(N);
7541-
Imm = CurDAG->getTargetConstant(CN->getZExtValue(), DL,
7542-
Bits == 32 ? MVT::i32 : MVT::i64);
7536+
Imm = CurDAG->getTargetConstant(CN->getZExtValue(), DL, N.getValueType());
75437537
return true;
75447538
}
75457539
}

llvm/lib/Target/AArch64/AArch64InstrFormats.td

Lines changed: 2 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -401,16 +401,12 @@ def uimm6_32b : Operand<i32>, ImmLeaf<i32, [{ return Imm >= 0 && Imm < 64; }]> {
401401
}
402402

403403
def CmpBranchUImm6Operand_32b
404-
: Operand<i32>,
405-
ComplexPattern<i32, 1, "SelectCmpBranchUImm6Operand<32>"> {
406-
let ParserMatchClass = UImm6Operand;
404+
: ComplexPattern<i32, 1, "SelectCmpBranchUImm6Operand", [imm]> {
407405
let WantsParent = true;
408406
}
409407

410408
def CmpBranchUImm6Operand_64b
411-
: Operand<i64>,
412-
ComplexPattern<i64, 1, "SelectCmpBranchUImm6Operand<64>"> {
413-
let ParserMatchClass = UImm6Operand;
409+
: ComplexPattern<i64, 1, "SelectCmpBranchUImm6Operand", [imm]> {
414410
let WantsParent = true;
415411
}
416412

0 commit comments

Comments
 (0)