Mesa (main): aco: remove (wrong) GCC array-bounds warning
GitLab Mirror
gitlab-mirror at kemper.freedesktop.org
Mon Jul 12 12:25:50 UTC 2021
Module: Mesa
Branch: main
Commit: 9de4fe95e24ff8ab621703c4fdc3252586c8e3f5
URL: http://cgit.freedesktop.org/mesa/mesa/commit/?id=9de4fe95e24ff8ab621703c4fdc3252586c8e3f5
Author: Daniel Schürmann <daniel at schuermann.dev>
Date: Fri Jul 9 20:54:53 2021 +0200
aco: remove (wrong) GCC array-bounds warning
Reviewed-by: Tony Wasserka <tony.wasserka at gmx.de>
Part-of: <https://gitlab.freedesktop.org/mesa/mesa/-/merge_requests/11271>
---
src/amd/compiler/aco_print_ir.cpp | 29 ++++++++++++++---------------
1 file changed, 14 insertions(+), 15 deletions(-)
diff --git a/src/amd/compiler/aco_print_ir.cpp b/src/amd/compiler/aco_print_ir.cpp
index 219a852529c..c45e823ca65 100644
--- a/src/amd/compiler/aco_print_ir.cpp
+++ b/src/amd/compiler/aco_print_ir.cpp
@@ -727,9 +727,15 @@ void aco_print_instr(const Instruction *instr, FILE *output, unsigned flags)
bool *const neg = (bool *)alloca(instr->operands.size() * sizeof(bool));
bool *const opsel = (bool *)alloca(instr->operands.size() * sizeof(bool));
uint8_t *const sel = (uint8_t *)alloca(instr->operands.size() * sizeof(uint8_t));
+ for (unsigned i = 0; i < instr->operands.size(); ++i) {
+ abs[i] = false;
+ neg[i] = false;
+ opsel[i] = false;
+ sel[i] = sdwa_udword;
+ }
if (instr->isVOP3()) {
const VOP3_instruction& vop3 = instr->vop3();
- for (unsigned i = 0; i < instr->operands.size(); ++i) {
+ for (unsigned i = 0; i < 3; ++i) {
abs[i] = vop3.abs[i];
neg[i] = vop3.neg[i];
opsel[i] = vop3.opsel & (1 << i);
@@ -737,26 +743,19 @@ void aco_print_instr(const Instruction *instr, FILE *output, unsigned flags)
}
} else if (instr->isDPP()) {
const DPP_instruction& dpp = instr->dpp();
- for (unsigned i = 0; i < instr->operands.size(); ++i) {
- abs[i] = i < 2 ? dpp.abs[i] : false;
- neg[i] = i < 2 ? dpp.neg[i] : false;
+ for (unsigned i = 0; i < 2; ++i) {
+ abs[i] = dpp.abs[i];
+ neg[i] = dpp.neg[i];
opsel[i] = false;
sel[i] = sdwa_udword;
}
} else if (instr->isSDWA()) {
const SDWA_instruction& sdwa = instr->sdwa();
- for (unsigned i = 0; i < instr->operands.size(); ++i) {
- abs[i] = i < 2 ? sdwa.abs[i] : false;
- neg[i] = i < 2 ? sdwa.neg[i] : false;
- opsel[i] = false;
- sel[i] = i < 2 ? sdwa.sel[i] : sdwa_udword;
- }
- } else {
- for (unsigned i = 0; i < instr->operands.size(); ++i) {
- abs[i] = false;
- neg[i] = false;
+ for (unsigned i = 0; i < 2; ++i) {
+ abs[i] = sdwa.abs[i];
+ neg[i] = sdwa.neg[i];
opsel[i] = false;
- sel[i] = sdwa_udword;
+ sel[i] = sdwa.sel[i];
}
}
for (unsigned i = 0; i < instr->operands.size(); ++i) {
More information about the mesa-commit
mailing list