BreakPHIEdge would be set based on whether the instruction needs to insert a new critical edge to allow sinking into a block where the uses are PHI nodes. But for instructions with multiple defs it would be reset on the second def, allowing the instruciton to sink where it should not.
Details
Diff Detail
Event Timeline
Hi Dave, thanks for fixing this. Probably good to mention in the description that this is fixing PR44981.
Some nits inlined.
llvm/lib/CodeGen/MachineSink.cpp | ||
---|---|---|
283 | Fair enough, I am not that familiar with this code, but reading the example above for the first time, I didn't find it that informative, i.e. the description is clear, the example isn't really. But since you're making changes to how this works, it's probably best to add that here as a comment: that we only change the global value when we found a local one, and say something about that example IR. |
Thanks. I've tried to adjust the comment and changed the condition to use all_of.
With multiple defs we might end up with one def being used by phi nodes, and another not (but used/dominated by the same block). BreakPHIEdge seems to be checking for if _all_ uses are phi nodes in the same block, but I don't see a problem with only some being phis.
Ah, yeah, cheers. And I like this a lot more now.
This LGTM, but please wait a day in case someone else has other opinions.
Ooops, I didn't see this patch and post another https://reviews.llvm.org/D78297. It can fix https://bugs.llvm.org/show_bug.cgi?id=45557. Thanks for the patch.
Ah, it looks like this came up in a couple of places now.
Let me go and commit this one to get it out of the way. We can see if it fixes both bugs..
llvm/test/CodeGen/ARM/machine-sink-multidef.ll | ||
---|---|---|
2 | Ah, I was committing before I got the message. I'll see what I can cook up. |
Fair enough, I am not that familiar with this code, but reading the example above for the first time, I didn't find it that informative, i.e. the description is clear, the example isn't really. But since you're making changes to how this works, it's probably best to add that here as a comment: that we only change the global value when we found a local one, and say something about that example IR.