]> git.ipfire.org Git - thirdparty/gcc.git/commitdiff
RISC-V: Replace simm32_p with immediate_operand (Pmode)
authorJu-Zhe Zhong <juzhe.zhong@rivai.ai>
Tue, 14 Feb 2023 15:04:49 +0000 (23:04 +0800)
committerKito Cheng <kito.cheng@sifive.com>
Fri, 17 Feb 2023 02:46:11 +0000 (10:46 +0800)
simm32_p is used to check constant int value within 32-bit.
It's used in handling SEW = 64 in rv32 system since such constant int
value with 32-bit allow us use vx instruction.

The current implementation of simm32_p is quite ugly and now I figure
out immedate_operand (op, pmode) can help us to check whether the op
is a constant value within 32-bit.

I already have a bunch testcases to test SEW = 64 in rv32 system and
all regression tests are passed with this patch.

gcc/ChangeLog:

* config/riscv/riscv-protos.h (simm32_p): Remove.
* config/riscv/riscv-v.cc (simm32_p): Ditto.
* config/riscv/vector.md: Use immediate_operand
instead of riscv_vector::simm32_p.

gcc/config/riscv/riscv-protos.h
gcc/config/riscv/riscv-v.cc
gcc/config/riscv/vector.md

index 9d8b0b78a06d99229f82800d0181b2a08bdea58a..ee8e903ddf55471f7a937e0150d71ac4bfc6fb94 100644 (file)
@@ -176,7 +176,6 @@ enum tail_policy get_prefer_tail_policy ();
 enum mask_policy get_prefer_mask_policy ();
 rtx get_avl_type_rtx (enum avl_type);
 opt_machine_mode get_vector_mode (scalar_mode, poly_uint64);
-extern bool simm32_p (rtx);
 extern bool simm5_p (rtx);
 extern bool neg_simm5_p (rtx);
 #ifdef RTX_CODE
index 600b2e6ecadba99c28190298362bb65d7f051848..dd70bf9b541314b4198cc52b6b4f147bdb1c49f6 100644 (file)
@@ -396,16 +396,6 @@ get_vector_mode (scalar_mode inner_mode, poly_uint64 nunits)
   return opt_machine_mode ();
 }
 
