This is an archive of the discontinued LLVM Phabricator instance.

[SCF] Clean up ForOpTensorCastFolder and harden it against nop tensor casts
ClosedPublic

Authored by bkramer on Apr 19 2023, 6:37 AM.

Details

Summary

The code was inserting a new cast, discarding it, then inserting it
again.

The self-cast issue is the root of #62135 because it would end up
dropping the loop and inserting an invalid cast to itself. As far as I
can tell tensor.cast with the same src and dst types is not invalid but
it can't really be tested in isolation as it's immediately folded.

Fixes #62135

Diff Detail

Event Timeline

bkramer created this revision.Apr 19 2023, 6:37 AM
Herald added a project: Restricted Project. · View Herald TranscriptApr 19 2023, 6:37 AM
bkramer requested review of this revision.Apr 19 2023, 6:37 AM
Herald added a project: Restricted Project. · View Herald TranscriptApr 19 2023, 6:37 AM
pifon2a accepted this revision.Apr 19 2023, 6:39 AM
This revision is now accepted and ready to land.Apr 19 2023, 6:39 AM
nicolasvasilache requested changes to this revision.Apr 19 2023, 6:44 AM

test please ?

This revision now requires changes to proceed.Apr 19 2023, 6:44 AM

test please ?

The bug requires interaction between multiple patterns. I don't see a way of testing it without committing an unmaintainable mess.

Also, how does this relate to the issue raised in: https://reviews.llvm.org/D144577 ?
Note that the code you are touching is busted already for other reasons.

Also, how does this relate to the issue raised in: https://reviews.llvm.org/D144577 ?
Note that the code you are touching is busted already for other reasons.

It doesn't interact with that at all. Will you accept a change to delete the pattern?

This is an unstable area since https://reviews.llvm.org/D144577 was landed: the pattern can now miscompile due to the wrong assumption it makes.

If this pattern can be removed and no tests regress, by all means please delete it.

Also @springerm who has experience around those corners.

This is an unstable area since https://reviews.llvm.org/D144577 was landed: the pattern can now miscompile due to the wrong assumption it makes.

If this pattern can be removed and no tests regress, by all means please delete it.

If course it will regress things. This pattern wasn't added for fun. But correctness is probably more important than performance.

Anyways, I'm going to land this cleanup now. Continue to discuss on D144577 as that's the real problem here.

This revision was not accepted when it landed; it landed in state Needs Revision.Apr 19 2023, 7:06 AM
This revision was landed with ongoing or failed builds.
This revision was automatically updated to reflect the committed changes.