]> git.ipfire.org Git - thirdparty/gcc.git/commitdiff
LoongArch: Change the value of branch_cost from 2 to 6.
authorLulu Cheng <chenglulu@loongson.cn>
Wed, 13 Sep 2023 03:01:34 +0000 (11:01 +0800)
committerLulu Cheng <chenglulu@loongson.cn>
Thu, 14 Sep 2023 06:59:26 +0000 (14:59 +0800)
gcc/ChangeLog:

* config/loongarch/loongarch-def.c: Modify the default value of
branch_cost.

gcc/testsuite/ChangeLog:

* gcc.target/loongarch/cmov_ii.c: New test.

gcc/config/loongarch/loongarch-def.c
gcc/testsuite/gcc.target/loongarch/cmov_ii.c [new file with mode: 0644]

index e744ee01d6d76422fdc0a8ff54ecb04a2664cca2..430ef8b2d9571af30ee159383ce065a34eb17916 100644 (file)
@@ -85,7 +85,7 @@ loongarch_cpu_align[N_TUNE_TYPES] = {
     .int_mult_di       = COSTS_N_INSNS (1),    \
     .int_div_si                = COSTS_N_INSNS (4),    \
     .int_div_di                = COSTS_N_INSNS (6),    \
-    .branch_cost       = 2,                    \
+    .branch_cost       = 6,                    \
     .memory_latency    = 4
 
 /* The following properties cannot be looked up directly using "cpucfg".
@@ -118,7 +118,7 @@ loongarch_rtx_cost_optimize_size = {
     .int_mult_di      = 4,
     .int_div_si              = 4,
     .int_div_di              = 4,
-    .branch_cost      = 2,
+    .branch_cost      = 6,
     .memory_latency   = 4,
 };
 
diff --git a/gcc/testsuite/gcc.target/loongarch/cmov_ii.c b/gcc/testsuite/gcc.target/loongarch/cmov_ii.c
new file mode 100644 (file)
index 0000000..21b468e
--- /dev/null
@@ -0,0 +1,15 @@
+/* { dg-do compile } */
+/* { dg-options "-O2" } */
+/* { dg-final { scan-assembler "test:.*xor.*maskeqz.*masknez.*or.*" } } */
+
+extern void foo_ii (int *, int *, int *, int *);
+
+int
+test (void)
+{
+  int a, b;
+  int c, d, out;
+  foo_ii (&a, &b, &c, &d);
+  out = a == b ? c : d;
+  return out;
+}