This is an archive of the discontinued LLVM Phabricator instance.

[GlobalISel] Change ConstantFoldVectorBinop to return vector of APInt
ClosedPublic

Authored by foad on Jan 20 2022, 2:02 AM.

Details

Summary

Previously it built MIR for the results and returned a Register.

This avoids building constants for earlier elements of the vector if
later elements will fail to fold, and allows CSEMIRBuilder::buildInstr
to avoid unconditionally building a copy from the result.

Use a new helper function MachineIRBuilder::buildBuildVectorConstant
to build a G_BUILD_VECTOR of G_CONSTANTs.

Diff Detail

Event Timeline

foad created this revision.Jan 20 2022, 2:02 AM
foad requested review of this revision.Jan 20 2022, 2:02 AM
Herald added a project: Restricted Project. · View Herald TranscriptJan 20 2022, 2:02 AM
Herald added a project: Restricted Project. · View Herald TranscriptMay 12 2022, 1:31 AM
Herald added a subscriber: kosarev. · View Herald Transcript
paquette accepted this revision.May 12 2022, 10:07 AM

I think this seems reasonable? Looks like a compile time improvement too, maybe?

This revision is now accepted and ready to land.May 12 2022, 10:07 AM
foad added a comment.May 12 2022, 11:21 AM

Looks like a compile time improvement too, maybe?

I haven't tried to measure it, but yes part of the rationale is that it can avoid doing unnecessary work in some cases.