@@ -3055,7 +3055,8 @@ riscv_rtx_costs (rtx x, machine_mode mode, int outer_code, int opno ATTRIBUTE_UN
case SET:
/* If we are called for an INSN that's a simple set of a register,
then cost based on the SET_SRC alone. */
- if (outer_code == INSN && REG_P (SET_DEST (x)))
+ if (outer_code == INSN
+ && register_operand (SET_DEST (x), GET_MODE (SET_DEST (x))))
{
riscv_rtx_costs (SET_SRC (x), mode, outer_code, opno, total, speed);
return true;
@@ -3172,7 +3173,7 @@ riscv_rtx_costs (rtx x, machine_mode mode, int outer_code, int opno ATTRIBUTE_UN
rtx and_rhs = XEXP (x, 1);
rtx ashift_lhs = XEXP (XEXP (x, 0), 0);
rtx ashift_rhs = XEXP (XEXP (x, 0), 1);
- if (REG_P (ashift_lhs)
+ if (register_operand (ashift_lhs, GET_MODE (ashift_lhs))
&& CONST_INT_P (ashift_rhs)
&& CONST_INT_P (and_rhs)
&& ((INTVAL (and_rhs) >> INTVAL (ashift_rhs)) == 0xffffffff))
@@ -3188,7 +3189,7 @@ riscv_rtx_costs (rtx x, machine_mode mode, int outer_code, int opno ATTRIBUTE_UN
}
/* bclr pattern for zbs. */
if (TARGET_ZBS
- && REG_P (XEXP (x, 1))
+ && register_operand (XEXP (x, 1), GET_MODE (XEXP (x, 1)))
&& GET_CODE (XEXP (x, 0)) == ROTATE
&& CONST_INT_P (XEXP ((XEXP (x, 0)), 0))
&& INTVAL (XEXP ((XEXP (x, 0)), 0)) == -2)
@@ -3344,7 +3345,8 @@ riscv_rtx_costs (rtx x, machine_mode mode, int outer_code, int opno ATTRIBUTE_UN
if (TARGET_ZBA
&& (TARGET_64BIT && (mode == DImode))
&& GET_CODE (XEXP (x, 0)) == ZERO_EXTEND
- && REG_P (XEXP (XEXP (x, 0), 0))
+ && register_operand (XEXP (XEXP (x, 0), 0),
+ GET_MODE (XEXP (XEXP (x, 0), 0)))
&& GET_MODE (XEXP (XEXP (x, 0), 0)) == SImode)
{
*total = COSTS_N_INSNS (1);
@@ -3355,7 +3357,8 @@ riscv_rtx_costs (rtx x, machine_mode mode, int outer_code, int opno ATTRIBUTE_UN
&& ((!TARGET_64BIT && (mode == SImode)) ||
(TARGET_64BIT && (mode == DImode)))
&& (GET_CODE (XEXP (x, 0)) == ASHIFT)
- && REG_P (XEXP (XEXP (x, 0), 0))
+ && register_operand (XEXP (XEXP (x, 0), 0),
+ GET_MODE (XEXP (XEXP (x, 0), 0)))
&& CONST_INT_P (XEXP (XEXP (x, 0), 1))
&& IN_RANGE (INTVAL (XEXP (XEXP (x, 0), 1)), 1, 3))
{
@@ -3368,7 +3371,8 @@ riscv_rtx_costs (rtx x, machine_mode mode, int outer_code, int opno ATTRIBUTE_UN
if (TARGET_ZBA
&& mode == word_mode
&& GET_CODE (XEXP (x, 0)) == MULT
- && REG_P (XEXP (XEXP (x, 0), 0))
+ && register_operand (XEXP (XEXP (x, 0), 0),
+ GET_MODE (XEXP (XEXP (x, 0), 0)))
&& CONST_INT_P (XEXP (XEXP (x, 0), 1))
&& pow2p_hwi (INTVAL (XEXP (XEXP (x, 0), 1)))
&& IN_RANGE (exact_log2 (INTVAL (XEXP (XEXP (x, 0), 1))), 1, 3))
@@ -3390,7 +3394,7 @@ riscv_rtx_costs (rtx x, machine_mode mode, int outer_code, int opno ATTRIBUTE_UN
if (TARGET_ZBA
&& (TARGET_64BIT && (mode == DImode))
&& (GET_CODE (XEXP (x, 0)) == AND)
- && (REG_P (XEXP (x, 1))))
+ && register_operand (XEXP (x, 1), GET_MODE (XEXP (x, 1))))
{
do {
rtx and_lhs = XEXP (XEXP (x, 0), 0);
new file mode 100644
@@ -0,0 +1,15 @@
+/* { dg-do compile } */
+/* { dg-require-effective-target rv64 } */
+/* { dg-skip-if "" { *-*-* } { "-O0" "-Og" "-Os" "-Oz" } } */
+/* { dg-options "-march=rv64gc_zba" } */
+
+#include <stdint-gcc.h>
+void foo(uint32_t a, uint64_t *b_ptr, uint64_t b, uint64_t *c_ptr, uint64_t c)
+{
+ uint64_t x = a;
+ *b_ptr = b + x;
+ *c_ptr = c + x;
+}
+
+/* { dg-final { scan-assembler-not "\\szext.w\\s" } } */
+