]> git.ipfire.org Git - thirdparty/gcc.git/commitdiff
LoongArch: Enable '-free' starting at -O2.
authorLulu Cheng <chenglulu@loongson.cn>
Mon, 28 Aug 2023 03:30:21 +0000 (11:30 +0800)
committerLulu Cheng <chenglulu@loongson.cn>
Tue, 29 Aug 2023 00:58:04 +0000 (08:58 +0800)
gcc/ChangeLog:

* common/config/loongarch/loongarch-common.cc:
Enable '-free' on O2 and above.
* doc/invoke.texi: Modify the description information
of the '-free' compilation option and add the LoongArch
description.

gcc/testsuite/ChangeLog:

* gcc.target/loongarch/sign-extend.c: New test.

gcc/common/config/loongarch/loongarch-common.cc
gcc/doc/invoke.texi
gcc/testsuite/gcc.target/loongarch/sign-extend.c [new file with mode: 0644]

index fce32fa3f8d3085b4b87bec155ed5115d04e4da3..c5ed37d27a64b375d056a6e58594fd212d0ff383 100644 (file)
@@ -35,6 +35,7 @@ static const struct default_options loongarch_option_optimization_table[] =
 {
   { OPT_LEVELS_ALL, OPT_fasynchronous_unwind_tables, NULL, 1 },
   { OPT_LEVELS_1_PLUS, OPT_fsection_anchors, NULL, 1 },
+  { OPT_LEVELS_2_PLUS, OPT_free, NULL, 1 },
   { OPT_LEVELS_NONE, 0, NULL, 0 }
 };
 
index a32dabf0405fbf3b74917c41ed5d3dba7b640f7d..16aa92b5e861d4e91bace84c50ac30f4d7b87fcd 100644 (file)
@@ -12639,8 +12639,8 @@ Attempt to remove redundant extension instructions.  This is especially
 helpful for the x86-64 architecture, which implicitly zero-extends in 64-bit
 registers after writing to their lower 32-bit half.
 
-Enabled for Alpha, AArch64, PowerPC, RISC-V, SPARC, h83000 and x86 at levels
-@option{-O2}, @option{-O3}, @option{-Os}.
+Enabled for Alpha, AArch64, LoongArch, PowerPC, RISC-V, SPARC, h83000 and x86 at
+levels @option{-O2}, @option{-O3}, @option{-Os}.
 
 @opindex fno-lifetime-dse
 @opindex flifetime-dse
diff --git a/gcc/testsuite/gcc.target/loongarch/sign-extend.c b/gcc/testsuite/gcc.target/loongarch/sign-extend.c
new file mode 100644 (file)
index 0000000..3f339d0
--- /dev/null
@@ -0,0 +1,25 @@
+/* { dg-do compile } */
+/* { dg-options "-mabi=lp64d -O2" } */
+/* { dg-final { scan-assembler-times "slli.w" 1 } } */
+
+extern int PL_savestack_ix;
+extern int PL_regsize;
+extern int PL_savestack_max;
+void Perl_savestack_grow_cnt (int need);
+extern void Perl_croak (char *);
+
+int
+S_regcppush(int parenfloor)
+{
+  int retval = PL_savestack_ix;
+  int paren_elems_to_push = (PL_regsize - parenfloor) * 4;
+  int p;
+
+  if (paren_elems_to_push < 0)
+    Perl_croak ("panic: paren_elems_to_push < 0");
+
+  if (PL_savestack_ix + (paren_elems_to_push + 6) > PL_savestack_max)
+    Perl_savestack_grow_cnt (paren_elems_to_push + 6);
+
+  return retval;
+}