On 09/28/2015 11:12 AM, Jeff Law wrote:
On 09/26/2015 03:05 AM, Andreas Schwab wrote:
Jeff Law <l...@redhat.com> writes:
@@ -9320,7 +9320,9 @@ arc_legitimize_reload_address (rtx *p,
machine_mode mode, int opnum,
if ((scale-1) & offset)
scale = 1;
shift = scale >> 1;
- offset_base = (offset + (256 << shift)) & (-512 << shift);
+ offset_base
+ = ((offset + (256 << shift))
+ & ((HOST_WIDE_INT)(-512U << shift)));
If HOST_WIDE_INT is bigger than int then this is not the same.
I'll fix this too.
Fixed thusly.
Rebuilt arceb-linux-uclibc for testing purposes.
Jeff
commit 0cd75b5dc1dd8ed3f60d0b12d5cc43cc52d213aa
Author: Jeff Law <l...@tor.usersys.redhat.com>
Date: Mon Sep 28 13:23:43 2015 -0400
Re: [PATCH] Fix undefined behaviour in arc port
* config/arc/arc.c (arc_legitimize_reload_address): Fix stupid
thinko in last change.
* config/arc/constraints.md (C2a): Fix typos in last change.
diff --git a/gcc/config/arc/arc.c b/gcc/config/arc/arc.c
index 4d731b5..a6a1921 100644
--- a/gcc/config/arc/arc.c
+++ b/gcc/config/arc/arc.c
@@ -9322,7 +9322,7 @@ arc_legitimize_reload_address (rtx *p, machine_mode mode,
int opnum,
shift = scale >> 1;
offset_base
= ((offset + (256 << shift))
- & ((HOST_WIDE_INT)(-512U << shift)));
+ & ((HOST_WIDE_INT)((unsigned HOST_WIDE_INT) -512 << shift)));
/* Sometimes the normal form does not suit DImode. We
could avoid that by using smaller ranges, but that
would give less optimized code when SImode is
diff --git a/gcc/config/arc/constraints.md b/gcc/config/arc/constraints.md
index b3ea115..3d0db36 100644
--- a/gcc/config/arc/constraints.md
+++ b/gcc/config/arc/constraints.md
@@ -195,7 +195,7 @@
"@internal
Unconditional two-address add / sub constant"
(and (match_code "const_int")
- (match_test "ival == HOST_WIDE_INT (HOST_WIDE_INT_M1U << 31)
+ (match_test "ival == (HOST_WIDE_INT) (HOST_WIDE_INT_M1U << 31)
|| (ival >= -0x4000 && ival <= 0x4000
&& ((ival >= 0 ? ival : -ival)
<= 0x7ff * (ival & -ival)))")))