Skip to contentSkip to conversation

s390x: Fix stoc direction

PATCH In review Alexander Graf 2 participants 2 messages Apr 15, 2015 – May 5, 2015

lore
Share & tools
lore
#0 lore raw

PATCH 1/1 s390x: Fix stoc direction

The store conditional instruction wants to store when the condition is fulfilled, so we should branch out when it's not true.

The code today branches out when the condition is true, clearly reversing the logic. Fix it up by negating the condition.

---
 target-s390x/translate.c | 4 ++++
 1 file changed, 4 insertions(+)
target-s390x/translate.c +4 -0
index 4f82edd..8ae4912 100644
@@ -3082,6 +3082,10 @@ static ExitStatus op_soc(DisasContext *s, DisasOps *o)
 
     disas_jcc(s, &c, get_field(s->fields, m3));
 
+    /* We want to store when the condition is fulfilled, so branch
+       out when it's not */
+    c.cond = tcg_invert_cond(c.cond);
+
     lab = gen_new_label();
     if (c.is_64) {
         tcg_gen_brcond_i64(c.cond, c.u.s64.a, c.u.s64.b, lab);
Signature · 1 line
1.8.1.4
Reviewed-by on v1 1/1
#1 lore raw
Quoted 16 lines · Alexander Graf

The store conditional instruction wants to store when the condition is fulfilled, so we should branch out when it's not true.

The code today branches out when the condition is true, clearly reversing the logic. Fix it up by negating the condition.

---
 target-s390x/translate.c | 4 ++++
 1 file changed, 4 insertions(+)
target-s390x/translate.c +0 -0
index 4f82edd..8ae4912 100644

target-s390x/translate.c static ExitStatus op_soc(DisasContext *s, DisasOps *o) · line 3087

Quoted 6 lines
target-s390x/translate.c +3 -0
@@ -3082,6 +3082,10 @@ static ExitStatus op_soc(DisasContext *s, DisasOps *o)
 
     disas_jcc(s, &c, get_field(s->fields, m3));
 
+    /* We want to store when the condition is fulfilled, so branch
+       out when it's not */
+    c.cond = tcg_invert_cond(c.cond);

Doh.

r~