@@ -564,7 +564,8 @@ static bool
564564arc64_legitimate_address_1_p (machine_mode mode ,
565565 rtx x ,
566566 bool strict ATTRIBUTE_UNUSED ,
567- bool load_p )
567+ bool load_p ,
568+ bool scaling_p )
568569{
569570 if (REG_P (x ))
570571 return true;
@@ -577,7 +578,8 @@ arc64_legitimate_address_1_p (machine_mode mode,
577578 offset as address. */
578579 if (GET_CODE (x ) == PLUS
579580 && REG_P (XEXP (x , 0 ))
580- && (ARC64_CHECK_SMALL_IMMEDIATE (XEXP (x , 1 ), mode )
581+ && (ARC64_CHECK_SMALL_IMMEDIATE (XEXP (x , 1 ),
582+ scaling_p ? mode : QImode )
581583 || (load_p && CONST_INT_P (XEXP (x , 1 ))
582584 && !lra_in_progress && !optimize_size )))
583585 return true;
@@ -590,7 +592,8 @@ arc64_legitimate_address_1_p (machine_mode mode,
590592 return true;
591593
592594 /* Scalled addresses. */
593- if (GET_CODE (x ) == PLUS
595+ if (scaling_p
596+ && GET_CODE (x ) == PLUS
594597 && GET_CODE (XEXP (x , 0 )) == MULT
595598 && ((load_p && REG_P (XEXP (x , 1 )))
596599 || (load_p && CONST_INT_P (XEXP (x , 1 )))
@@ -615,7 +618,8 @@ arc64_legitimate_address_1_p (machine_mode mode,
615618 return true;
616619
617620 if ((GET_CODE (x ) == PRE_MODIFY || GET_CODE (x ) == POST_MODIFY ))
618- return arc64_legitimate_address_1_p (mode , XEXP (x , 1 ), strict , load_p );
621+ return arc64_legitimate_address_1_p (mode , XEXP (x , 1 ), strict ,
622+ load_p , false);
619623
620624 /* PIC address (LARGE). */
621625 if (GET_CODE (x ) == LO_SUM
@@ -651,7 +655,7 @@ arc64_legitimate_address_p (machine_mode mode,
651655 bool strict ATTRIBUTE_UNUSED )
652656{
653657 /* Allow all the addresses accepted by load. */
654- return arc64_legitimate_address_1_p (mode , x , strict , true);
658+ return arc64_legitimate_address_1_p (mode , x , strict , true, true );
655659}
656660
657661/* Implement TARGET_LEGITIMATE_CONSTANT_P hook. Return true for constants
@@ -2519,7 +2523,8 @@ arc64_prepare_move_operands (rtx op0, rtx op1, machine_mode mode)
25192523
25202524 /* Check and fix unsupported store addresses. */
25212525 if (MEM_P (op0 )
2522- && !arc64_legitimate_address_1_p (mode , XEXP (op0 , 0 ), false, false))
2526+ && !arc64_legitimate_address_1_p (mode , XEXP (op0 , 0 ), false,
2527+ false, true))
25232528 {
25242529 rtx tmp = gen_reg_rtx (Pmode );
25252530 rtx addr = XEXP (op0 , 0 );
@@ -2884,7 +2889,7 @@ arc64_limm_addr_p (rtx op)
28842889bool
28852890arc64_legitimate_store_address_p (machine_mode mode , rtx addr )
28862891{
2887- return arc64_legitimate_address_1_p (mode , addr , true, false);
2892+ return arc64_legitimate_address_1_p (mode , addr , true, false, true );
28882893}
28892894
28902895/* Return true if an address fits a short load/store instruction. */
0 commit comments