public inbox for gcc-patches@gcc.gnu.org
 help / color / mirror / Atom feed
* [PATCH, i386]: Fix PR90552, attribute((optimize(3))) not overriding -Os
@ 2019-05-23 19:52 Uros Bizjak
  0 siblings, 0 replies; only message in thread
From: Uros Bizjak @ 2019-05-23 19:52 UTC (permalink / raw)
  To: gcc-patches

[-- Attachment #1: Type: text/plain, Size: 644 bytes --]

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.

[-- Attachment #2: p.diff.txt --]
[-- Type: text/plain, Size: 995 bytes --]

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" } } */

^ permalink raw reply	[flat|nested] only message in thread

only message in thread, other threads:[~2019-05-23 19:52 UTC | newest]

Thread overview: (only message) (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2019-05-23 19:52 [PATCH, i386]: Fix PR90552, attribute((optimize(3))) not overriding -Os Uros Bizjak

This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for read-only IMAP folder(s) and NNTP newsgroup(s).