Skip to content

spirv-opt: add missing OpConstantCompositeReplicateEXT support to constant manager#6616

Open
kpet wants to merge 1 commit intoKhronosGroup:mainfrom
kpet:constant-manager-replicated
Open

spirv-opt: add missing OpConstantCompositeReplicateEXT support to constant manager#6616
kpet wants to merge 1 commit intoKhronosGroup:mainfrom
kpet:constant-manager-replicated

Conversation

@kpet
Copy link
Copy Markdown
Contributor

@kpet kpet commented Mar 27, 2026

No description provided.

…stant manager

Signed-off-by: Mohammadreza Ameri Mahabadian <mohammadreza.amerimahabadian@arm.com>
Signed-off-by: Kevin Petit <kevin.petit@arm.com>
Change-Id: I155dc7050a828d33b5f31e7b4eef8c580427ee1b
@CLAassistant
Copy link
Copy Markdown

CLA assistant check
Thank you for your submission! We really appreciate it. Like many open source projects, we ask that you sign our Contributor License Agreement before we can accept your contribution.
You have signed the CLA already but the status is still pending? Let us recheck it.

case spv::Op::OpConstantNull:
case spv::Op::OpConstant:
case spv::Op::OpConstantComposite:
case spv::Op::OpConstantCompositeReplicateEXT:
Copy link
Copy Markdown
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I don't think this is correct. The opcode is not used when creating the constant. You will be creating a vector constant with just a single element. This will lead to problems in other areas of the code. I think the same goes for OpSpecConstantCompositeReplicateEXT.

For those opcodes, you will have to replicate the id the appropriate number of times in literal_words_or_ids.

Copy link
Copy Markdown
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I did not author this change and was just upstreaming it for someone else but, diving into the code, I'm reaching the same conclusion as you. Replicating the id probably is the most straightforward solution. Another approach would be to add support for replication to CompositeConstant (and derived types) but this would be more complex/invasive I think.

const CompositeConstant* composite =
composite_constant->AsCompositeConstant();
ASSERT_NE(composite, nullptr);
ASSERT_FALSE(composite->GetComponents().empty());
Copy link
Copy Markdown
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

You should also assert that the number of components equals the number of elements in the vector. If not when trying to, say, fold an OpCompositeExtract that gets element 1 from the vector, the code will fail.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

4 participants