diff mbox series

[v2,4/5] target/mips: Refactor helpers for fp comparison instructions

Message ID 1602103041-32017-5-git-send-email-aleksandar.qemu.devel@gmail.com (mailing list archive)
State New, archived
Headers show
Series target/mips: Misc patches | expand

Commit Message

Aleksandar Markovic Oct. 7, 2020, 8:37 p.m. UTC
This change causes slighlty better performance of emulation of fp
comparison instructions via better compiler optimization of refactored
code. The functionality is otherwise unchanged.

Signed-off-by: Aleksandar Markovic <aleksandar.qemu.devel@gmail.com>
---
 target/mips/fpu_helper.c | 56 +++++++++++++++++++++++++++---------------------
 1 file changed, 32 insertions(+), 24 deletions(-)

Comments

Philippe Mathieu-Daudé Oct. 9, 2020, 2:47 p.m. UTC | #1
Hi Aleksandar,

On 10/7/20 10:37 PM, Aleksandar Markovic wrote:
> This change causes slighlty better performance of emulation of fp
> comparison instructions via better compiler optimization of refactored
> code. The functionality is otherwise unchanged.
> 
> Signed-off-by: Aleksandar Markovic <aleksandar.qemu.devel@gmail.com>
> ---
>   target/mips/fpu_helper.c | 56 +++++++++++++++++++++++++++---------------------
>   1 file changed, 32 insertions(+), 24 deletions(-)
> 
[...]

