This is an archive of the discontinued LLVM Phabricator instance.

[InstCombine] limit icmp fold with sub if other sub user is a phi
ClosedPublic

Authored by spatel on Apr 1 2022, 8:13 AM.

Details

Summary

This is a hacky fix for issue #54558. As discussed there, codegen regressed when we opened up this transform to allow extra uses ( 61580d0949fd3465 ), and it's not clear how to undo the transforms at the later stage of compilation.

As noted in the code comments, there's a set of remaining folds that are still limited to one-use, so we can try harder to refine and expand the limitations on these folds, but it's likely to be an up-and-down battle as we find and overcome similar regressions.

Diff Detail

Event Timeline

spatel created this revision.Apr 1 2022, 8:13 AM
Herald added a project: Restricted Project. · View Herald TranscriptApr 1 2022, 8:13 AM
spatel requested review of this revision.Apr 1 2022, 8:13 AM
Herald added a project: Restricted Project. · View Herald TranscriptApr 1 2022, 8:13 AM
kazu accepted this revision.Apr 1 2022, 10:37 AM

Sanjay, thank you so much for the fix!

This revision is now accepted and ready to land.Apr 1 2022, 10:37 AM

It seems like something for a late undo pass to deal with.

spatel added a comment.Apr 2 2022, 3:13 PM

It seems like something for a late undo pass to deal with.

Agree, but the comments in https://github.com/llvm/llvm-project/issues/54558 suggested there wasn't a quick fix, and there are already one-use limitations here, so that's why I proposed a fast fix for the regression. Do you object to this change?

lebedev.ri edited the summary of this revision. (Show Details)Apr 2 2022, 3:23 PM

It seems like something for a late undo pass to deal with.

Agree, but the comments in https://github.com/llvm/llvm-project/issues/54558 suggested there wasn't a quick fix, and there are already one-use limitations here, so that's why I proposed a fast fix for the regression. Do you object to this change?

No strong thoughts on this one. I just think it would be best to have a more general undo fold :)

spatel added a comment.Apr 2 2022, 3:35 PM

It seems like something for a late undo pass to deal with.

Agree, but the comments in https://github.com/llvm/llvm-project/issues/54558 suggested there wasn't a quick fix, and there are already one-use limitations here, so that's why I proposed a fast fix for the regression. Do you object to this change?

No strong thoughts on this one. I just think it would be best to have a more general undo fold :)

Yes, I didn't look closely at the original example, but there was a comment about a cross-block limitation, so it might be a job for CGP.

This revision was landed with ongoing or failed builds.Apr 2 2022, 4:33 PM
This revision was automatically updated to reflect the committed changes.