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 | ||
---|---|---|
280 | The preferred doxygen style is to drop the function name in the comments. | |
301 | The preferred doxygen style is to drop the function name in the comments. | |
304 | Once this gets committed please file a PR unless you plan on doing the follow up work. | |
348–352 | location. -> location, | |
429–430 | The other interesting case -> Another interesting case | |
457 | We also need -> Finally, we also need | |
467 | 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. | |
469 | I believe you dropped a comment: // Otherwise, they don't completely overlap. | |
test/Transforms/DeadStoreElimination/OverwriteStoreBegin.ll | ||
4 | 4to8 -> 4to7? | |
17 | 0to4 -> 0to3? Should you decide to make this change, more instances below.. | |
53 | 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 | ||
---|---|---|
304 | Yes, I will do that. | |
467 | 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(). | |
469 | Oh.. Thanks .. | |
test/Transforms/DeadStoreElimination/OverwriteStoreBegin.ll | ||
17 | Thanks, I will fix them. | |
53 | Okay, I will comment it. |
lib/Transforms/Scalar/DeadStoreElimination.cpp | ||
---|---|---|
342 | It's better to list the enum members alphabetically. | |
642–647 | Enclosing the RHS in parentheses makes it more readable. | |
659 | 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 | ||
---|---|---|
659 | 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.