public inbox for gcc-bugs@sourceware.org
help / color / mirror / Atom feed
From: "jakub at gcc dot gnu.org" <gcc-bugzilla@gcc.gnu.org>
To: gcc-bugs@gcc.gnu.org
Subject: [Bug target/105930] [12/13 Regression] Excessive stack spill generation on 32-bit x86
Date: Tue, 14 Jun 2022 09:42:42 +0000	[thread overview]
Message-ID: <bug-105930-4-meIJjJj90M@http.gcc.gnu.org/bugzilla/> (raw)
In-Reply-To: <bug-105930-4@http.gcc.gnu.org/bugzilla/>

https://gcc.gnu.org/bugzilla/show_bug.cgi?id=105930

Jakub Jelinek <jakub at gcc dot gnu.org> changed:

           What    |Removed                     |Added
----------------------------------------------------------------------------
           Keywords|needs-bisection             |

--- Comment #17 from Jakub Jelinek <jakub at gcc dot gnu.org> ---
So, I've tried:
--- gcc/config/i386/i386.md.jj  2022-06-13 10:53:26.739290704 +0200
+++ gcc/config/i386/i386.md     2022-06-14 11:09:24.467024047 +0200
@@ -13734,14 +13734,13 @@
 ;; shift instructions and a scratch register.

 (define_insn_and_split "ix86_rotl<dwi>3_doubleword"
- [(set (match_operand:<DWI> 0 "register_operand" "=r")
-       (rotate:<DWI> (match_operand:<DWI> 1 "register_operand" "0")
-                    (match_operand:QI 2 "<shift_immediate_operand>" "<S>")))
-  (clobber (reg:CC FLAGS_REG))
-  (clobber (match_scratch:DWIH 3 "=&r"))]
- ""
+ [(set (match_operand:<DWI> 0 "register_operand")
+       (rotate:<DWI> (match_operand:<DWI> 1 "register_operand")
+                    (match_operand:QI 2 "<shift_immediate_operand>")))
+  (clobber (reg:CC FLAGS_REG))]
+ "ix86_pre_reload_split ()"
  "#"
- "reload_completed"
+ "&& 1"
  [(set (match_dup 3) (match_dup 4))
   (parallel
    [(set (match_dup 4)
@@ -13764,6 +13763,7 @@
                                                       (match_dup 6)))) 0)))
     (clobber (reg:CC FLAGS_REG))])]
 {
+  operands[3] = gen_reg_rtx (<MODE>mode);
   operands[6] = GEN_INT (GET_MODE_BITSIZE (<MODE>mode) - 1);
   operands[7] = GEN_INT (GET_MODE_BITSIZE (<MODE>mode));

@@ -13771,14 +13771,13 @@
 })

 (define_insn_and_split "ix86_rotr<dwi>3_doubleword"
- [(set (match_operand:<DWI> 0 "register_operand" "=r")
-       (rotatert:<DWI> (match_operand:<DWI> 1 "register_operand" "0")
-                      (match_operand:QI 2 "<shift_immediate_operand>" "<S>")))
-  (clobber (reg:CC FLAGS_REG))
-  (clobber (match_scratch:DWIH 3 "=&r"))]
- ""
+ [(set (match_operand:<DWI> 0 "register_operand")
+       (rotatert:<DWI> (match_operand:<DWI> 1 "register_operand")
+                      (match_operand:QI 2 "<shift_immediate_operand>")))
+  (clobber (reg:CC FLAGS_REG))]
+ "ix86_pre_reload_split ()"
  "#"
- "reload_completed"
+ "&& 1"
  [(set (match_dup 3) (match_dup 4))
   (parallel
    [(set (match_dup 4)
@@ -13801,6 +13800,7 @@
                                                     (match_dup 6)))) 0)))
     (clobber (reg:CC FLAGS_REG))])]
 {
+  operands[3] = gen_reg_rtx (<MODE>mode);
   operands[6] = GEN_INT (GET_MODE_BITSIZE (<MODE>mode) - 1);
   operands[7] = GEN_INT (GET_MODE_BITSIZE (<MODE>mode));


On the #c0 test with -O2 -m32 -mno-mmx -mno-sse it makes some difference, but
not as much as one would hope for:
Numbers from gcc 11.3.1 20220614, 11.3.1 20220614 with the patch, 13.0.0
20220610, 13.0.0 20220614 with the patch:
sub on %esp    428      2556      2620      2556
fn size in B 21657     23186     28413     23534
.s lines      6199      3942      7260      4198
So, trunk patched with the above patch results in significantly fewer
instructions, but larger (more of them use 32-bit immediates, mostly in form of
whatever(%esp) memory source operand).
And the stack usage is high.

I think the patch is still a good idea, it gives the RA more options, but we
should investigate why it consumes so much more stack and results in larger
code.

  parent reply	other threads:[~2022-06-14  9:42 UTC|newest]

Thread overview: 30+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2022-06-11 20:51 [Bug c/105930] New: " torvalds@linux-foundation.org
2022-06-11 23:20 ` [Bug target/105930] " torvalds@linux-foundation.org
2022-06-11 23:54 ` [Bug target/105930] [12/13 Regression] " pinskia at gcc dot gnu.org
2022-06-11 23:59 ` pinskia at gcc dot gnu.org
2022-06-12  0:20 ` torvalds@linux-foundation.org
2022-06-12  0:20 ` torvalds@linux-foundation.org
2022-06-12  0:27 ` torvalds@linux-foundation.org
2022-06-12  2:26 ` sneves at dei dot uc.pt
2022-06-12  6:28 ` roger at nextmovesoftware dot com
2022-06-12 16:18 ` torvalds@linux-foundation.org
2022-06-12 16:35 ` torvalds@linux-foundation.org
2022-06-12 17:30 ` torvalds@linux-foundation.org
2022-06-13  9:29 ` jakub at gcc dot gnu.org
2022-06-13 17:39 ` torvalds@linux-foundation.org
2022-06-13 18:23 ` sneves at dei dot uc.pt
2022-06-13 18:31 ` torvalds@linux-foundation.org
2022-06-14  7:57 ` rguenth at gcc dot gnu.org
2022-06-14  8:50 ` jakub at gcc dot gnu.org
2022-06-14  9:42 ` jakub at gcc dot gnu.org [this message]
2022-06-14  9:50 ` jakub at gcc dot gnu.org
2022-06-16 10:06 ` arnd at linaro dot org
2022-06-24  6:17 ` cvs-commit at gcc dot gnu.org
2022-06-24 16:45 ` torvalds@linux-foundation.org
2022-06-24 16:55 ` jakub at gcc dot gnu.org
2022-06-24 17:06 ` torvalds@linux-foundation.org
2022-06-24 17:19 ` torvalds@linux-foundation.org
2022-06-24 17:33 ` jakub at gcc dot gnu.org
2022-06-30 10:03 ` cvs-commit at gcc dot gnu.org
2022-07-10  8:01 ` roger at nextmovesoftware dot com
2022-07-10 16:41 ` torvalds@linux-foundation.org

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox

  Avoid top-posting and favor interleaved quoting:
  https://en.wikipedia.org/wiki/Posting_style#Interleaved_style

* Reply using the --to, --cc, and --in-reply-to
  switches of git-send-email(1):

  git send-email \
    --in-reply-to=bug-105930-4-meIJjJj90M@http.gcc.gnu.org/bugzilla/ \
    --to=gcc-bugzilla@gcc.gnu.org \
    --cc=gcc-bugs@gcc.gnu.org \
    /path/to/YOUR_REPLY

  https://kernel.org/pub/software/scm/git/docs/git-send-email.html

* If your mail client supports setting the In-Reply-To header
  via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line before the message body.
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).