Fixes strided vector stores. As per RiscV Vector documentation the stride is a byte stride, and therefore should not be scaled by the element size. This is the case for vector load strided. However, vector store strided erroneously scaled the stride. This has been fixed, and the test has been updated accordingly. PiperOrigin-RevId: 660400129 Change-Id: Iac39f1df21ba9269959533ff1abd197a4a7db2c5
diff --git a/riscv/riscv_vector_memory_instructions.cc b/riscv/riscv_vector_memory_instructions.cc index 36a2da6..fb2731a 100644 --- a/riscv/riscv_vector_memory_instructions.cc +++ b/riscv/riscv_vector_memory_instructions.cc
@@ -805,7 +805,7 @@ for (int i = vstart; i < num_elements; i++) { int mask_index = i >> 3; int mask_offset = i & 0b111; - addresses[i - vstart] = base + i * stride * sizeof(T); + addresses[i - vstart] = base + i * stride; masks[i - vstart] = ((src_masks[mask_index] >> mask_offset) & 0b1) != 0; store_data[i - vstart] = GetInstructionSource<T>(inst, 0, i); }
diff --git a/riscv/test/riscv_vector_memory_instructions_test.cc b/riscv/test/riscv_vector_memory_instructions_test.cc index 58d6899..98270f5 100644 --- a/riscv/test/riscv_vector_memory_instructions_test.cc +++ b/riscv/test/riscv_vector_memory_instructions_test.cc
@@ -812,7 +812,7 @@ for (int lmul_index = 0; lmul_index < 7; lmul_index++) { // Try different strides. for (int s = 0; s < 5; s++) { - int32_t stride = strides[s]; + int32_t stride = strides[s] * sizeof(T); SetRegisterValues<int32_t>({{kRs2Name, stride}}); // Configure vector unit. uint32_t vtype = (kSewSettingsByByteSize[sizeof(T)] << 3) | @@ -840,7 +840,7 @@ } else { EXPECT_EQ(data_db->template Get<T>(0), 0) << "index: " << i; } - base += stride * sizeof(T); + base += stride; value++; } data_db->DecRef();