Skip to content
Draft
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
25 changes: 25 additions & 0 deletions llvm/lib/CodeGen/SelectionDAG/SelectionDAG.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -5636,6 +5636,31 @@ bool SelectionDAG::isGuaranteedNotToBeUndefOrPoison(SDValue Op,
});
}

case ISD::BITCAST: {
SDValue Src = Op.getOperand(0);
EVT SrcVT = Src.getValueType();
EVT TgtVT = Op.getValueType();

// Case 1: Scalar -> Vector, or Scalar -> Scalar
if (!SrcVT.isVector()) {
APInt DemandedSrcElts(1, 1);
return isGuaranteedNotToBeUndefOrPoison(Src, DemandedSrcElts, PoisonOnly,
Depth + 1);
}

// Case 2: Vector -> Scalar, or Scalable Vector -> Scalable Vector
if ((SrcVT.isVector() && !TgtVT.isVector()) ||
(SrcVT.isScalableVT() && TgtVT.isScalableVT()))
return isGuaranteedNotToBeUndefOrPoison(Src, PoisonOnly, Depth + 1);

// Case 3: Vector -> Vector
unsigned NumSrcElts = SrcVT.getVectorNumElements();
APInt ScaledDemandedElts = APIntOps::ScaleBitMask(DemandedElts, NumSrcElts);

return isGuaranteedNotToBeUndefOrPoison(Src, ScaledDemandedElts, PoisonOnly,
Depth + 1);
}

// TODO: Search for noundef attributes from library functions.

// TODO: Pointers dereferenced by ISD::LOAD/STORE ops are noundef.
Expand Down