This change will shorten memset if the beginning of memset is overwritten by later stores.
Details
Diff Detail
Event Timeline
The patch looks to be in good shape generally. I've inlined a few nits and questions/suggestions.
lib/Transforms/Scalar/DeadStoreElimination.cpp | ||
---|---|---|
278 | The preferred doxygen style is to drop the function name in the comments. | |
300 | The preferred doxygen style is to drop the function name in the comments. | |
303 | Once this gets committed please file a PR unless you plan on doing the follow up work. | |
348 | location. -> location, | |
429 | The other interesting case -> Another interesting case | |
442 | We also need -> Finally, we also need | |
452 | I suspect this condition 'int64_t(LaterOff + Later.Size) < int64_t(EarlierOff + Earlier.Size)' will always be true because the OverwriteComplete case will return true when LaterEnd is >= EarlyEnd. If I am correct and the condition is true, perhaps add an assert that it's always true. | |
454 | I believe you dropped a comment: // Otherwise, they don't completely overlap. | |
test/Transforms/DeadStoreElimination/OverwriteStoreBegin.ll | ||
3 | 4to8 -> 4to7? | |
16 | 0to4 -> 0to3? Should you decide to make this change, more instances below.. | |
52 | Perhaps add a comments stating why this transformation is unsafe (i.e., we must not change the alignment of the earlier write, if I'm not mistaken). |
Thanks Chad for the review. I will address your comments soon.
lib/Transforms/Scalar/DeadStoreElimination.cpp | ||
---|---|---|
303 | Yes, I will do that. | |
452 | Agree. If the first two condition is true and the the third condition is false, that means OverwriteComplete. As you pointed, the third condition could be an assert(). | |
454 | Oh.. Thanks .. | |
test/Transforms/DeadStoreElimination/OverwriteStoreBegin.ll | ||
16 | Thanks, I will fix them. | |
52 | Okay, I will comment it. |
lib/Transforms/Scalar/DeadStoreElimination.cpp | ||
---|---|---|
341 | It's better to list the enum members alphabetically. | |
639 | Enclosing the RHS in parentheses makes it more readable. | |
656 | Parentheses not really needed: DepLoc.Size - (InstWriteOffset - DepWriteOffset) equals DepLoc.Size - InstWriteOffset - DepWriteOffset |
Addressed Mandeep's comments. Thanks for the review.
lib/Transforms/Scalar/DeadStoreElimination.cpp | ||
---|---|---|
656 | DepLoc.Size - (InstWriteOffset - DepWriteOffset) is same as DepLoc.Size - InstWriteOffset + DepWriteOffset, but I think DepLoc.Size - (InstWriteOffset - DepWriteOffset) is more readable. |
The preferred doxygen style is to drop the function name in the comments.