Skip to content

Commit 5322415

Browse files
committed
[PowerPC] Use getSignedConstant() in SelectOptimalAddrMode()
All of these immediates are signed, as the surrounding comments indicate. This fixes an assertion failure in CodeGen/Generic/dag-combine-ossfuzz-crash.ll when run with a powerpc-aix triple.
1 parent 6f5e5b6 commit 5322415

File tree

1 file changed

+4
-4
lines changed

1 file changed

+4
-4
lines changed

llvm/lib/Target/PowerPC/PPCISelLowering.cpp

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -18928,7 +18928,7 @@ PPC::AddrMode PPCTargetLowering::SelectOptimalAddrMode(const SDNode *Parent,
1892818928
SDValue Op1 = N.getOperand(1);
1892918929
int16_t Imm = Op1->getAsZExtVal();
1893018930
if (!Align || isAligned(*Align, Imm)) {
18931-
Disp = DAG.getTargetConstant(Imm, DL, N.getValueType());
18931+
Disp = DAG.getSignedTargetConstant(Imm, DL, N.getValueType());
1893218932
Base = Op0;
1893318933
if (FrameIndexSDNode *FI = dyn_cast<FrameIndexSDNode>(Op0)) {
1893418934
Base = DAG.getTargetFrameIndex(FI->getIndex(), N.getValueType());
@@ -18959,7 +18959,7 @@ PPC::AddrMode PPCTargetLowering::SelectOptimalAddrMode(const SDNode *Parent,
1895918959
// this as "d, 0".
1896018960
int16_t Imm;
1896118961
if (isIntS16Immediate(CN, Imm) && (!Align || isAligned(*Align, Imm))) {
18962-
Disp = DAG.getTargetConstant(Imm, DL, CNType);
18962+
Disp = DAG.getSignedTargetConstant(Imm, DL, CNType);
1896318963
Base = DAG.getRegister(Subtarget.isPPC64() ? PPC::ZERO8 : PPC::ZERO,
1896418964
CNType);
1896518965
break;
@@ -18992,14 +18992,14 @@ PPC::AddrMode PPCTargetLowering::SelectOptimalAddrMode(const SDNode *Parent,
1899218992
if (((Opcode == ISD::ADD) || (Opcode == ISD::OR)) &&
1899318993
(isIntS34Immediate(N.getOperand(1), Imm34))) {
1899418994
// N is an Add/OR Node, and it's operand is a 34-bit signed immediate.
18995-
Disp = DAG.getTargetConstant(Imm34, DL, N.getValueType());
18995+
Disp = DAG.getSignedTargetConstant(Imm34, DL, N.getValueType());
1899618996
if (FrameIndexSDNode *FI = dyn_cast<FrameIndexSDNode>(N.getOperand(0)))
1899718997
Base = DAG.getTargetFrameIndex(FI->getIndex(), N.getValueType());
1899818998
else
1899918999
Base = N.getOperand(0);
1900019000
} else if (isIntS34Immediate(N, Imm34)) {
1900119001
// The address is a 34-bit signed immediate.
19002-
Disp = DAG.getTargetConstant(Imm34, DL, N.getValueType());
19002+
Disp = DAG.getSignedTargetConstant(Imm34, DL, N.getValueType());
1900319003
Base = DAG.getRegister(PPC::ZERO8, N.getValueType());
1900419004
}
1900519005
break;

0 commit comments

Comments
 (0)