diff --git a/crates/rustc_codegen_spirv/src/linker/peephole_opts.rs b/crates/rustc_codegen_spirv/src/linker/peephole_opts.rs index 7977cfe63a..6fa7ea8bc4 100644 --- a/crates/rustc_codegen_spirv/src/linker/peephole_opts.rs +++ b/crates/rustc_codegen_spirv/src/linker/peephole_opts.rs @@ -72,7 +72,9 @@ pub fn composite_construct(types: &FxHashMap, function: &mut // of bounds, but just stop optimizing instead of panicing here. break; } - components[index] = Some(value); + if components[index].is_none() { + components[index] = Some(value); + } // Follow back one in the chain of OpCompositeInsert cur_inst = match defs.get(&cur_inst.operands[1].unwrap_id_ref()) { Some(i) => i,