With simplify_gen_unary we end up with a not fully expanded RTX like

    (set (reg:SI 90) (and:SI (neg:SI (reg:SI 80)) (const_int 63)))

Then it will cause an ICE with unrecognizable insn.

gcc/ChangeLog:

        PR middle-end/113033
        * expmed.cc (expand_shift_1): When expanding rotate shift, call
        negate_rtx instead of simplify_gen_unary (NEG, ...).
---

Bootstrapped and regtested on x86_64-linux-gnu and
loongarch64-linux-gnu.  Ok for trunk?

 gcc/expmed.cc | 4 +---
 1 file changed, 1 insertion(+), 3 deletions(-)

diff --git a/gcc/expmed.cc b/gcc/expmed.cc
index 05331dd5d82..f9e416b9549 100644
--- a/gcc/expmed.cc
+++ b/gcc/expmed.cc
@@ -2634,9 +2634,7 @@ expand_shift_1 (enum tree_code code, machine_mode mode, 
rtx shifted,
                  (mode, GET_MODE_BITSIZE (scalar_mode) - INTVAL (op1));
              else
                {
-                 other_amount
-                   = simplify_gen_unary (NEG, GET_MODE (op1),
-                                         op1, GET_MODE (op1));
+                 other_amount = negate_rtx (GET_MODE (op1), op1);
                  HOST_WIDE_INT mask = GET_MODE_PRECISION (scalar_mode) - 1;
                  other_amount
                    = simplify_gen_binary (AND, GET_MODE (op1), other_amount,
-- 
2.43.0

Reply via email to