https://gcc.gnu.org/bugzilla/show_bug.cgi?id=117506

Jakub Jelinek <jakub at gcc dot gnu.org> changed:

           What    |Removed                     |Added
----------------------------------------------------------------------------
                 CC|                            |law at gcc dot gnu.org

--- Comment #5 from Jakub Jelinek <jakub at gcc dot gnu.org> ---
So, we have a loop with
(insn 3 72 4 5 (set (reg:DI 159 [ ivtmp_86 ])
        (const_int 0 [0])) "pr117506.c":7:7 277 {*movdi_64bit}
     (nil))
before the loop and
(insn 84 80 86 6 (set (reg:DI 159 [ ivtmp_86 ])
        (sign_extend:DI (plus:SI (subreg/s/u:SI (reg:DI 159 [ ivtmp_86 ]) 0)
                (reg:SI 216)))) "pr117506.c":6:23 discrim 1 8 {addsi3_extended}
     (expr_list:REG_DEAD (reg:SI 216)
        (expr_list:REG_EQUAL (sign_extend:DI (plus:SI (subreg/s/u:SI (reg:DI
159 [ ivtmp_86 ]) 0)
                    (const_poly_int:SI [8, 8])))
            (nil))))
inside of the loop.
The BIV analysis uses DImode as outermode, that is fine, but then
r14-1622-g99bfdb072e67fa3fe294d86b4b2a9f686f8d9705 added some loop-iv.cc RISCV
specific hacks.
Now, because (const_poly_int:SI [8, 8]) is a CONSTANT_P but doesn't have
VOIDmode, that obviously causes ICE on the simplify_gen_binary.
Guess one possibility would be to
--- gcc/loop-iv.cc.jj   2025-01-02 11:23:04.479684906 +0100
+++ gcc/loop-iv.cc      2025-01-29 11:55:57.723511186 +0100
@@ -711,7 +711,7 @@ get_biv_step_1 (df_ref def, scalar_int_m
          if (CONSTANT_P (op0))
            std::swap (op0, op1);

-         if (!simple_reg_p (op0) || !CONSTANT_P (op1))
+         if (!simple_reg_p (op0) || !CONST_INT_P (op1))
            return false;

          prev_code = code;
Another would be to make sure op1 is SIGN/ZERO_EXTENDED before we actually use
it later in the simplify_gen_binary:
--- gcc/loop-iv.cc.jj   2025-01-02 11:23:04.479684906 +0100
+++ gcc/loop-iv.cc      2025-01-29 12:01:08.899294623 +0100
@@ -714,6 +714,7 @@ get_biv_step_1 (df_ref def, scalar_int_m
          if (!simple_reg_p (op0) || !CONSTANT_P (op1))
            return false;

+         op1 = simplify_gen_unary (code, outer_mode, op1, GET_MODE (rhs));
          prev_code = code;
          code = PLUS;
        }
Both fix the ICE on this testcase but otherwise completely untested.
But, I have no way to test this on RISC-V, so deferring to Jeff as the commit
author.

Reply via email to