aboutsummaryrefslogtreecommitdiff
path: root/sim/ppc
diff options
context:
space:
mode:
authorAndrew Burgess <aburgess@redhat.com>2022-10-19 15:12:57 +0100
committerAndrew Burgess <aburgess@redhat.com>2022-10-24 17:19:04 +0100
commite0b3df3b4d77706abf5f077477b2ca227fc4e9d1 (patch)
tree21b0c20eb478a4fe2a4fc596a730fd285f778182 /sim/ppc
parent548d634f1b61571f118c3133ce0e8986714c8fd6 (diff)
downloadfsf-binutils-gdb-e0b3df3b4d77706abf5f077477b2ca227fc4e9d1.zip
fsf-binutils-gdb-e0b3df3b4d77706abf5f077477b2ca227fc4e9d1.tar.gz
fsf-binutils-gdb-e0b3df3b4d77706abf5f077477b2ca227fc4e9d1.tar.bz2
sim/ppc: fix for operator precedence warning from clang
In the ppc simulator, clang was warning about some code like this: busy_ptr->nr_writebacks = 1 + (PPC_ONE_BIT_SET_P(out_vmask)) ? 1 : 2; The warning was: operator '?:' has lower precedence than '+'; '+' will be evaluated first I suspect that this is not the original authors intention. PPC_ONE_BIT_SET_P is going to be 0 or 1, so if we evaluate the '+' first, the condition will always be non-zero, so true. The whole expression could then be simplified to just '1', which doesn't make much sense. I suspect the answer the author was expecting was either 2 or 3. Why they didn't just write: busy_ptr->nr_writebacks = (PPC_ONE_BIT_SET_P(out_vmask)) ? 2 : 3; I have no clue, however, to keep the structure of the code unchanged, I've updated things to: busy_ptr->nr_writebacks = 1 + (PPC_ONE_BIT_SET_P (out_vmask) ? 1 : 2); which silences the warning from clang, and is, I am guessing, what the original author intended.
Diffstat (limited to 'sim/ppc')
-rw-r--r--sim/ppc/altivec.igen2
1 files changed, 1 insertions, 1 deletions
diff --git a/sim/ppc/altivec.igen b/sim/ppc/altivec.igen
index 63fe95a..f3ad32d 100644
--- a/sim/ppc/altivec.igen
+++ b/sim/ppc/altivec.igen
@@ -231,7 +231,7 @@ void::model-function::ppc_insn_vr_vscr:itable_index index, model_data *model_ptr
busy_ptr->vscr_busy = 1;
if (out_vmask)
- busy_ptr->nr_writebacks = 1 + (PPC_ONE_BIT_SET_P(out_vmask)) ? 1 : 2;
+ busy_ptr->nr_writebacks = 1 + (PPC_ONE_BIT_SET_P (out_vmask) ? 1 : 2);
if (WITH_TRACE && ppc_trace[trace_model])
model_trace_altivec_make_busy(model_ptr, vr_mask, 0);