Skip to content

Commit ee2aba7

Browse files
authored
AMDGPU: Use poison in some lowering contexts (#137325)
This replaces most of the places that use undef. I left alone the cases that require additional thought.
1 parent 41f1663 commit ee2aba7

File tree

1 file changed

+25
-26
lines changed

1 file changed

+25
-26
lines changed

llvm/lib/Target/AMDGPU/SIISelLowering.cpp

+25-26
Original file line numberDiff line numberDiff line change
@@ -2226,7 +2226,7 @@ SDValue SITargetLowering::getPreloadedValue(
22262226

22272227
// It's undefined behavior if a function marked with the amdgpu-no-*
22282228
// attributes uses the corresponding intrinsic.
2229-
return DAG.getUNDEF(VT);
2229+
return DAG.getPOISON(VT);
22302230
}
22312231

22322232
return loadInputValue(DAG, RC, VT, SDLoc(DAG.getEntryNode()), *Reg);
@@ -2962,7 +2962,7 @@ SDValue SITargetLowering::LowerFormalArguments(
29622962
for (unsigned i = 0, e = Ins.size(), ArgIdx = 0; i != e; ++i) {
29632963
const ISD::InputArg &Arg = Ins[i];
29642964
if ((Arg.isOrigArg() && Skipped[Arg.getOrigArgIndex()]) || IsError) {
2965-
InVals.push_back(DAG.getUNDEF(Arg.VT));
2965+
InVals.push_back(DAG.getPOISON(Arg.VT));
29662966
continue;
29672967
}
29682968

@@ -3446,12 +3446,12 @@ void SITargetLowering::passSpecialInputs(
34463446
if (Id.has_value()) {
34473447
InputReg = DAG.getConstant(*Id, DL, ArgVT);
34483448
} else {
3449-
InputReg = DAG.getUNDEF(ArgVT);
3449+
InputReg = DAG.getPOISON(ArgVT);
34503450
}
34513451
} else {
34523452
// We may have proven the input wasn't needed, although the ABI is
34533453
// requiring it. We just need to allocate the register appropriately.
3454-
InputReg = DAG.getUNDEF(ArgVT);
3454+
InputReg = DAG.getPOISON(ArgVT);
34553455
}
34563456

34573457
if (OutgoingArg->isRegister()) {
@@ -3531,7 +3531,7 @@ void SITargetLowering::passSpecialInputs(
35313531
// ID, but the calling function does not have it (e.g a graphics function
35323532
// calling a C calling convention function). This is illegal, but we need
35333533
// to produce something.
3534-
InputReg = DAG.getUNDEF(MVT::i32);
3534+
InputReg = DAG.getPOISON(MVT::i32);
35353535
} else {
35363536
// Workitem ids are already packed, any of present incoming arguments
35373537
// will carry all required fields.
@@ -3777,7 +3777,7 @@ SDValue SITargetLowering::LowerCall(CallLoweringInfo &CLI,
37773777
if (Callee.isUndef() || isNullConstant(Callee)) {
37783778
if (!CLI.IsTailCall) {
37793779
for (ISD::InputArg &Arg : CLI.Ins)
3780-
InVals.push_back(DAG.getUNDEF(Arg.VT));
3780+
InVals.push_back(DAG.getPOISON(Arg.VT));
37813781
}
37823782

37833783
return Chain;
@@ -6139,7 +6139,7 @@ static SDValue adjustLoadValueTypeImpl(SDValue Result, EVT LoadVT,
61396139

61406140
// Pad illegal v1i16/v3fi6 to v4i16
61416141
if ((LoadVT.getVectorNumElements() % 2) == 1)
6142-
Elts.push_back(DAG.getUNDEF(MVT::i16));
6142+
Elts.push_back(DAG.getPOISON(MVT::i16));
61436143

61446144
Result = DAG.getBuildVector(IntLoadVT, DL, Elts);
61456145

@@ -6231,7 +6231,7 @@ static SDValue lowerICMPIntrinsic(const SITargetLowering &TLI, SDNode *N,
62316231
EVT VT = N->getValueType(0);
62326232
unsigned CondCode = N->getConstantOperandVal(3);
62336233
if (!ICmpInst::isIntPredicate(static_cast<ICmpInst::Predicate>(CondCode)))
6234-
return DAG.getUNDEF(VT);
6234+
return DAG.getPOISON(VT);
62356235

62366236
ICmpInst::Predicate IcInput = static_cast<ICmpInst::Predicate>(CondCode);
62376237

@@ -6266,7 +6266,7 @@ static SDValue lowerFCMPIntrinsic(const SITargetLowering &TLI, SDNode *N,
62666266

62676267
unsigned CondCode = N->getConstantOperandVal(3);
62686268
if (!FCmpInst::isFPPredicate(static_cast<FCmpInst::Predicate>(CondCode)))
6269-
return DAG.getUNDEF(VT);
6269+
return DAG.getPOISON(VT);
62706270

62716271
SDValue Src0 = N->getOperand(1);
62726272
SDValue Src1 = N->getOperand(2);
@@ -7343,7 +7343,7 @@ SDValue SITargetLowering::getSegmentAperture(unsigned AS, const SDLoc &DL,
73437343
if (UserSGPR == AMDGPU::NoRegister) {
73447344
// We probably are in a function incorrectly marked with
73457345
// amdgpu-no-queue-ptr. This is undefined.
7346-
return DAG.getUNDEF(MVT::i32);
7346+
return DAG.getPOISON(MVT::i32);
73477347
}
73487348

73497349
SDValue QueuePtr =
@@ -7465,8 +7465,7 @@ SDValue SITargetLowering::lowerADDRSPACECAST(SDValue Op,
74657465
// global <-> flat are no-ops and never emitted.
74667466

74677467
// Invalid casts are poison.
7468-
// TODO: Should return poison
7469-
return DAG.getUNDEF(Op->getValueType(0));
7468+
return DAG.getPOISON(Op->getValueType(0));
74707469
}
74717470

74727471
// This lowers an INSERT_SUBVECTOR by extracting the individual elements from
@@ -7808,7 +7807,7 @@ SDValue SITargetLowering::lowerVECTOR_SHUFFLE(SDValue Op,
78087807
NewMaskIdx1 += NewSrcNumElts;
78097808
Result1 = SubVec1;
78107809
} else {
7811-
Result1 = DAG.getUNDEF(PackVT);
7810+
Result1 = DAG.getPOISON(PackVT);
78127811
}
78137812

78147813
SDValue Shuf = DAG.getVectorShuffle(PackVT, SL, Result0, Result1,
@@ -7841,7 +7840,7 @@ SDValue SITargetLowering::lowerSCALAR_TO_VECTOR(SDValue Op,
78417840
SDValue SVal = Op.getOperand(0);
78427841
EVT ResultVT = Op.getValueType();
78437842
EVT SValVT = SVal.getValueType();
7844-
SDValue UndefVal = DAG.getUNDEF(SValVT);
7843+
SDValue UndefVal = DAG.getPOISON(SValVT);
78457844
SDLoc SL(Op);
78467845

78477846
SmallVector<SDValue, 8> VElts;
@@ -8065,7 +8064,7 @@ static SDValue emitNonHSAIntrinsicError(SelectionDAG &DAG, const SDLoc &DL,
80658064
"non-hsa intrinsic with hsa target",
80668065
DL.getDebugLoc());
80678066
DAG.getContext()->diagnose(BadIntrin);
8068-
return DAG.getUNDEF(VT);
8067+
return DAG.getPOISON(VT);
80698068
}
80708069

80718070
static SDValue emitRemovedIntrinsicError(SelectionDAG &DAG, const SDLoc &DL,
@@ -8074,7 +8073,7 @@ static SDValue emitRemovedIntrinsicError(SelectionDAG &DAG, const SDLoc &DL,
80748073
"intrinsic not supported on subtarget",
80758074
DL.getDebugLoc());
80768075
DAG.getContext()->diagnose(BadIntrin);
8077-
return DAG.getUNDEF(VT);
8076+
return DAG.getPOISON(VT);
80788077
}
80798078

80808079
static SDValue getBuildDwordsVector(SelectionDAG &DAG, SDLoc DL,
@@ -8099,7 +8098,7 @@ static SDValue getBuildDwordsVector(SelectionDAG &DAG, SDLoc DL,
80998098
VecElts[i] = Elt;
81008099
}
81018100
for (unsigned i = Elts.size(); i < NumElts; ++i)
8102-
VecElts[i] = DAG.getUNDEF(MVT::f32);
8101+
VecElts[i] = DAG.getPOISON(MVT::f32);
81038102

81048103
if (NumElts == 1)
81058104
return VecElts[0];
@@ -8117,7 +8116,7 @@ static SDValue padEltsToUndef(SelectionDAG &DAG, const SDLoc &DL, EVT CastVT,
81178116
else
81188117
Elts.push_back(Src);
81198118

8120-
SDValue Undef = DAG.getUNDEF(SrcVT.getScalarType());
8119+
SDValue Undef = DAG.getPOISON(SrcVT.getScalarType());
81218120
while (ExtraElts--)
81228121
Elts.push_back(Undef);
81238122

@@ -8368,7 +8367,7 @@ SDValue SITargetLowering::lowerImage(SDValue Op,
83688367
// occupies full 32-bit.
83698368
SDValue Bias = DAG.getBuildVector(
83708369
MVT::v2f16, DL,
8371-
{Op.getOperand(ArgOffset + I), DAG.getUNDEF(MVT::f16)});
8370+
{Op.getOperand(ArgOffset + I), DAG.getPOISON(MVT::f16)});
83728371
VAddrs.push_back(Bias);
83738372
} else {
83748373
assert((!IsA16 || Intr->NumBiasArgs == 0 || I != Intr->BiasIndex) &&
@@ -8498,7 +8497,7 @@ SDValue SITargetLowering::lowerImage(SDValue Op,
84988497
// type
84998498
if (DMaskLanes == 0 && !BaseOpcode->Store) {
85008499
// This is a no-op load. This can be eliminated
8501-
SDValue Undef = DAG.getUNDEF(Op.getValueType());
8500+
SDValue Undef = DAG.getPOISON(Op.getValueType());
85028501
if (isa<MemSDNode>(Op))
85038502
return DAG.getMergeValues({Undef, Op.getOperand(0)}, DL);
85048503
return Undef;
@@ -8743,7 +8742,7 @@ SDValue SITargetLowering::lowerWorkitemID(SelectionDAG &DAG, SDValue Op,
87438742
// It's undefined behavior if a function marked with the amdgpu-no-*
87448743
// attributes uses the corresponding intrinsic.
87458744
if (!Arg)
8746-
return DAG.getUNDEF(Op->getValueType(0));
8745+
return DAG.getPOISON(Op->getValueType(0));
87478746

87488747
SDValue Val = loadInputValue(DAG, &AMDGPU::VGPR_32RegClass, MVT::i32,
87498748
SDLoc(DAG.getEntryNode()), Arg);
@@ -8786,7 +8785,7 @@ SDValue SITargetLowering::LowerINTRINSIC_WO_CHAIN(SDValue Op,
87868785
MF.getFunction(), "unsupported hsa intrinsic without hsa target",
87878786
DL.getDebugLoc());
87888787
DAG.getContext()->diagnose(BadIntrin);
8789-
return DAG.getUNDEF(VT);
8788+
return DAG.getPOISON(VT);
87908789
}
87918790

87928791
auto RegID = IntrinsicID == Intrinsic::amdgcn_dispatch_ptr
@@ -9661,7 +9660,7 @@ SDValue SITargetLowering::LowerINTRINSIC_W_CHAIN(SDValue Op,
96619660
if (!UseNSA) {
96629661
// Build a single vector containing all the operands so far prepared.
96639662
if (NumVAddrDwords > 12) {
9664-
SDValue Undef = DAG.getUNDEF(MVT::i32);
9663+
SDValue Undef = DAG.getPOISON(MVT::i32);
96659664
Ops.append(16 - Ops.size(), Undef);
96669665
}
96679666
assert(Ops.size() >= 8 && Ops.size() <= 12);
@@ -9847,13 +9846,13 @@ SDValue SITargetLowering::handleD16VData(SDValue VData, SelectionDAG &DAG,
98479846
// Handle v3i16
98489847
unsigned I = Elts.size() / 2;
98499848
SDValue Pair = DAG.getBuildVector(MVT::v2i16, DL,
9850-
{Elts[I * 2], DAG.getUNDEF(MVT::i16)});
9849+
{Elts[I * 2], DAG.getPOISON(MVT::i16)});
98519850
SDValue IntPair = DAG.getNode(ISD::BITCAST, DL, MVT::i32, Pair);
98529851
PackedElts.push_back(IntPair);
98539852
}
98549853

98559854
// Pad using UNDEF
9856-
PackedElts.resize(Elts.size(), DAG.getUNDEF(MVT::i32));
9855+
PackedElts.resize(Elts.size(), DAG.getPOISON(MVT::i32));
98579856

98589857
// Build final vector
98599858
EVT VecVT =
@@ -9900,7 +9899,7 @@ SDValue SITargetLowering::LowerINTRINSIC_VOID(SDValue Op,
99009899
return SDValue();
99019900

99029901
const ConstantSDNode *Done = cast<ConstantSDNode>(Op.getOperand(6));
9903-
SDValue Undef = DAG.getUNDEF(MVT::f32);
9902+
SDValue Undef = DAG.getPOISON(MVT::f32);
99049903
const SDValue Ops[] = {
99059904
Op.getOperand(2), // tgt
99069905
DAG.getNode(ISD::BITCAST, DL, MVT::f32, Src0), // src0

0 commit comments

Comments
 (0)