-
Notifications
You must be signed in to change notification settings - Fork 13.6k
[ConstraintElim] Decompose shl nsw for signed predicates #76961
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 1 commit
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 |
---|---|---|
|
@@ -517,6 +517,17 @@ static Decomposition decompose(Value *V, | |
return Result; | ||
} | ||
|
||
// shl nsw x, shift is mul nsw x, (1<<shift), | ||
// with the exception of shift == bw-1. | ||
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: reflow comment? |
||
if (match(V, m_NSWShl(m_Value(Op0), m_ConstantInt(CI)))) { | ||
uint64_t Shift = CI->getValue().getLimitedValue(); | ||
if (Shift < Ty->getIntegerBitWidth() - 1 && Shift < 64) { | ||
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. Looks like there's no test case for 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. Yeah, this check is actually redundant. I'll replace it with an assert. 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. Sounds good! |
||
auto Result = decompose(Op0, Preconditions, IsSigned, DL); | ||
Result.mul(int64_t(1) << Shift); | ||
return Result; | ||
} | ||
} | ||
|
||
return V; | ||
} | ||
|
||
|
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.
nit: might be good to wrap the expressions in
()
or something else to separate them from the interleave text