>   /*
> @@ -2080,12 +2088,12 @@ uint64_t helper_r6_cmp_d_ ## op(CPUMIPSState *env, uint64_t fdt0,   \
>   {                                                                   \
>       uint64_t c;                                                     \
>       c = cond;                                                       \
> -    update_fcr31(env, GETPC());                                     \
>       if (c) {                                                        \
>           return -1;                                                  \
>       } else {                                                        \
>           return 0;                                                   \
>       }                                                               \
> +    update_fcr31(env, GETPC());                                     \

Isn't it now never called (dead code)?

>   }
>   
>   /*
> @@ -2175,12 +2183,12 @@ uint32_t helper_r6_cmp_s_ ## op(CPUMIPSState *env, uint32_t fst0,   \
>   {                                                                   \
>       uint64_t c;                                                     \
>       c = cond;                                                       \
> -    update_fcr31(env, GETPC());                                     \
>       if (c) {                                                        \
>           return -1;                                                  \
>       } else {                                                        \
>           return 0;                                                   \
>       }                                                               \
> +    update_fcr31(env, GETPC());                                     \

Ditto.

>   }
>   
>   /*
>
Philippe Mathieu-Daudé Oct. 16, 2020, 8:17 p.m. UTC | #2
On 10/9/20 4:47 PM, Philippe Mathieu-Daudé wrote:
> Hi Aleksandar,
> 
> On 10/7/20 10:37 PM, Aleksandar Markovic wrote:
>> This change causes slighlty better performance of emulation of fp
>> comparison instructions via better compiler optimization of refactored
>> code. The functionality is otherwise unchanged.
>>
>> Signed-off-by: Aleksandar Markovic <aleksandar.qemu.devel@gmail.com>
>> ---
>>   target/mips/fpu_helper.c | 56 
>> +++++++++++++++++++++++++++---------------------
>>   1 file changed, 32 insertions(+), 24 deletions(-)
>>
> [...]
> 
>>   /*
>> @@ -2080,12 +2088,12 @@ uint64_t helper_r6_cmp_d_ ## op(CPUMIPSState 
>> *env, uint64_t fdt0,   \
>>   {                                                                   \
>>       uint64_t c;                                                     \
>>       c = cond;                                                       \
>> -    update_fcr31(env, GETPC());                                     \
>>       if (c) {                                                        \
>>           return -1;                                                  \
>>       } else {                                                        \
>>           return 0;                                                   \
>>       }                                                               \
>> +    update_fcr31(env, GETPC());                                     \
> 
> Isn't it now never called (dead code)?

Confirmed:

target/mips/fpu_helper.c: In function ‘helper_r6_cmp_d_af’:
target/mips/fpu_helper.c:2097:1: error: control reaches end of non-void 
function [-Werror=return-type]
  2097 | }
       | ^
target/mips/fpu_helper.c:2103:1: note: in expansion of macro ‘FOP_CONDN_D’
  2103 | FOP_CONDN_D(af,  (float64_unordered_quiet(fdt1, fdt0,
       | ^~~~~~~~~~~
Compiling C object libqemu-mips-softmmu.fa.p/target_mips_dsp_helper.c.o
target/mips/fpu_helper.c: In function ‘helper_r6_cmp_d_un’:
target/mips/fpu_helper.c:2097:1: error: control reaches end of non-void 
function [-Werror=return-type]
  2097 | }
       | ^
target/mips/fpu_helper.c:2105:1: note: in expansion of macro ‘FOP_CONDN_D’
  2105 | FOP_CONDN_D(un,  (float64_unordered_quiet(fdt1, fdt0,
       | ^~~~~~~~~~~
target/mips/fpu_helper.c: In function ‘helper_r6_cmp_d_eq’:
target/mips/fpu_helper.c:2097:1: error: control reaches end of non-void 
function [-Werror=return-type]
  2097 | }
       | ^
target/mips/fpu_helper.c:2107:1: note: in expansion of macro ‘FOP_CONDN_D’
  2107 | FOP_CONDN_D(eq,  (float64_eq_quiet(fdt0, fdt1,
       | ^~~~~~~~~~~
target/mips/fpu_helper.c: In function ‘helper_r6_cmp_d_ueq’:
target/mips/fpu_helper.c:2097:1: error: control reaches end of non-void 
function [-Werror=return-type]
  2097 | }
       | ^
target/mips/fpu_helper.c:2109:1: note: in expansion of macro ‘FOP_CONDN_D’
  2109 | FOP_CONDN_D(ueq, (float64_unordered_quiet(fdt1, fdt0,
       | ^~~~~~~~~~~
target/mips/fpu_helper.c: In function ‘helper_r6_cmp_d_lt’:
target/mips/fpu_helper.c:2097:1: error: control reaches end of non-void 
function [-Werror=return-type]
  2097 | }
       | ^
target/mips/fpu_helper.c:2113:1: note: in expansion of macro ‘FOP_CONDN_D’
  2113 | FOP_CONDN_D(lt,  (float64_lt_quiet(fdt0, fdt1,
       | ^~~~~~~~~~~
target/mips/fpu_helper.c: In function ‘helper_r6_cmp_d_ult’:
target/mips/fpu_helper.c:2097:1: error: control reaches end of non-void 
function [-Werror=return-type]
  2097 | }
       | ^
target/mips/fpu_helper.c:2115:1: note: in expansion of macro ‘FOP_CONDN_D’
  2115 | FOP_CONDN_D(ult, (float64_unordered_quiet(fdt1, fdt0,
       | ^~~~~~~~~~~
target/mips/fpu_helper.c: In function ‘helper_r6_cmp_d_le’:
target/mips/fpu_helper.c:2097:1: error: control reaches end of non-void 
function [-Werror=return-type]
  2097 | }
       | ^
target/mips/fpu_helper.c:2119:1: note: in expansion of macro ‘FOP_CONDN_D’
  2119 | FOP_CONDN_D(le,  (float64_le_quiet(fdt0, fdt1,
       | ^~~~~~~~~~~
target/mips/fpu_helper.c: In function ‘helper_r6_cmp_d_ule’:
target/mips/fpu_helper.c:2097:1: error: control reaches end of non-void 
function [-Werror=return-type]
  2097 | }
       | ^
target/mips/fpu_helper.c:2121:1: note: in expansion of macro ‘FOP_CONDN_D’
  2121 | FOP_CONDN_D(ule, (float64_unordered_quiet(fdt1, fdt0,
       | ^~~~~~~~~~~
target/mips/fpu_helper.c: In function ‘helper_r6_cmp_d_saf’:
target/mips/fpu_helper.c:2097:1: error: control reaches end of non-void 
function [-Werror=return-type]
  2097 | }
       | ^
target/mips/fpu_helper.c:2129:1: note: in expansion of macro ‘FOP_CONDN_D’
  2129 | FOP_CONDN_D(saf,  (float64_unordered(fdt1, fdt0,
       | ^~~~~~~~~~~
target/mips/fpu_helper.c: In function ‘helper_r6_cmp_d_sun’:
target/mips/fpu_helper.c:2097:1: error: control reaches end of non-void 
function [-Werror=return-type]
  2097 | }
       | ^
target/mips/fpu_helper.c:2131:1: note: in expansion of macro ‘FOP_CONDN_D’
  2131 | FOP_CONDN_D(sun,  (float64_unordered(fdt1, fdt0,
       | ^~~~~~~~~~~
target/mips/fpu_helper.c: In function ‘helper_r6_cmp_d_seq’:
target/mips/fpu_helper.c:2097:1: error: control reaches end of non-void 
function [-Werror=return-type]
  2097 | }
       | ^
target/mips/fpu_helper.c:2133:1: note: in expansion of macro ‘FOP_CONDN_D’
  2133 | FOP_CONDN_D(seq,  (float64_eq(fdt0, fdt1,
       | ^~~~~~~~~~~
target/mips/fpu_helper.c: In function ‘helper_r6_cmp_d_sueq’:
target/mips/fpu_helper.c:2097:1: error: control reaches end of non-void 
function [-Werror=return-type]
  2097 | }
       | ^
target/mips/fpu_helper.c:2135:1: note: in expansion of macro ‘FOP_CONDN_D’
  2135 | FOP_CONDN_D(sueq, (float64_unordered(fdt1, fdt0,
       | ^~~~~~~~~~~
target/mips/fpu_helper.c: In function ‘helper_r6_cmp_d_slt’:
target/mips/fpu_helper.c:2097:1: error: control reaches end of non-void 
function [-Werror=return-type]
  2097 | }
       | ^
target/mips/fpu_helper.c:2139:1: note: in expansion of macro ‘FOP_CONDN_D’
  2139 | FOP_CONDN_D(slt,  (float64_lt(fdt0, fdt1,
       | ^~~~~~~~~~~
target/mips/fpu_helper.c: In function ‘helper_r6_cmp_d_sult’:
target/mips/fpu_helper.c:2097:1: error: control reaches end of non-void 
function [-Werror=return-type]
  2097 | }
       | ^
target/mips/fpu_helper.c:2141:1: note: in expansion of macro ‘FOP_CONDN_D’
  2141 | FOP_CONDN_D(sult, (float64_unordered(fdt1, fdt0,
       | ^~~~~~~~~~~
target/mips/fpu_helper.c: In function ‘helper_r6_cmp_d_sle’:
target/mips/fpu_helper.c:2097:1: error: control reaches end of non-void 
function [-Werror=return-type]
  2097 | }
       | ^
target/mips/fpu_helper.c:2145:1: note: in expansion of macro ‘FOP_CONDN_D’
  2145 | FOP_CONDN_D(sle,  (float64_le(fdt0, fdt1,
       | ^~~~~~~~~~~
target/mips/fpu_helper.c: In function ‘helper_r6_cmp_d_sule’:
target/mips/fpu_helper.c:2097:1: error: control reaches end of non-void 
function [-Werror=return-type]
  2097 | }
       | ^
target/mips/fpu_helper.c:2147:1: note: in expansion of macro ‘FOP_CONDN_D’
  2147 | FOP_CONDN_D(sule, (float64_unordered(fdt1, fdt0,
       | ^~~~~~~~~~~
target/mips/fpu_helper.c: In function ‘helper_r6_cmp_d_or’:
target/mips/fpu_helper.c:2097:1: error: control reaches end of non-void 
function [-Werror=return-type]
  2097 | }
       | ^
target/mips/fpu_helper.c:2151:1: note: in expansion of macro ‘FOP_CONDN_D’
  2151 | FOP_CONDN_D(or,   (float64_le_quiet(fdt1, fdt0,
       | ^~~~~~~~~~~
target/mips/fpu_helper.c: In function ‘helper_r6_cmp_d_une’:
target/mips/fpu_helper.c:2097:1: error: control reaches end of non-void 
function [-Werror=return-type]
  2097 | }
       | ^
target/mips/fpu_helper.c:2155:1: note: in expansion of macro ‘FOP_CONDN_D’
  2155 | FOP_CONDN_D(une,  (float64_unordered_quiet(fdt1, fdt0,
       | ^~~~~~~~~~~
target/mips/fpu_helper.c: In function ‘helper_r6_cmp_d_ne’:
target/mips/fpu_helper.c:2097:1: error: control reaches end of non-void 
function [-Werror=return-type]
  2097 | }
       | ^
target/mips/fpu_helper.c:2161:1: note: in expansion of macro ‘FOP_CONDN_D’
  2161 | FOP_CONDN_D(ne,   (float64_lt_quiet(fdt1, fdt0,
       | ^~~~~~~~~~~
target/mips/fpu_helper.c: In function ‘helper_r6_cmp_d_sor’:
target/mips/fpu_helper.c:2097:1: error: control reaches end of non-void 
function [-Werror=return-type]
  2097 | }
       | ^
target/mips/fpu_helper.c:2165:1: note: in expansion of macro ‘FOP_CONDN_D’
  2165 | FOP_CONDN_D(sor,  (float64_le(fdt1, fdt0,
       | ^~~~~~~~~~~
target/mips/fpu_helper.c: In function ‘helper_r6_cmp_d_sune’:
target/mips/fpu_helper.c:2097:1: error: control reaches end of non-void 
function [-Werror=return-type]
  2097 | }
       | ^
target/mips/fpu_helper.c:2169:1: note: in expansion of macro ‘FOP_CONDN_D’
  2169 | FOP_CONDN_D(sune, (float64_unordered(fdt1, fdt0,
       | ^~~~~~~~~~~
target/mips/fpu_helper.c: In function ‘helper_r6_cmp_d_sne’:
target/mips/fpu_helper.c:2097:1: error: control reaches end of non-void 
function [-Werror=return-type]
  2097 | }
       | ^
target/mips/fpu_helper.c:2175:1: note: in expansion of macro ‘FOP_CONDN_D’
  2175 | FOP_CONDN_D(sne,  (float64_lt(fdt1, fdt0,
       | ^~~~~~~~~~~
target/mips/fpu_helper.c: In function ‘helper_r6_cmp_s_af’:
target/mips/fpu_helper.c:2192:1: error: control reaches end of non-void 
function [-Werror=return-type]
  2192 | }
       | ^
target/mips/fpu_helper.c:2198:1: note: in expansion of macro ‘FOP_CONDN_S’
  2198 | FOP_CONDN_S(af,   (float32_unordered_quiet(fst1, fst0,
       | ^~~~~~~~~~~
target/mips/fpu_helper.c: In function ‘helper_r6_cmp_s_un’:
target/mips/fpu_helper.c:2192:1: error: control reaches end of non-void 
function [-Werror=return-type]
  2192 | }
       | ^
target/mips/fpu_helper.c:2200:1: note: in expansion of macro ‘FOP_CONDN_S’
  2200 | FOP_CONDN_S(un,   (float32_unordered_quiet(fst1, fst0,
       | ^~~~~~~~~~~
target/mips/fpu_helper.c: In function ‘helper_r6_cmp_s_eq’:
target/mips/fpu_helper.c:2192:1: error: control reaches end of non-void 
function [-Werror=return-type]
  2192 | }
       | ^
target/mips/fpu_helper.c:2202:1: note: in expansion of macro ‘FOP_CONDN_S’
  2202 | FOP_CONDN_S(eq,   (float32_eq_quiet(fst0, fst1,
       | ^~~~~~~~~~~
target/mips/fpu_helper.c: In function ‘helper_r6_cmp_s_ueq’:
target/mips/fpu_helper.c:2192:1: error: control reaches end of non-void 
function [-Werror=return-type]
  2192 | }
       | ^
target/mips/fpu_helper.c:2204:1: note: in expansion of macro ‘FOP_CONDN_S’
  2204 | FOP_CONDN_S(ueq,  (float32_unordered_quiet(fst1, fst0,
       | ^~~~~~~~~~~
target/mips/fpu_helper.c: In function ‘helper_r6_cmp_s_lt’:
target/mips/fpu_helper.c:2192:1: error: control reaches end of non-void 
function [-Werror=return-type]
  2192 | }
       | ^
target/mips/fpu_helper.c:2208:1: note: in expansion of macro ‘FOP_CONDN_S’
  2208 | FOP_CONDN_S(lt,   (float32_lt_quiet(fst0, fst1,
       | ^~~~~~~~~~~
target/mips/fpu_helper.c: In function ‘helper_r6_cmp_s_ult’:
target/mips/fpu_helper.c:2192:1: error: control reaches end of non-void 
function [-Werror=return-type]
  2192 | }
       | ^
target/mips/fpu_helper.c:2210:1: note: in expansion of macro ‘FOP_CONDN_S’
  2210 | FOP_CONDN_S(ult,  (float32_unordered_quiet(fst1, fst0,
       | ^~~~~~~~~~~
target/mips/fpu_helper.c: In function ‘helper_r6_cmp_s_le’:
target/mips/fpu_helper.c:2192:1: error: control reaches end of non-void 
function [-Werror=return-type]
  2192 | }
       | ^
target/mips/fpu_helper.c:2214:1: note: in expansion of macro ‘FOP_CONDN_S’
  2214 | FOP_CONDN_S(le,   (float32_le_quiet(fst0, fst1,
       | ^~~~~~~~~~~
target/mips/fpu_helper.c: In function ‘helper_r6_cmp_s_ule’:
target/mips/fpu_helper.c:2192:1: error: control reaches end of non-void 
function [-Werror=return-type]
  2192 | }
       | ^
target/mips/fpu_helper.c:2216:1: note: in expansion of macro ‘FOP_CONDN_S’
  2216 | FOP_CONDN_S(ule,  (float32_unordered_quiet(fst1, fst0,
       | ^~~~~~~~~~~
target/mips/fpu_helper.c: In function ‘helper_r6_cmp_s_saf’:
target/mips/fpu_helper.c:2192:1: error: control reaches end of non-void 
function [-Werror=return-type]
  2192 | }
       | ^
target/mips/fpu_helper.c:2224:1: note: in expansion of macro ‘FOP_CONDN_S’
  2224 | FOP_CONDN_S(saf,  (float32_unordered(fst1, fst0,
       | ^~~~~~~~~~~
target/mips/fpu_helper.c: In function ‘helper_r6_cmp_s_sun’:
target/mips/fpu_helper.c:2192:1: error: control reaches end of non-void 
function [-Werror=return-type]
  2192 | }
       | ^
target/mips/fpu_helper.c:2226:1: note: in expansion of macro ‘FOP_CONDN_S’
  2226 | FOP_CONDN_S(sun,  (float32_unordered(fst1, fst0,
       | ^~~~~~~~~~~
target/mips/fpu_helper.c: In function ‘helper_r6_cmp_s_seq’:
target/mips/fpu_helper.c:2192:1: error: control reaches end of non-void 
function [-Werror=return-type]
  2192 | }
       | ^
target/mips/fpu_helper.c:2228:1: note: in expansion of macro ‘FOP_CONDN_S’
  2228 | FOP_CONDN_S(seq,  (float32_eq(fst0, fst1,
       | ^~~~~~~~~~~
target/mips/fpu_helper.c: In function ‘helper_r6_cmp_s_sueq’:
target/mips/fpu_helper.c:2192:1: error: control reaches end of non-void 
function [-Werror=return-type]
  2192 | }
       | ^
target/mips/fpu_helper.c:2230:1: note: in expansion of macro ‘FOP_CONDN_S’
  2230 | FOP_CONDN_S(sueq, (float32_unordered(fst1, fst0,
       | ^~~~~~~~~~~
target/mips/fpu_helper.c: In function ‘helper_r6_cmp_s_slt’:
target/mips/fpu_helper.c:2192:1: error: control reaches end of non-void 
function [-Werror=return-type]
  2192 | }
       | ^
target/mips/fpu_helper.c:2234:1: note: in expansion of macro ‘FOP_CONDN_S’
  2234 | FOP_CONDN_S(slt,  (float32_lt(fst0, fst1,
       | ^~~~~~~~~~~
target/mips/fpu_helper.c: In function ‘helper_r6_cmp_s_sult’:
target/mips/fpu_helper.c:2192:1: error: control reaches end of non-void 
function [-Werror=return-type]
  2192 | }
       | ^
target/mips/fpu_helper.c:2236:1: note: in expansion of macro ‘FOP_CONDN_S’
  2236 | FOP_CONDN_S(sult, (float32_unordered(fst1, fst0,
       | ^~~~~~~~~~~
target/mips/fpu_helper.c: In function ‘helper_r6_cmp_s_sle’:
target/mips/fpu_helper.c:2192:1: error: control reaches end of non-void 
function [-Werror=return-type]
  2192 | }
       | ^
target/mips/fpu_helper.c:2240:1: note: in expansion of macro ‘FOP_CONDN_S’
  2240 | FOP_CONDN_S(sle,  (float32_le(fst0, fst1,
       | ^~~~~~~~~~~
target/mips/fpu_helper.c: In function ‘helper_r6_cmp_s_sule’:
target/mips/fpu_helper.c:2192:1: error: control reaches end of non-void 
function [-Werror=return-type]
  2192 | }
       | ^
target/mips/fpu_helper.c:2242:1: note: in expansion of macro ‘FOP_CONDN_S’
  2242 | FOP_CONDN_S(sule, (float32_unordered(fst1, fst0,
       | ^~~~~~~~~~~
target/mips/fpu_helper.c: In function ‘helper_r6_cmp_s_or’:
target/mips/fpu_helper.c:2192:1: error: control reaches end of non-void 
function [-Werror=return-type]
  2192 | }
       | ^
target/mips/fpu_helper.c:2246:1: note: in expansion of macro ‘FOP_CONDN_S’
  2246 | FOP_CONDN_S(or,   (float32_le_quiet(fst1, fst0,
       | ^~~~~~~~~~~
target/mips/fpu_helper.c: In function ‘helper_r6_cmp_s_une’:
target/mips/fpu_helper.c:2192:1: error: control reaches end of non-void 
function [-Werror=return-type]
  2192 | }
       | ^
target/mips/fpu_helper.c:2250:1: note: in expansion of macro ‘FOP_CONDN_S’
  2250 | FOP_CONDN_S(une,  (float32_unordered_quiet(fst1, fst0,
       | ^~~~~~~~~~~
target/mips/fpu_helper.c: In function ‘helper_r6_cmp_s_ne’:
target/mips/fpu_helper.c:2192:1: error: control reaches end of non-void 
function [-Werror=return-type]
  2192 | }
       | ^
target/mips/fpu_helper.c:2256:1: note: in expansion of macro ‘FOP_CONDN_S’
  2256 | FOP_CONDN_S(ne,   (float32_lt_quiet(fst1, fst0,
       | ^~~~~~~~~~~
target/mips/fpu_helper.c: In function ‘helper_r6_cmp_s_sor’:
target/mips/fpu_helper.c:2192:1: error: control reaches end of non-void 
function [-Werror=return-type]
  2192 | }
       | ^
target/mips/fpu_helper.c:2260:1: note: in expansion of macro ‘FOP_CONDN_S’
  2260 | FOP_CONDN_S(sor,  (float32_le(fst1, fst0,
       | ^~~~~~~~~~~
target/mips/fpu_helper.c: In function ‘helper_r6_cmp_s_sune’:
target/mips/fpu_helper.c:2192:1: error: control reaches end of non-void 
function [-Werror=return-type]
  2192 | }
       | ^
target/mips/fpu_helper.c:2264:1: note: in expansion of macro ‘FOP_CONDN_S’
  2264 | FOP_CONDN_S(sune, (float32_unordered(fst1, fst0,
       | ^~~~~~~~~~~
target/mips/fpu_helper.c: In function ‘helper_r6_cmp_s_sne’:
target/mips/fpu_helper.c:2192:1: error: control reaches end of non-void 
function [-Werror=return-type]
  2192 | }
       | ^
target/mips/fpu_helper.c:2270:1: note: in expansion of macro ‘FOP_CONDN_S’
  2270 | FOP_CONDN_S(sne,  (float32_lt(fst1, fst0,
       | ^~~~~~~~~~~
Compiling C object libqemu-mips-softmmu.fa.p/target_mips_cpu.c.o
cc1: all warnings being treated as errors
Makefile.ninja:3848: recipe for target 
'libqemu-mips-softmmu.fa.p/target_mips_fpu_helper.c.o' failed
make: *** [libqemu-mips-softmmu.fa.p/target_mips_fpu_helper.c.o] Error 1
diff mbox series

Patch

diff --git a/target/mips/fpu_helper.c b/target/mips/fpu_helper.c
index 6cc956c..8d48a5b 100644
--- a/target/mips/fpu_helper.c
+++ b/target/mips/fpu_helper.c
@@ -1780,11 +1780,12 @@  void helper_cmp_d_ ## op(CPUMIPSState *env, uint64_t fdt0,     \
 {                                                              \
     int c;                                                     \
     c = cond;                                                  \
-    update_fcr31(env, GETPC());                                \
-    if (c)                                                     \
+    if (c) {                                                   \
         SET_FP_COND(cc, env->active_fpu);                      \
-    else                                                       \
+    } else {                                                   \
         CLEAR_FP_COND(cc, env->active_fpu);                    \
+    }                                                          \
+    update_fcr31(env, GETPC());                                \
 }                                                              \
 void helper_cmpabs_d_ ## op(CPUMIPSState *env, uint64_t fdt0,  \
                             uint64_t fdt1, int cc)             \
@@ -1793,11 +1794,12 @@  void helper_cmpabs_d_ ## op(CPUMIPSState *env, uint64_t fdt0,  \
     fdt0 = float64_abs(fdt0);                                  \
     fdt1 = float64_abs(fdt1);                                  \
     c = cond;                                                  \
-    update_fcr31(env, GETPC());                                \
-    if (c)                                                     \
+    if (c) {                                                   \
         SET_FP_COND(cc, env->active_fpu);                      \
-    else                                                       \
+    } else {                                                   \
         CLEAR_FP_COND(cc, env->active_fpu);                    \
+    }                                                          \
+    update_fcr31(env, GETPC());                                \
 }
 
 /*
@@ -1859,11 +1861,12 @@  void helper_cmp_s_ ## op(CPUMIPSState *env, uint32_t fst0,     \
 {                                                              \
     int c;                                                     \
     c = cond;                                                  \
-    update_fcr31(env, GETPC());                                \
-    if (c)                                                     \
+    if (c) {                                                   \
         SET_FP_COND(cc, env->active_fpu);                      \
-    else                                                       \
+    } else {                                                   \
         CLEAR_FP_COND(cc, env->active_fpu);                    \
+    }                                                          \
+    update_fcr31(env, GETPC());                                \
 }                                                              \
 void helper_cmpabs_s_ ## op(CPUMIPSState *env, uint32_t fst0,  \
                             uint32_t fst1, int cc)             \
@@ -1872,11 +1875,12 @@  void helper_cmpabs_s_ ## op(CPUMIPSState *env, uint32_t fst0,  \
     fst0 = float32_abs(fst0);                                  \
     fst1 = float32_abs(fst1);                                  \
     c = cond;                                                  \
-    update_fcr31(env, GETPC());                                \
-    if (c)                                                     \
+    if (c) {                                                   \
         SET_FP_COND(cc, env->active_fpu);                      \
-    else                                                       \
+    } else {                                                   \
         CLEAR_FP_COND(cc, env->active_fpu);                    \
+    }                                                          \
+    update_fcr31(env, GETPC());                                \
 }
 
 /*
@@ -1944,15 +1948,17 @@  void helper_cmp_ps_ ## op(CPUMIPSState *env, uint64_t fdt0,     \
     fsth1 = fdt1 >> 32;                                         \
     cl = condl;                                                 \
     ch = condh;                                                 \
-    update_fcr31(env, GETPC());                                 \
-    if (cl)                                                     \
+    if (cl) {                                                   \
         SET_FP_COND(cc, env->active_fpu);                       \
-    else                                                        \
+    } else {                                                    \
         CLEAR_FP_COND(cc, env->active_fpu);                     \
-    if (ch)                                                     \
+    }                                                           \
+    if (ch) {                                                   \
         SET_FP_COND(cc + 1, env->active_fpu);                   \
-    else                                                        \
+    } else {                                                    \
         CLEAR_FP_COND(cc + 1, env->active_fpu);                 \
+    }                                                           \
+    update_fcr31(env, GETPC());                                 \
 }                                                               \
 void helper_cmpabs_ps_ ## op(CPUMIPSState *env, uint64_t fdt0,  \
                              uint64_t fdt1, int cc)             \
@@ -1965,15 +1971,17 @@  void helper_cmpabs_ps_ ## op(CPUMIPSState *env, uint64_t fdt0,  \
     fsth1 = float32_abs(fdt1 >> 32);                            \
     cl = condl;                                                 \
     ch = condh;                                                 \
-    update_fcr31(env, GETPC());                                 \
-    if (cl)                                                     \
+    if (cl) {                                                   \
         SET_FP_COND(cc, env->active_fpu);                       \
-    else                                                        \
+    } else {                                                    \
         CLEAR_FP_COND(cc, env->active_fpu);                     \
-    if (ch)                                                     \
+    }                                                           \
+    if (ch) {                                                   \
         SET_FP_COND(cc + 1, env->active_fpu);                   \
-    else                                                        \
+    } else {                                                    \
         CLEAR_FP_COND(cc + 1, env->active_fpu);                 \
+    }                                                           \
+    update_fcr31(env, GETPC());                                 \
 }
 
 /*
@@ -2080,12 +2088,12 @@  uint64_t helper_r6_cmp_d_ ## op(CPUMIPSState *env, uint64_t fdt0,   \
 {                                                                   \
     uint64_t c;                                                     \
     c = cond;                                                       \
-    update_fcr31(env, GETPC());                                     \
     if (c) {                                                        \
         return -1;                                                  \
     } else {                                                        \
         return 0;                                                   \
     }                                                               \
+    update_fcr31(env, GETPC());                                     \
 }
 
 /*
@@ -2175,12 +2183,12 @@  uint32_t helper_r6_cmp_s_ ## op(CPUMIPSState *env, uint32_t fst0,   \
 {                                                                   \
     uint64_t c;                                                     \
     c = cond;                                                       \
-    update_fcr31(env, GETPC());                                     \
     if (c) {                                                        \
         return -1;                                                  \
     } else {                                                        \
         return 0;                                                   \
     }                                                               \
+    update_fcr31(env, GETPC());                                     \
 }
 
 /*