-
Notifications
You must be signed in to change notification settings - Fork 299
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
[InferReadWrite] Add heuristic to infer unmasked memory #6790
Conversation
// If we can infer that all the bits of the mask are always assigned | ||
// the same value, then the memory is unmasked. | ||
if (auto maskVal = getConnectSrc(sf)) { | ||
SmallVector<Value> bits; |
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'm not sure it's reasonable to use Value to represent bit precise states. I think llvm::KnownBits would be right better fit here. You may want to refer the similar analysis for comb
circt/lib/Dialect/Comb/CombAnalysis.cpp
Line 86 in e1a69e3
/// constant" always returns zeros for the zero bits in a constant. |
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.
Thanks @uenoku , the analysis is very similar, but seems like its only trying to figure out the 1s and 0s in the bits.
But in this PR, the analysis is different.
- In general the mask value is going to be constructed by concat of few 1 bit values, which may not be constants.
- If the same Value is used to mask each field of an aggregate memory data, then each bit of the mask can be traced back to that Value.
- So, this unmasked inference analysis is only trying to follow the dataflow into each of the bits of an Value to a source Value and then check if the source value is same for each bit.
I agree about the recursion depth, I will make this an iterative algorithm.
67a3e12
to
3c28356
Compare
@seldridge , @debs-sifive This PR updates the heuristic to infer an unmasked memory, ready for a review. |
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'm not familiar here either but I think this change seems reasonable.
4169217
to
f6cc014
Compare
This PR updates the heuristic to infer an unmasked memory.
If all the bits of a masked memory are exactly the same, then it can be replaced with an unmasked memory.
This is an attempt to fix a use case, in which
firtool
introduces masked memory for an aggregate data type when the user expected an unmasked one.