diff mbox series

[i386] : Fix PR90552, attribute((optimize(3))) not overriding -Os

Message ID CAFULd4YuqsQUur5gv4MnPQQ-LcsvAwahOXYHUiz7qSZ8Dsgxow@mail.gmail.com
State New
Headers show
Series [i386] : Fix PR90552, attribute((optimize(3))) not overriding -Os | expand

Commit Message

Uros Bizjak May 23, 2019, 7:51 p.m. UTC
Hello!

As explained in the PR, ix86_cost switches to ix86_size_cost when -Os
is used. This defeats the intention of speed variable to
ix86_rtx_costs, which is set according to the optimization level at
the point of insn insertion.

2019-05-23  Uroš Bizjak  <ubizjak@gmail.com>

    PR target/90552
    * config/i386/i386.c (gen_rtx_cost):
    Use ix86_tune_cost instead of ix86_cost.

testsuite/ChangeLog:

2019-05-23  Uroš Bizjak  <ubizjak@gmail.com>

    PR target/90552
    * gcc.target/i386/pr90552.c: New test.

Bootstrapped and regression tested on x86_64-linux-gnu {,-m32}.

Committed to mainline SVN.

Uros.
diff mbox series

Patch

Index: config/i386/i386.c
===================================================================
--- config/i386/i386.c	(revision 271562)
+++ config/i386/i386.c	(working copy)
@@ -19124,7 +19124,8 @@  ix86_rtx_costs (rtx x, machine_mode mode, int oute
   rtx mask;
   enum rtx_code code = GET_CODE (x);
   enum rtx_code outer_code = (enum rtx_code) outer_code_i;
-  const struct processor_costs *cost = speed ? ix86_cost : &ix86_size_cost;
+  const struct processor_costs *cost
+    = speed ? ix86_tune_cost : &ix86_size_cost;
   int src_cost;
 
   switch (code)
Index: testsuite/gcc.target/i386/pr90552.c
===================================================================
--- testsuite/gcc.target/i386/pr90552.c	(nonexistent)
+++ testsuite/gcc.target/i386/pr90552.c	(working copy)
@@ -0,0 +1,11 @@ 
+/* PR target/90552 *
+/* { dg-do compile } */
+/* { dg-options "-Os" } */
+
+__attribute__((optimize(2)))
+int foo (int x)
+{
+  return x / 3;
+}
+
+/* { dg-final { scan-assembler-not "idiv" } } */