The fix for PR83969 accidentally disallowed PRE_INC and PRE_DEC addresses from being matched for the Y constraint leading to poor code generation. The following patch resurrects the fix for PR84279 (early test for altivec addresses) and then moves the call to rs6000_offsettable_memref_p below the address_offset test, which is what allows PRE_INC/PRE_DEC addresses to be matched.
Is this ok for trunk and the release branches where the earlier fixes were backported to, assuming no bootstrap errors and the testsuite runs do not show any regressions? Peter gcc/ PR target/85755 * config/rs6000/rs6000.c (mem_operand_gpr): Disable Altivec addresses. Move call to rs6000_offsettable_memref_p below call to address_offset to allow PRE_INC and PRE_DEC addresses. gcc/testsuite/ PR target/85755 * gcc.target/powerpc/pr85755.c: New test. Index: gcc/config/rs6000/rs6000.c =================================================================== --- gcc/config/rs6000/rs6000.c (revision 261279) +++ gcc/config/rs6000/rs6000.c (working copy) @@ -7997,15 +7997,19 @@ mem_operand_gpr (rtx op, machine_mode mo int extra; rtx addr = XEXP (op, 0); - /* Don't allow non-offsettable addresses. See PRs 83969 and 84279. */ - if (!rs6000_offsettable_memref_p (op, mode, false)) + /* PR84279: Don't allow altivec addresses like (mem (and (plus ...))). */ + if (GET_CODE (addr) == AND) return false; - op = address_offset (addr); - if (op == NULL_RTX) + rtx offset_op = address_offset (addr); + if (offset_op == NULL_RTX) return true; - offset = INTVAL (op); + /* PR83969: Don't allow non-offsettable addresses. */ + if (!rs6000_offsettable_memref_p (op, mode, false)) + return false; + + offset = INTVAL (offset_op); if (TARGET_POWERPC64 && (offset & 3) != 0) return false; Index: gcc/testsuite/gcc.target/powerpc/pr85755.c =================================================================== --- gcc/testsuite/gcc.target/powerpc/pr85755.c (nonexistent) +++ gcc/testsuite/gcc.target/powerpc/pr85755.c (working copy) @@ -0,0 +1,24 @@ +/* { dg-do compile { target { powerpc*-*-* } } } */ +/* { dg-skip-if "" { powerpc*-*-darwin* } } */ +/* { dg-require-effective-target powerpc_p8vector_ok } */ +/* { dg-skip-if "do not override -mcpu" { powerpc*-*-* } { "-mcpu=*" } { "-mcpu=power8" } } */ +/* { dg-options "-O1 -mcpu=power8" } */ + +void +preinc (long *q, long n) +{ + long i; + for (i = 0; i < n; i++) + q[i] = i; +} + +void +predec (long *q, long n) +{ + long i; + for (i = n; i >= 0; i--) + q[i] = i; +} + +/* { dg-final { scan-assembler-times {\mstdu\M} 2 } } */ +/* { dg-final { scan-assembler-not {\mstfdu\M} } } */