Skip to content

array memset testing #596

@brody2consult

Description

@brody2consult

NOTE: I would be happy to contribute the testing, likely based on the test cases from #586 if that is merged.


I discovered that the following codegen mutations do not trigger any compiletest or difftest failures:

diff --git a/crates/rustc_codegen_spirv/src/builder/builder_methods.rs b/crates/rustc_codegen_spirv/src/builder/builder_methods.rs
index d86db1cbd0..b6a867933f 100644
--- a/crates/rustc_codegen_spirv/src/builder/builder_methods.rs
+++ b/crates/rustc_codegen_spirv/src/builder/builder_methods.rs
@@ -290,21 +290,16 @@ macro_rules! simple_uni_op {
 }
 
 fn memset_fill_u16(b: u8) -> u16 {
-    b as u16 | ((b as u16) << 8)
+    b as u16
 }
 
 fn memset_fill_u32(b: u8) -> u32 {
-    b as u32 | ((b as u32) << 8) | ((b as u32) << 16) | ((b as u32) << 24)
+    b as u32
 }
 
 fn memset_fill_u64(b: u8) -> u64 {
     b as u64
         | ((b as u64) << 8)
-        | ((b as u64) << 16)
-        | ((b as u64) << 24)
-        | ((b as u64) << 32)
-        | ((b as u64) << 40)
-        | ((b as u64) << 48)
         | ((b as u64) << 56)
 }
 
@@ -384,9 +379,6 @@ impl<'a, 'tcx> Builder<'a, 'tcx> {
                 32 => self
                     .constant_u32(self.span(), memset_fill_u32(fill_byte))
                     .def(self),
-                64 => self
-                    .constant_u64(self.span(), memset_fill_u64(fill_byte))
-                    .def(self),
                 _ => self.fatal(format!(
                     "memset on integer width {width} not implemented yet"
                 )),

I discovered this while investigating possible testing for a more general solution to #594.

I think the test cases from PR #586 may be able to help avoid this issue if we can adapt these to test memset array fill for u64, i64, u32, etc & check the disassembly. This would give me some more confidence in case we would ever want to refactor some of this memset-related code (someday).

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions