https://gcc.gnu.org/bugzilla/show_bug.cgi?id=123114
--- Comment #2 from Jakub Jelinek <jakub at gcc dot gnu.org> ---
The PR52345 change wants to optimize
(set (reg/i:DI 10 a0)
(ne:DI (ior:DI (ne:DI (reg:DI 151 [ a ])
(const_int 0 [0]))
(reg:DI 152 [ b ]))
(const_int 0 [0])))
but here we have
(set (reg:CCZ 17 flags)
(compare:CCZ (ior:QI (ne:QI (reg/v:SI 104 [ c ])
(const_int 0 [0]))
(reg:QI 98 [ _5 ]))
(const_int 0 [0])))
instead and nothing verifies that in
22b3de712f79 gcc/simplify-rtx.cc (Shreya Munnangi 2025-11-02 19:21:53
-0700 6505)
22b3de712f79 gcc/simplify-rtx.cc (Shreya Munnangi 2025-11-02 19:21:53
-0700 6506) if ((code == NE || code == EQ)
22b3de712f79 gcc/simplify-rtx.cc (Shreya Munnangi 2025-11-02 19:21:53
-0700 6507) /* Verify op0 is IOR */
22b3de712f79 gcc/simplify-rtx.cc (Shreya Munnangi 2025-11-02 19:21:53
-0700 6508) && GET_CODE (op0) == IOR
22b3de712f79 gcc/simplify-rtx.cc (Shreya Munnangi 2025-11-02 19:21:53
-0700 6509) /* only enters if op1 is 0 */
22b3de712f79 gcc/simplify-rtx.cc (Shreya Munnangi 2025-11-02 19:21:53
-0700 6510) /* Verify IOR operand is NE */
22b3de712f79 gcc/simplify-rtx.cc (Shreya Munnangi 2025-11-02 19:21:53
-0700 6511) && GET_CODE (XEXP (op0, 0)) == NE
2e1d74b27283 gcc/simplify-rtx.cc (Jeff Law 2025-11-17 10:40:46
-0700 6512) /* Verify second NE operand is 0 */
22b3de712f79 gcc/simplify-rtx.cc (Shreya Munnangi 2025-11-02 19:21:53
-0700 6513) && XEXP (XEXP (op0, 0), 1) == CONST0_RTX (mode))
22b3de712f79 gcc/simplify-rtx.cc (Shreya Munnangi 2025-11-02 19:21:53
-0700 6514) {
2e1d74b27283 gcc/simplify-rtx.cc (Jeff Law 2025-11-17 10:40:46
-0700 6515) rtx t = gen_rtx_IOR (cmp_mode, XEXP (XEXP (op0, 0), 0), XEXP
(op0, 1));
22b3de712f79 gcc/simplify-rtx.cc (Shreya Munnangi 2025-11-02 19:21:53
-0700 6516) t = gen_rtx_fmt_ee (code, mode, t, CONST0_RTX (mode));
22b3de712f79 gcc/simplify-rtx.cc (Shreya Munnangi 2025-11-02 19:21:53
-0700 6517) return t;
22b3de712f79 gcc/simplify-rtx.cc (Shreya Munnangi 2025-11-02 19:21:53
-0700 6518) }
XEXP (XEXP (op0, 0), 0) actually has the cmp_mode. It has in PR52345 (both are
DImode), but here cmp_mode is QImode, while
XEXP (XEXP (op0, 0), 0) has SImode.
I wonder about the
XEXP (XEXP (op0, 0), 1) == CONST0_RTX (mode)
comparison as well, shouldn't that be CONST0_RTX (cmp_mode) too?
So perhaps
--- gcc/simplify-rtx.cc.jj 2025-12-09 10:18:55.437229339 +0100
+++ gcc/simplify-rtx.cc 2025-12-13 23:04:14.672186706 +0100
@@ -6509,8 +6509,9 @@ simplify_context::simplify_relational_op
/* only enters if op1 is 0 */
/* Verify IOR operand is NE */
&& GET_CODE (XEXP (op0, 0)) == NE
+ && GET_MODE (XEXP (XEXP (op0, 0), 0)) == cmp_mode
/* Verify second NE operand is 0 */
- && XEXP (XEXP (op0, 0), 1) == CONST0_RTX (mode))
+ && XEXP (XEXP (op0, 0), 1) == CONST0_RTX (cmp_mode))
{
rtx t = gen_rtx_IOR (cmp_mode, XEXP (XEXP (op0, 0), 0), XEXP (op0,
1));
t = gen_rtx_fmt_ee (code, mode, t, CONST0_RTX (mode));