This is an archive of the discontinued LLVM Phabricator instance.

GlobalISel: Fix CSEMIRBuilder mishandling constant folds of vectors
ClosedPublic

Authored by arsenm on Jan 11 2022, 7:46 AM.

Details

Summary

This was ignoring the requested result register, resulting in a
missing def when this happened in the IRTranslator. Fixes some crashes
and verifier errors at -O0.

Alternatively we could pass DstOps to the constant fold functions.

Diff Detail

Event Timeline

arsenm created this revision.Jan 11 2022, 7:46 AM
arsenm requested review of this revision.Jan 11 2022, 7:46 AM
Herald added a project: Restricted Project. · View Herald TranscriptJan 11 2022, 7:46 AM
Herald added a subscriber: wdng. · View Herald Transcript
foad added a comment.Jan 11 2022, 9:15 AM

Alternatively we could pass DstOps to the constant fold functions.

If that would avoid building a copy when DstOp is not a register then it sounds better to me.

+1 for avoiding the copy if possible, otherwise looks fine to me?

aemerson accepted this revision.Jan 12 2022, 2:43 PM

I have no strong preference of whether we emit a copy or not FWIW.

This revision is now accepted and ready to land.Jan 12 2022, 2:43 PM

+1 for avoiding the copy if possible, otherwise looks fine to me?

DstOps is part of the MachineIRBuilder API, so I'm not sure it should be spread to Utils. However since this is using it anyway, why is ConstantFoldVectorBinop in Utils? We could either move the whole function into the MIRBuilder, or have the utils function return a vector of APInt

foad added a comment.Jan 20 2022, 2:03 AM

or have the utils function return a vector of APInt

I have tried that in D117758.