-
Notifications
You must be signed in to change notification settings - Fork 14.3k
[VPlan] Add non-poison propagating LogicalAnd VPInstruction opcode. #91897
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
2143c19
2b54e95
b70a6a8
84ef292
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 | ||||||||||||
---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|
|
@@ -8011,14 +8011,13 @@ VPValue *VPRecipeBuilder::createEdgeMask(BasicBlock *Src, BasicBlock *Dst) { | |||||||||||||
EdgeMask = Builder.createNot(EdgeMask, BI->getDebugLoc()); | ||||||||||||||
|
||||||||||||||
if (SrcMask) { // Otherwise block in-mask is all-one, no need to AND. | ||||||||||||||
// The condition is 'SrcMask && EdgeMask', which is equivalent to | ||||||||||||||
// 'select i1 SrcMask, i1 EdgeMask, i1 false'. | ||||||||||||||
// The select version does not introduce new UB if SrcMask is false and | ||||||||||||||
// EdgeMask is poison. Using 'and' here introduces undefined behavior. | ||||||||||||||
VPValue *False = Plan.getOrAddLiveIn( | ||||||||||||||
ConstantInt::getFalse(BI->getCondition()->getType())); | ||||||||||||||
EdgeMask = | ||||||||||||||
Builder.createSelect(SrcMask, EdgeMask, False, BI->getDebugLoc()); | ||||||||||||||
// Use LogicalAnd as it does not propagate poison, i.e. does not introduce | ||||||||||||||
// new UB if SrcMask is false and EdgeMask is poison. Using 'and' here | ||||||||||||||
// introduces undefined behavior. | ||||||||||||||
Comment on lines
+8014
to
+8016
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.
Suggested change
(BTW, the converse - false EdgeMask and poison SrcMask - is irrelevant, because EdgeMask is conditional on SrcMask, right?) 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. Yes IIUC 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. (nit, post-commit): above suggestion was a rephrasing of the initial comment, meant to replace it rather than augment it. 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. Ah yes, my bad! Should be fixed in b1e99a6 |
||||||||||||||
// The bitwise 'And' of SrcMask and EdgeMask introduces new UB if SrcMask | ||||||||||||||
// is false and EdgeMask is poison. Avoid that by using 'LogicalAnd' | ||||||||||||||
// instead which generates 'select i1 SrcMask, i1 EdgeMask, i1 false'. | ||||||||||||||
EdgeMask = Builder.createLogicalAnd(SrcMask, EdgeMask, BI->getDebugLoc()); | ||||||||||||||
} | ||||||||||||||
|
||||||||||||||
return EdgeMaskCache[Edge] = EdgeMask; | ||||||||||||||
|
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.
Is this now useless, untested, subject to dce?
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.
There was one other place that created selects, updated here: e122380