This is an archive of the discontinued LLVM Phabricator instance.

[GlobalISel] Combine sext([sz]ext) -> [sz]ext, zext(zext) -> zext
ClosedPublic

Authored by gargaroff on Apr 1 2020, 4:13 AM.

Details

Summary

Combine sext(zext x) to (zext x) since the sign-bit is 0
after the zero-extension.

Combine sext(sext x) to (sext x) and ext(zext x) to (zext x)
since the intermediate step is not needed.

Diff Detail

Event Timeline

gargaroff created this revision.Apr 1 2020, 4:13 AM
Herald added a project: Restricted Project. · View Herald TranscriptApr 1 2020, 4:13 AM
gargaroff updated this revision to Diff 254163.Apr 1 2020, 4:16 AM

Remove unrelated changes

Harbormaster completed remote builds in B51275: Diff 254161.
arsenm added inline comments.Apr 1 2020, 8:55 AM
llvm/include/llvm/CodeGen/GlobalISel/LegalizationArtifactCombiner.h
129

Can you just replace the source?

184

Why the m_all_of?

gargaroff updated this revision to Diff 254466.Apr 2 2020, 2:43 AM
gargaroff marked an inline comment as done.

Add DstReg to UpdatedDefs

Replace source

gargaroff marked an inline comment as done.Apr 2 2020, 2:43 AM
gargaroff added inline comments.
llvm/include/llvm/CodeGen/GlobalISel/LegalizationArtifactCombiner.h
184

This is needed to get the matched extension instruction. I didn't find any other way to easily get the instruction. Using it in place of m_Reg gives me the def of ExtSrc and I'm not aware of any matcher which give you the *matched* instruction. That's why I use m_all_of. This pattern is also used in tryCombineAnyExt.

arsenm accepted this revision.Apr 7 2020, 11:46 AM

Pattern seems convoluted to me, but OK I guess if it's already used

This revision is now accepted and ready to land.Apr 7 2020, 11:46 AM
This revision was automatically updated to reflect the committed changes.