diff mbox

[v2,1/4] tricore: remove no-op abs() calls

Message ID 1426718625-24120-2-git-send-email-jsnow@redhat.com
State New
Headers show

Commit Message

John Snow March 18, 2015, 10:43 p.m. UTC
Calling abs() on a uint32_t is a no-op, so remove it.
clang 3.5.0 will not compile this if -Werror is set,
throwing a -Wabsolute-value warning.

Signed-off-by: John Snow <jsnow@redhat.com>
---
 target-tricore/op_helper.c | 12 ++++++------
 1 file changed, 6 insertions(+), 6 deletions(-)

Comments

Peter Maydell March 18, 2015, 10:51 p.m. UTC | #1
On 18 March 2015 at 22:43, John Snow <jsnow@redhat.com> wrote:
> Calling abs() on a uint32_t is a no-op, so remove it.
> clang 3.5.0 will not compile this if -Werror is set,
> throwing a -Wabsolute-value warning.
>
> Signed-off-by: John Snow <jsnow@redhat.com>

This is probably the wrong fix (ie it silences the
warning rather than fixing the bug). See
http://patchwork.ozlabs.org/patch/447585/

thanks
-- PMM
John Snow March 18, 2015, 10:55 p.m. UTC | #2
On 03/18/2015 06:51 PM, Peter Maydell wrote:
> On 18 March 2015 at 22:43, John Snow <jsnow@redhat.com> wrote:
>> Calling abs() on a uint32_t is a no-op, so remove it.
>> clang 3.5.0 will not compile this if -Werror is set,
>> throwing a -Wabsolute-value warning.
>>
>> Signed-off-by: John Snow <jsnow@redhat.com>
>
> This is probably the wrong fix (ie it silences the
> warning rather than fixing the bug). See
> http://patchwork.ozlabs.org/patch/447585/
>
> thanks
> -- PMM
>

Ah, I missed that there was another patch out there and a deeper bug. I 
thought this was a harmless abs() inclusion, but I didn't look too 
deeply at it.

I am fine with dropping this patch if a more comprehensive change is in 
the works, but the other three should still stand.

--js
diff mbox

Patch

diff --git a/target-tricore/op_helper.c b/target-tricore/op_helper.c
index 97b0c8b..5b82223 100644
--- a/target-tricore/op_helper.c
+++ b/target-tricore/op_helper.c
@@ -1953,9 +1953,9 @@  uint64_t helper_dvinit_b_13(CPUTriCoreState *env, uint32_t r1, uint32_t r2)
         quotient_sign = 1;
     }
 
-    abs_sig_dividend = abs(r1) >> 7;
-    abs_base_dividend = abs(r1) & 0x7f;
-    abs_divisor = abs(r1);
+    abs_sig_dividend = r1 >> 7;
+    abs_base_dividend = r1 & 0x7f;
+    abs_divisor = r1;
     /* calc overflow */
     env->PSW_USB_V = 0;
     if ((quotient_sign) && (abs_divisor)) {
@@ -2003,9 +2003,9 @@  uint64_t helper_dvinit_h_13(CPUTriCoreState *env, uint32_t r1, uint32_t r2)
         quotient_sign = 1;
     }
 
-    abs_sig_dividend = abs(r1) >> 7;
-    abs_base_dividend = abs(r1) & 0x7f;
-    abs_divisor = abs(r1);
+    abs_sig_dividend = r1 >> 7;
+    abs_base_dividend = r1 & 0x7f;
+    abs_divisor = r1;
     /* calc overflow */
     env->PSW_USB_V = 0;
     if ((quotient_sign) && (abs_divisor)) {