-/* Helper functions for handling sew=64 on RV32 system. */
-bool
-simm32_p (rtx x)
-{
-  if (!CONST_INT_P (x))
-    return false;
-  unsigned HOST_WIDE_INT val = UINTVAL (x);
-  return val <= 0x7FFFFFFFULL || val >= 0xFFFFFFFF80000000ULL;
-}
-
 bool
 simm5_p (rtx x)
 {
index 2d8179f948c8b4323b07ed14bf8d7913218fbe9b..cc550b7458b97991d2843227df402d50f73602b1 100644 (file)
       {
        rtx v = gen_reg_rtx (<MODE>mode);
 
-       if (riscv_vector::simm32_p (operands[3]))
+       if (immediate_operand (operands[3], Pmode))
          operands[3] = gen_rtx_SIGN_EXTEND (<VEL>mode,
                force_reg (Pmode, operands[3]));
        else
       {
        rtx v = gen_reg_rtx (<MODE>mode);
 
-       if (riscv_vector::simm32_p (operands[4]))
+       if (immediate_operand (operands[4], Pmode))
          {
            if (!rtx_equal_p (operands[4], const0_rtx))
              operands[4] = force_reg (Pmode, operands[4]);
       {
        rtx v = gen_reg_rtx (<MODE>mode);
 
-       if (riscv_vector::simm32_p (operands[4]))
+       if (immediate_operand (operands[4], Pmode))
          {
            if (!rtx_equal_p (operands[4], const0_rtx))
              operands[4] = force_reg (Pmode, operands[4]);
       {
        rtx v = gen_reg_rtx (<MODE>mode);
 
-       if (riscv_vector::simm32_p (operands[4]))
+       if (immediate_operand (operands[4], Pmode))
          operands[4] = gen_rtx_SIGN_EXTEND (<VEL>mode,
                force_reg (Pmode, operands[4]));
        else
       {
        rtx v = gen_reg_rtx (<MODE>mode);
 
-       if (riscv_vector::simm32_p (operands[4]))
+       if (immediate_operand (operands[4], Pmode))
          operands[4] = gen_rtx_SIGN_EXTEND (<VEL>mode,
                force_reg (Pmode, operands[4]));
        else
       {
        rtx v = gen_reg_rtx (<MODE>mode);
 
-       if (riscv_vector::simm32_p (operands[4]))
+       if (immediate_operand (operands[4], Pmode))
          operands[4] = gen_rtx_SIGN_EXTEND (<VEL>mode,
                force_reg (Pmode, operands[4]));
        else
       {
        rtx v = gen_reg_rtx (<MODE>mode);
 
-       if (riscv_vector::simm32_p (operands[4]))
+       if (immediate_operand (operands[4], Pmode))
          {
            if (!rtx_equal_p (operands[4], const0_rtx))
              operands[4] = force_reg (Pmode, operands[4]);
       {
         rtx v = gen_reg_rtx (<MODE>mode);
 
-       if (riscv_vector::simm32_p (operands[3]))
+       if (immediate_operand (operands[3], Pmode))
          operands[3] = gen_rtx_SIGN_EXTEND (<VEL>mode,
                force_reg (Pmode, operands[3]));
         else
       {
         rtx v = gen_reg_rtx (<MODE>mode);
 
-       if (riscv_vector::simm32_p (operands[3]))
+       if (immediate_operand (operands[3], Pmode))
          {
            if (!rtx_equal_p (operands[3], const0_rtx))
              operands[3] = force_reg (Pmode, operands[3]);
       {
        rtx v = gen_reg_rtx (<MODE>mode);
 
-       if (riscv_vector::simm32_p (operands[2]))
+       if (immediate_operand (operands[2], Pmode))
          operands[2] = gen_rtx_SIGN_EXTEND (<VEL>mode,
                force_reg (Pmode, operands[2]));
        else
       {
         rtx v = gen_reg_rtx (<MODE>mode);
 
-       if (riscv_vector::simm32_p (operands[2]))
+       if (immediate_operand (operands[2], Pmode))
          {
            if (!rtx_equal_p (operands[2], const0_rtx))
              operands[2] = force_reg (Pmode, operands[2]);
       {
         rtx v = gen_reg_rtx (<MODE>mode);
 
-       if (riscv_vector::simm32_p (operands[2]))
+       if (immediate_operand (operands[2], Pmode))
          operands[2] = gen_rtx_SIGN_EXTEND (<VEL>mode,
                force_reg (Pmode, operands[2]));
        else
       {
         rtx v = gen_reg_rtx (<MODE>mode);
 
-       if (riscv_vector::simm32_p (operands[2]))
+       if (immediate_operand (operands[2], Pmode))
          {
            if (!rtx_equal_p (operands[2], const0_rtx))
              operands[2] = force_reg (Pmode, operands[2]);
       {
        rtx v = gen_reg_rtx (<MODE>mode);
 
-       if (riscv_vector::simm32_p (operands[4]))
+       if (immediate_operand (operands[4], Pmode))
          {
            if (!rtx_equal_p (operands[4], const0_rtx))
              operands[4] = force_reg (Pmode, operands[4]);
       {
        rtx v = gen_reg_rtx (<MODE>mode);
 
-       if (riscv_vector::simm32_p (operands[5]))
+       if (immediate_operand (operands[5], Pmode))
          {
            if (!rtx_equal_p (operands[5], const0_rtx))
              operands[5] = force_reg (Pmode, operands[5]);
       {
        rtx v = gen_reg_rtx (<MODE>mode);
 
-       if (riscv_vector::simm32_p (operands[5]))
+       if (immediate_operand (operands[5], Pmode))
          {
            if (!rtx_equal_p (operands[5], const0_rtx))
              operands[5] = force_reg (Pmode, operands[5]);
     {
       rtx v = gen_reg_rtx (<MODE>mode);
 
-      if (riscv_vector::simm32_p (operands[2]))
+      if (immediate_operand (operands[2], Pmode))
         operands[2] = gen_rtx_SIGN_EXTEND (<VEL>mode,
                force_reg (Pmode, operands[2]));
       else