]> git.ipfire.org Git - thirdparty/gcc.git/commitdiff
ree: Skip extension on fixed register
authorH.J. Lu <hjl.tools@gmail.com>
Wed, 8 Jan 2025 12:50:04 +0000 (20:50 +0800)
committerH.J. Lu <hjl.tools@gmail.com>
Thu, 9 Jan 2025 08:38:31 +0000 (16:38 +0800)
Skip extension on fixed register since we can't turn

(insn 27 26 139 2 (parallel [
            (set (reg/f:SI 7 sp)
                (plus:SI (reg/f:SI 7 sp)
                    (const_int 16 [0x10])))
            (clobber (reg:CC 17 flags))
        ]) "x.ii":14:17 discrim 1 283 {*addsi_1}
     (expr_list:REG_ARGS_SIZE (const_int 0 [0])
        (nil)))
...
(insn 43 125 74 2 (set (reg/f:DI 6 bp [145])
        (zero_extend:DI (reg/f:SI 7 sp))) "x.ii":15:9 175 {*zero_extendsidi2}
     (nil))

into

(insn 27 26 155 2 (parallel [
            (set (reg:DI 6 bp)
                (zero_extend:DI (plus:SI (reg/f:SI 7 sp)
                        (const_int 16 [0x10]))))
            (clobber (reg:CC 17 flags))
        ]) "x.ii":14:17 discrim 1 296 {addsi_1_zext}
     (expr_list:REG_ARGS_SIZE (const_int 0 [0])
        (nil)))
(insn 155 27 139 2 (set (reg:DI 7 sp)
        (reg:DI 6 bp)) "x.ii":14:17 discrim 1 -1
     (nil))

without updating stack frame info.

gcc/

PR rtl-optimization/118266
* ree.cc (add_removable_extension): Skip extension on fixed
register.

gcc/testsuite/

PR rtl-optimization/118266
* gcc.target/i386/pr118266.c: New test.

Signed-off-by: H.J. Lu <hjl.tools@gmail.com>
gcc/ree.cc
gcc/testsuite/gcc.target/i386/pr118266.c [new file with mode: 0644]

index a44e8e5625b66e61b1993093a9fda6b5df485508..bcce9da44af0fa32cbdfe9850193d358bccdd096 100644 (file)
@@ -1113,6 +1113,18 @@ add_removable_extension (const_rtx expr, rtx_insn *insn,
       struct df_link *defs, *def;
       ext_cand *cand;
 
+      if (fixed_regs[REGNO (reg)])
+       {
+         if (dump_file)
+           {
+             fprintf (dump_file, "Cannot eliminate extension:\n");
+             print_rtl_single (dump_file, insn);
+             fprintf (dump_file, " because extension on fixed register"
+                                 " isn't supported.\n");
+           }
+         return;
+       }
+
       /* Zero-extension of an undefined value is partly defined (it's
         completely undefined for sign-extension, though).  So if there exists
         a path from the entry to this zero-extension that leaves this register
diff --git a/gcc/testsuite/gcc.target/i386/pr118266.c b/gcc/testsuite/gcc.target/i386/pr118266.c
new file mode 100644 (file)
index 0000000..4c83cd1
--- /dev/null
@@ -0,0 +1,27 @@
+/* { dg-do compile { target { ! ia32 } } } */
+/* { dg-require-effective-target maybe_x32 } */
+/* { dg-require-effective-target fopenacc } */
+/* { dg-options "-O2 -mx32 -fopenacc" } */
+
+typedef struct {
+  int a;
+  int b;
+  int c;
+} mystruct;
+int main_j;
+int
+main()
+{
+  mystruct *m = (mystruct *)__builtin_malloc (2*sizeof (mystruct)), *mref = m;
+#pragma acc enter data copyin(m[1])
+  for (int i; i < 9; i++) {
+#pragma acc parallel
+    for (; main_j;)
+      ;
+#pragma acc parallel loop copy(mref->b, m->c)
+    for (main_j = 0; main_j < 4; main_j++)
+      ;
+  }
+#pragma acc data copyout(m[ : 1])
+  __builtin_free(m);
+}