Skip to content

Commit 8b49091

Browse files
committed
[Sparc] Use getSignedConstant() where necessary
This avoids assertion failures once we disable implicit truncation in getConstant().
1 parent 2e07c2b commit 8b49091

File tree

3 files changed

+8
-8
lines changed

3 files changed

+8
-8
lines changed

llvm/lib/Target/Sparc/SparcISelDAGToDAG.cpp

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -106,8 +106,8 @@ bool SparcDAGToDAGISel::SelectADDRri(SDValue Addr,
106106
} else {
107107
Base = Addr.getOperand(0);
108108
}
109-
Offset = CurDAG->getTargetConstant(CN->getZExtValue(), SDLoc(Addr),
110-
MVT::i32);
109+
Offset = CurDAG->getSignedTargetConstant(CN->getSExtValue(),
110+
SDLoc(Addr), MVT::i32);
111111
return true;
112112
}
113113
}

llvm/lib/Target/Sparc/SparcISelLowering.cpp

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -2820,7 +2820,7 @@ static SDValue LowerDYNAMIC_STACKALLOC(SDValue Op, SelectionDAG &DAG,
28202820
SDValue AlignedPtr =
28212821
IsOveraligned
28222822
? DAG.getNode(ISD::AND, dl, VT, AllocatedPtr,
2823-
DAG.getConstant(-MaybeAlignment->value(), dl, VT))
2823+
DAG.getSignedConstant(-MaybeAlignment->value(), dl, VT))
28242824
: AllocatedPtr;
28252825

28262826
// Now that we are done, restore the bias and reserved spill area.
@@ -3367,8 +3367,8 @@ void SparcTargetLowering::LowerAsmOperandForConstraint(
33673367
case 'I':
33683368
if (ConstantSDNode *C = dyn_cast<ConstantSDNode>(Op)) {
33693369
if (isInt<13>(C->getSExtValue())) {
3370-
Result = DAG.getTargetConstant(C->getSExtValue(), SDLoc(Op),
3371-
Op.getValueType());
3370+
Result = DAG.getSignedTargetConstant(C->getSExtValue(), SDLoc(Op),
3371+
Op.getValueType());
33723372
break;
33733373
}
33743374
return;

llvm/lib/Target/Sparc/SparcInstr64Bit.td

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -67,7 +67,7 @@ def : Pat<(i64 0), (COPY (i64 G0))>,
6767
// The ALU instructions want their simm13 operands as i32 immediates.
6868
// FIXME: This is no longer true, they are now pointer-sized.
6969
def as_i32imm : SDNodeXForm<imm, [{
70-
return CurDAG->getTargetConstant(N->getSExtValue(), SDLoc(N), MVT::i32);
70+
return CurDAG->getSignedTargetConstant(N->getSExtValue(), SDLoc(N), MVT::i32);
7171
}]>;
7272
def : Pat<(i64 simm13:$val), (ORri (i64 G0), (as_i32imm $val))>;
7373
def : Pat<(i64 SETHIimm:$val), (SETHIi (HI22 $val))>;
@@ -91,8 +91,8 @@ def HIX22 : SDNodeXForm<imm, [{
9191
}]>;
9292
// Bits 0-9 with ones in bits 10-31. Same as assembler's %lox.
9393
def LOX10 : SDNodeXForm<imm, [{
94-
return CurDAG->getTargetConstant(~(~N->getZExtValue() & 0x3ff), SDLoc(N),
95-
MVT::i32);
94+
return CurDAG->getSignedTargetConstant(~(~N->getZExtValue() & 0x3ff),
95+
SDLoc(N), MVT::i32);
9696
}]>;
9797
def : Pat<(i64 nimm33:$val), (XORri (SETHIi (HIX22 $val)), (LOX10 $val))>,
9898
Requires<[Is64Bit]>;

0 commit comments

Comments
 (0)