target/arm: Coverity fixups
cover target/arm: Coverity fixups
The first patch covers four related false positives. However, we check the same condition twice and we certainly don't need to that. Plus the assert might just help documentation-wise.
The second patch covers dead code. I believe that Coverity is right and that there are no paths that have !is_q at this point. Add the assert to check that is true.
The RISU tests that I ran over these insns came out clean.
r~
Richard Henderson (2):
target/arm: Tidy conditions in handle_vec_simd_shri target/arm: Tidy condition in disas_simd_two_reg_misc
target/arm/translate-a64.c | 12 ++++++------ 1 file changed, 6 insertions(+), 6 deletions(-)
Signature · 1 line
2.14.3
PATCH 1/2 target/arm: Tidy conditions in handle_vec_simd_shri
The (size > 3 && !is_q) condition is identical to the preceeding test of bit 3 in immh; eliminate it. For the benefit of Coverity, assert that size is within the bounds we expect.
--- target/arm/translate-a64.c | 6 +----- 1 file changed, 1 insertion(+), 5 deletions(-)
target/arm/translate-a64.c +1 -5
@@ -9019,11 +9019,7 @@ static void handle_vec_simd_shri(DisasContext *s, bool is_q, bool is_u,unallocated_encoding (s);return ; } - -if (size >3 && !is_q) { -unallocated_encoding (s); -return ; - } +tcg_debug_assert (size <=3 );if (!fp_access_check (s)) {return ;
Signature · 1 line
2.14.3
Re: [Qemu-arm] [PATCH 1/2] target/arm: Tidy conditions in handle_vec_simd_shri
Quoted 9 lines · Richard Henderson
The (size > 3 && !is_q) condition is identical to the preceeding test of bit 3 in immh; eliminate it. For the benefit of Coverity, assert that size is within the bounds we expect.
Fixes Coverity CID1385846Fixes Coverity CID1385849Fixes Coverity CID1385852Fixes Coverity CID1385857Signed-off-by Richard Henderson <[email protected]>
Quoted 11 lines
--- target/arm/translate-a64.c | 6 +----- 1 file changed, 1 insertion(+), 5 deletions(-)target/arm/translate-a64.c +0
-0@@ -9019,11 +9019,7 @@ static void handle_vec_simd_shri(DisasContext *s, bool is_q, bool is_u,unallocated_encoding (s);return ;
target/arm/translate-a64.c static void handle_vec_simd_shri(DisasContext *s, bool is_q, bool is_u, · line 9025
Quoted 10 lines
target/arm/translate-a64.c +1
-5} - -if (size >3 && !is_q) { -unallocated_encoding (s); -return ; - } +tcg_debug_assert (size <=3 );if (!fp_access_check (s)) {return ;
--
Alex Bennée
PATCH 2/2 target/arm: Tidy condition in disas_simd_two_reg_misc
In reply to Richard HendersonPath analysis shows that size == 3 && !is_q has been eliminated.
--- target/arm/translate-a64.c | 6 +++++- 1 file changed, 5 insertions(+), 1 deletion(-)
target/arm/translate-a64.c +5 -1
@@ -11473,7 +11473,11 @@ static void disas_simd_two_reg_misc(DisasContext *s, uint32_t insn)/* All 64-bit element operations can be shared with scalar 2misc */ int pass; -for (pass =0 ; pass < (is_q ?2 :1 ); pass++) { +/* Coverity claims (size == 3 && !is_q) has been eliminated +* from all paths leading to here. +*/ +tcg_debug_assert (is_q); +for (pass =0 ; pass <2 ; pass++) {TCGv_i64 tcg_op =tcg_temp_new_i64 ();TCGv_i64 tcg_res =tcg_temp_new_i64 ();
Signature · 1 line
2.14.3
Re: [Qemu-arm] [PATCH 2/2] target/arm: Tidy condition in disas_simd_two_reg_misc
Quoted 4 lines · Richard Henderson
Path analysis shows that size == 3 && !is_q has been eliminated.
Fixes Coverity CID1385853Signed-off-by Richard Henderson <[email protected]>
Quoted 10 lines
--- target/arm/translate-a64.c | 6 +++++- 1 file changed, 5 insertions(+), 1 deletion(-)target/arm/translate-a64.c +0
-0@@ -11473,7 +11473,11 @@ static void disas_simd_two_reg_misc(DisasContext *s, uint32_t insn)/* All 64-bit element operations can be shared with scalar 2misc */
target/arm/translate-a64.c static void disas_simd_two_reg_misc(DisasContext *s, uint32_t insn) · line 11482
Quoted 10 lines
target/arm/translate-a64.c +5
-1int pass; -for (pass =0 ; pass < (is_q ?2 :1 ); pass++) { +/* Coverity claims (size == 3 && !is_q) has been eliminated +* from all paths leading to here. +*/ +tcg_debug_assert (is_q); +for (pass =0 ; pass <2 ; pass++) {TCGv_i64 tcg_op =tcg_temp_new_i64 ();TCGv_i64 tcg_res =tcg_temp_new_i64 ();
--
Alex Bennée
Peter Maydell
AppliedQuoted 10 lines · Richard Henderson
The first patch covers four related false positives. However, we check the same condition twice and we certainly don't need to that. Plus the assert might just help documentation-wise.
The second patch covers dead code. I believe that Coverity is right and that there are no paths that have !is_q at this point. Add the assert to check that is true.
The RISU tests that I ran over these insns came out clean.
Applied to target-arm.next, thanks.
-- PMM