Skip to content

Commit 4a939e2

Browse files
fixup! arc: check if the addend fits when referencing small data memory
1 parent dbd8e86 commit 4a939e2

File tree

1 file changed

+6
-5
lines changed

1 file changed

+6
-5
lines changed

gcc/config/arc/arc.cc

Lines changed: 6 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -386,8 +386,9 @@ legitimate_small_data_address_p (rtx x, machine_mode mode)
386386
return SYMBOL_REF_SMALL_P (x);
387387
case PLUS:
388388
{
389-
bool p0 = (GET_CODE (XEXP (x, 0)) == SYMBOL_REF)
390-
&& SYMBOL_REF_SMALL_P (XEXP (x, 0));
389+
if ((GET_CODE (XEXP (x, 0)) != SYMBOL_REF)
390+
|| !SYMBOL_REF_SMALL_P (XEXP (x, 0)))
391+
return false;
391392

392393
/* If no constant then we cannot do small data. */
393394
if (!CONST_INT_P (XEXP (x, 1)))
@@ -402,11 +403,11 @@ legitimate_small_data_address_p (rtx x, machine_mode mode)
402403
switch (size)
403404
{
404405
case 1:
405-
if (p0) break;
406+
break;
406407
case 2:
407-
if (p0 && ((offset & 0x1) == 0)) break;
408+
if ((offset & 0x1) == 0) break; else return false;
408409
case 4:
409-
if (p0 && ((offset & 0x3) == 0)) break;
410+
if ((offset & 0x3) == 0) break; else return false;
410411
default:
411412
return false;
412413
}

0 commit comments

Comments
 (0)