This is an archive of the discontinued LLVM Phabricator instance.

[DAGCombiner] When folding fold (sext/zext (and/or/xor (sextload/zextload x), cst)) -> (and/or/xor (sextload/zextload x), (sext/zext cst)) make sure we check the legality of the full extended load.
ClosedPublic

Authored by craig.topper on Jan 31 2018, 11:04 PM.

Details

Summary

If the load is already an extended load we should be using the memory VT for the legality check, not just the VT of the current extension.

I don't have a test case, just noticed it while investigating some load extension improvements.

Diff Detail

Repository
rL LLVM

Event Timeline

craig.topper created this revision.Jan 31 2018, 11:04 PM
niravd accepted this revision.Feb 3 2018, 11:44 AM

LGTM.

Related question: Should the check be TLI.isLoadExtLegalOrCustom?

This revision is now accepted and ready to land.Feb 3 2018, 11:44 AM

Maybe? I'm still trying to get my head around this code. There are some other issues we need to investigate here first. We don't call ExtendUsesToFormExtLoad when the load itself has multiple uses. Just when the AND/OR/XOR has multiple uses, but we're passing the SDValue of the load. So we'll only collect setccs when the and/or/xor has additional users and the load is used by more than just the and/or/xor.

The other consequence of that is that any additional users of the load aren't checked for the isTruncateFree in ExtendUsesToFormExtLoad. So the test case I regressed in D42679 only works today by accident because we didn't check the additional load user which was a truncate.

This revision was automatically updated to reflect the committed changes.