This is an archive of the discontinued LLVM Phabricator instance.

[mlir][LLVMIR] Allow insert/extract element ops to have a constant index
AbandonedPublic

Authored by Mogball on Aug 16 2022, 10:41 AM.

Details

Summary

This patch allows LLVM's insertelement and extractelement ops to
optionally have a constant index instead of a dynamic index, allowing
syntax like

%0 = llvm.extractelement %v[1] : vector<2xi32>
%1 = llvm.insertelement %0, %v[2] : vector<2xi32>

Depends on D131971

Diff Detail

Event Timeline

Mogball created this revision.Aug 16 2022, 10:41 AM
Mogball requested review of this revision.Aug 16 2022, 10:41 AM

This feels like it's missing justification, can you add why? What's the benefit/necessity of the complexity here?

LLVMIR allows these ops to have inline constant indices. I thought the need to materialize an extra constant in these cases was a little verbose.

rriddle requested changes to this revision.Aug 18 2022, 9:36 AM

LLVMIR allows these ops to have inline constant indices. I thought the need to materialize an extra constant in these cases was a little verbose.

I'm not sure that design principle scales though, given that LLVM technically allows inline constants on everything.

This revision now requires changes to proceed.Aug 18 2022, 9:36 AM
Mogball abandoned this revision.Aug 18 2022, 9:40 AM

Yeah now that I think about it, you're right. LLVMIR constants are different than MLIR constants.