Hi!

As mentioned in the PR, the following testcase ICEs because rs, while valid
add_operand is not valid add_cint_operand and so gen_add3_insn fails,
because it doesn't meet the expander predicates.

Fixed thusly, bootstrapped/regtested on powerpc64{,le}-linux, ok for trunk?

Another option would be to:
1) always use gen_add3_insn, but if it returns NULL use the extra
emit_move_insn (end_addr, GEN_INT (-rounded_size));
and retry with end_addr instead of rs
2) if the first gen_add3_insn returned NULL or if it created more than one
instruction, add the REG_FRAME_RELATED_EXPR note on the last insn

Is that what you want to do instead?

2020-01-06  Jakub Jelinek  <ja...@redhat.com>

        PR target/93122
        * config/rs6000/rs6000-logue.c
        (rs6000_emit_probe_stack_range_stack_clash): Only use gen_addr3_insn
        if add_cint_operand predicate matches.  Use rs instead of doing
        GEN_INT again.

        * gcc.target/powerpc/pr93122.c: New test.

--- gcc/config/rs6000/rs6000-logue.c.jj 2020-01-01 12:22:32.945491552 +0100
+++ gcc/config/rs6000/rs6000-logue.c    2020-01-02 12:59:09.612734662 +0100
@@ -1605,11 +1605,11 @@ rs6000_emit_probe_stack_range_stack_clas
        = copy_reg ? gen_rtx_REG (Pmode, 0) : gen_rtx_REG (Pmode, 12);
       rtx rs = GEN_INT (-rounded_size);
       rtx_insn *insn;
-      if (add_operand (rs, Pmode))
+      if (add_cint_operand (rs, Pmode) && add_operand (rs, Pmode))
        insn = emit_insn (gen_add3_insn (end_addr, stack_pointer_rtx, rs));
       else
        {
-         emit_move_insn (end_addr, GEN_INT (-rounded_size));
+         emit_move_insn (end_addr, rs);
          insn = emit_insn (gen_add3_insn (end_addr, end_addr,
                                           stack_pointer_rtx));
          /* Describe the effect of INSN to the CFI engine.  */
--- gcc/testsuite/gcc.target/powerpc/pr93122.c.jj       2020-01-02 
13:07:07.022459554 +0100
+++ gcc/testsuite/gcc.target/powerpc/pr93122.c  2020-01-06 07:05:31.397917021 
+0100
@@ -0,0 +1,12 @@
+/* PR target/93122 */
+/* { dg-do compile { target lp64 } } */
+/* { dg-options "-fstack-clash-protection -mprefixed-addr -mfuture" } */
+
+void bar (char *);
+
+void
+foo (void)
+{
+  char s[4294967296];
+  bar (s);
+}

        Jakub

Reply via email to