This is an archive of the discontinued LLVM Phabricator instance.

[ARM] Peek through And 1 in IsCMPZCSINC
ClosedPublic

Authored by dmgreen on Dec 6 2021, 12:14 PM.

Details

Summary

We can be in situations where And 1 zext nodes will not have been yet, preventing us from detecting removable cmpz/csinc patterns. This peeks through those nodes allowing us to simplify more code.

Diff Detail

Event Timeline

dmgreen created this revision.Dec 6 2021, 12:14 PM
dmgreen requested review of this revision.Dec 6 2021, 12:14 PM
Herald added a project: Restricted Project. · View Herald TranscriptDec 6 2021, 12:14 PM
SjoerdMeijer added inline comments.Dec 7 2021, 2:17 AM
llvm/lib/Target/ARM/ARMISelLowering.cpp
14640

The problem with these end-to-end test that we have for this code is that we are not testing things in isolation here, and that the patterns are difficult to see.... perhaps I am missing context or something else, but can you clarify with a "zext and" nodes is? I am just failing to see what the AND 1 is doing here.

dmgreen added inline comments.Dec 7 2021, 6:47 AM
llvm/lib/Target/ARM/ARMISelLowering.cpp
14640

By "zext and" I just meant the And that are produces by legalizing an i1 zext. So from a zext i1 %x to i32, we legalize the %x to an i32 and add an and %x, 1 to make sure the value is correct. The operator we test for in this function can only produce 0 or 1, so it doesn't matter much if we And that with 1, we will remain at the same value.

Those extra And 1's will be removed later, because we know they don't do anything. By that point we may not re-visit this node to do this transform, though. Hence the improvement in some of the tests.

SjoerdMeijer accepted this revision.Dec 7 2021, 6:55 AM
SjoerdMeijer added inline comments.
llvm/lib/Target/ARM/ARMISelLowering.cpp
14640

Ahhhh okay, thanks, got it! LGTM.

Perhaps useful to that add that as a comment here (the and %x, 1 is for the legalized zext i1 %x to i32 ).

This revision is now accepted and ready to land.Dec 7 2021, 6:55 AM
This revision was automatically updated to reflect the committed changes.