[ARM] Restrict MAX_CONDITIONAL_EXECUTE when -mrestrict-it is in place
authorKyrylo Tkachov <kyrylo.tkachov@arm.com>
Thu, 11 Jun 2015 10:01:11 +0000 (10:01 +0000)
committerKyrylo Tkachov <ktkachov@gcc.gnu.org>
Thu, 11 Jun 2015 10:01:11 +0000 (10:01 +0000)
* config/arm/arm.c (arm_option_params_internal): When optimising
for speed set max_insns_skipped when arm_restrict_it.

* gcc.target/arm/short-it-ifcvt-1.c: New test.
* gcc.target/arm/short-it-ifcvt-2.c: Likewise.

From-SVN: r224367

gcc/ChangeLog
gcc/config/arm/arm.c
gcc/testsuite/ChangeLog
gcc/testsuite/gcc.target/arm/short-it-ifcvt-1.c [new file with mode: 0644]
gcc/testsuite/gcc.target/arm/short-it-ifcvt-2.c [new file with mode: 0644]

index f89cbb6c9d25c291138909ec931e48b043e9e827..409171ca2f4ecbf1eafdfeb40e6ad00bdacdc2ae 100644 (file)
@@ -1,3 +1,8 @@
+2015-06-11  Kyrylo Tkachov  <kyrylo.tkachov@arm.com>
+
+       * config/arm/arm.c (arm_option_params_internal): When optimising
+       for speed set max_insns_skipped when arm_restrict_it.
+
 2015-06-11  Christian Bruel  <christian.bruel@st.com>
 
        PR target/52144
index 353c2c599d90e167dd072c689aa39c1678604fdc..5744f955f20670f06c39b11a7857e74985ced8ac 100644 (file)
@@ -2788,7 +2788,10 @@ arm_option_params_internal (struct gcc_options *opts)
         max_insns_skipped = opts->x_arm_restrict_it ? 1 : 4;
     }
   else
-    max_insns_skipped = current_tune->max_insns_skipped;
+    /* When -mrestrict-it is in use tone down the if-conversion.  */
+    max_insns_skipped
+      = (TARGET_THUMB2_P (opts->x_target_flags) && opts->x_arm_restrict_it)
+         ? 1 : current_tune->max_insns_skipped;
 }
 
 /* Options after initial target override.  */
index 0accb7c3d71e3e9f008ad2e8434958f29feb40a2..cf2c0d6cc06f057e31dda716ab6c3bcf4ece2c4c 100644 (file)
@@ -1,3 +1,8 @@
+2015-06-11  Kyrylo Tkachov  <kyrylo.tkachov@arm.com>
+
+       * gcc.target/arm/short-it-ifcvt-1.c: New test.
+       * gcc.target/arm/short-it-ifcvt-2.c: Likewise.
+
 2015-06-11  Christian Bruel  <christian.bruel@st.com>
 
        PR target/52144
diff --git a/gcc/testsuite/gcc.target/arm/short-it-ifcvt-1.c b/gcc/testsuite/gcc.target/arm/short-it-ifcvt-1.c
new file mode 100644 (file)
index 0000000..f3d29b7
--- /dev/null
@@ -0,0 +1,23 @@
+/* Test that ifcvt is not being too aggressive when -mrestrict-it.  */
+/* { dg-do compile } */
+/* { dg-options "-O2 -mrestrict-it" } */
+/* { dg-require-effective-target arm_thumb2_ok } */
+
+int
+f1(int x, int y, int z)
+{
+  if (x > 100)
+    {
+      x++;
+      z = -z;
+    }
+  else
+    {
+      x = -x;
+      y = -y;
+      z = 1;
+    }
+  return x + y + z;
+}
+
+/* { dg-final { scan-assembler "b(gt|le)" } } */
diff --git a/gcc/testsuite/gcc.target/arm/short-it-ifcvt-2.c b/gcc/testsuite/gcc.target/arm/short-it-ifcvt-2.c
new file mode 100644 (file)
index 0000000..9ac8153
--- /dev/null
@@ -0,0 +1,21 @@
+/* Test that ifcvt is not being too aggressive when -mrestrict-it.  */
+/* { dg-do compile } */
+/* { dg-options "-O2 -mrestrict-it" } */
+/* { dg-require-effective-target arm_thumb2_ok } */
+
+int
+f1(int x, int y, int z)
+{
+  if (x > 100)
+    {
+      x++;
+      z = -z;
+    }
+  else
+    {
+      x = -x;
+      y = -y;
+    }
+  return x + y + z;
+}
+/* { dg-final { scan-assembler "b(gt|le)" } } */