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

Andrew Pinski <pinskia at gcc dot gnu.org> changed:

           What    |Removed                     |Added
----------------------------------------------------------------------------
   Last reconfirmed|                            |2025-07-30
           Keywords|                            |build
     Ever confirmed|0                           |1
           Assignee|unassigned at gcc dot gnu.org      |pinskia at gcc dot 
gnu.org
             Status|UNCONFIRMED                 |ASSIGNED

--- Comment #2 from Andrew Pinski <pinskia at gcc dot gnu.org> ---
diff --git a/gcc/simplify-rtx.cc b/gcc/simplify-rtx.cc
index 442da9f40fa..a83c0343e78 100644
--- a/gcc/simplify-rtx.cc
+++ b/gcc/simplify-rtx.cc
@@ -8341,7 +8341,22 @@ simplify_context::simplify_subreg (machine_mode
outermode, rtx op,
       rtx op0 = simplify_subreg (outermode, XEXP (op, 0), innermode, byte);
       rtx op1 = simplify_subreg (outermode, XEXP (op, 1), innermode, byte);
       if (op0 && op1)
+{
+      fprintf (stderr, "op0 = ");
+      print_rtl (stderr, op0);
+      fprintf (stderr, "\n");
+      fprintf (stderr, "op1 = ");
+      print_rtl (stderr, op1);
+      fprintf (stderr, "\n");
        return simplify_gen_binary (GET_CODE (op), outermode, op0, op1);
+}
+    }
+  /* Attempt to simplify WORD_MODE SUBREGs of unary bitwise expression.  */
+  if (outermode == word_mode && GET_CODE (op) == NOT)
+    {
+      rtx op0 = simplify_subreg (outermode, XEXP (op, 0), innermode, byte);
+      if (op0)
+       return simplify_gen_unary (GET_CODE (op), outermode, op0, outermode);
     }

   scalar_int_mode int_outermode, int_innermode;
@@ -8689,6 +8704,7 @@ test_scalar_int_ext_ops (machine_mode bmode, machine_mode
smode)


Fixes it. (ignore the prints).

But basically the new code does not hit in this case since there is already:
```
  /* Attempt to simplify WORD_MODE SUBREGs of bitwise expressions.  */
  if (outermode == word_mode
      && (GET_CODE (op) == IOR || GET_CODE (op) == XOR || GET_CODE (op) == AND)
      && SCALAR_INT_MODE_P (innermode))
    {
      rtx op0 = simplify_subreg (outermode, XEXP (op, 0), innermode, byte);
      rtx op1 = simplify_subreg (outermode, XEXP (op, 1), innermode, byte);
      if (op0 && op1)
        return simplify_gen_binary (GET_CODE (op), outermode, op0, op1);
    }
```

But this does not handle `(subreg:word (not:larger (subreg:larger (reg:word) 0)
0)`
So there is a disconnect between what is produced by the above vs what is done
by the new code due to the missing of the (subreg:word (not a) into (not
(subreg a)) .
So I will add that.

Reply via email to