-
Notifications
You must be signed in to change notification settings - Fork 14.3k
[SDAG] Harden assumption in getMemsetStringVal #126207
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Changes from all commits
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -8015,17 +8015,8 @@ static SDValue getMemsetStringVal(EVT VT, const SDLoc &dl, SelectionDAG &DAG, | |
if (Slice.Array == nullptr) { | ||
if (VT.isInteger()) | ||
return DAG.getConstant(0, dl, VT); | ||
if (VT == MVT::f32 || VT == MVT::f64 || VT == MVT::f128) | ||
return DAG.getConstantFP(0.0, dl, VT); | ||
if (VT.isVector()) { | ||
unsigned NumElts = VT.getVectorNumElements(); | ||
MVT EltVT = (VT.getVectorElementType() == MVT::f32) ? MVT::i32 : MVT::i64; | ||
return DAG.getNode(ISD::BITCAST, dl, VT, | ||
DAG.getConstant(0, dl, | ||
EVT::getVectorVT(*DAG.getContext(), | ||
EltVT, NumElts))); | ||
} | ||
llvm_unreachable("Expected type!"); | ||
return DAG.getNode(ISD::BITCAST, dl, VT, | ||
DAG.getConstant(0, dl, VT.changeTypeToInteger())); | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Technically this can be used for the isInteger() path above as well, but I'm not sure if that just gets confusing? There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. that crossed my mind also and is perhaps what @arsenm was referring to as well, I don't mind either way. |
||
} | ||
|
||
assert(!VT.isVector() && "Can't handle vector type here!"); | ||
|
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
This can just bitcast to VT.changeVectorElementTypeToInteger?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
that would also work I guess, although it's not obvious to me that's any better than calling getConstantFP?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I mean instead of having this unreachable case
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
not sure if my understanding is correct, but I've updated to what I believe you're suggesting, except I've used
changeTypeToInteger
since it handles both scalar/vector.