Hi! The following testcase ICEs because a peephole2 attempts to offset memory which is not offsettable (in particular address is a ZERO_EXTEND in this case).
Because peephole2s don't support constraints, I've added a check for this in the peephole2's condition. Bootstrapped/regtested on x86_64-linux and i686-linux, acked by Uros in the PR, committed to trunk so far. 2025-03-26 Jakub Jelinek <ja...@redhat.com> PR target/119450 * config/i386/i386.md (narrow test peephole2): Test for offsettable_memref_p in condition. * gcc.target/i386/pr119450.c: New test. --- gcc/config/i386/i386.md.jj 2025-03-25 09:34:33.000000000 +0100 +++ gcc/config/i386/i386.md 2025-03-25 10:44:21.265290918 +0100 @@ -12411,7 +12411,9 @@ (define_peephole2 (and:SWI248 (match_operand:SWI248 0 "memory_operand") (match_operand 1 "const_int_operand")) (const_int 0)))] - "!TARGET_PARTIAL_MEMORY_READ_STALL && !MEM_VOLATILE_P (operands[0])" + "!TARGET_PARTIAL_MEMORY_READ_STALL + && !MEM_VOLATILE_P (operands[0]) + && offsettable_memref_p (operands[0])" [(set (reg:CCZ FLAGS_REG) (compare:CCZ (match_dup 2) (const_int 0)))] { --- gcc/testsuite/gcc.target/i386/pr119450.c.jj 2025-03-25 10:47:30.735704828 +0100 +++ gcc/testsuite/gcc.target/i386/pr119450.c 2025-03-25 10:47:16.412900321 +0100 @@ -0,0 +1,15 @@ +/* PR target/119450 */ +/* { dg-do compile } */ +/* { dg-options "-O3" } */ + +long *a; +int b; + +void +foo (void) +{ + unsigned d = b >> 30; + a = (long *) (__UINTPTR_TYPE__) d; + if (*a & 1 << 30) + *a = 0; +} Jakub