This is an archive of the discontinued LLVM Phabricator instance.

[GlobalISel] Implement identity transforms for x op x -> x
ClosedPublic

Authored by paquette on Mar 30 2020, 4:48 PM.

Details

Summary

When we have

a = G_OR x, x

or

b = G_AND y, y

We can drop the G_OR/G_AND and just use x/y respectively.

Also update arm64-fallback.ll because there was an or in there which hits this transformation.

Diff Detail

Event Timeline

paquette created this revision.Mar 30 2020, 4:48 PM
arsenm accepted this revision.Mar 30 2020, 5:15 PM
This revision is now accepted and ready to land.Mar 30 2020, 5:15 PM
This revision was automatically updated to reflect the committed changes.
Herald added a project: Restricted Project. · View Herald TranscriptMar 30 2020, 6:36 PM

Where do these patterns come from?
I would expect they would be eliminated by InstCombine in the IR.

@qcolombet I'm not entirely sure, but patterns like this do hit a couple times in CTMark (but not very frequently, just once or twice.)

I'm surprised that they aren't entirely handled by InstCombine, but I'm guessing that they tend to appear in codegen at least once in a while considering they all exist in the DAGCombiner as well.

My best guess is that more complex combines simplify things enough that these patterns become obvious and thus can be eliminated.