LLVM Bugzilla is read-only and represents the historical archive of all LLVM issues filled before November 26, 2021. Use github to submit LLVM bugs

Bug 26325 - [x86] Consider mov-to-push also at -O2?
Summary: [x86] Consider mov-to-push also at -O2?
Status: RESOLVED FIXED
Alias: None
Product: libraries
Classification: Unclassified
Component: Backend: X86 (show other bugs)
Version: trunk
Hardware: PC Linux
: P normal
Assignee: Unassigned LLVM Bugs
URL:
Keywords:
Depends on:
Blocks: 26299
  Show dependency tree
 
Reported: 2016-01-26 15:10 PST by Hans Wennborg
Modified: 2016-11-03 19:23 PDT (History)
5 users (show)

See Also:
Fixed By Commit(s):


Attachments

Note You need to log in before you can comment on or make changes to this bug.
Description Hans Wennborg 2016-01-26 15:10:39 PST
On Windows, most of Chromium builds with /O1 /Os (optimize for size), but some of it builds with /O2 /Ot (optimize for speed).

For this code:

  void f(int x, int y);
  void g(int x) {
    f(x, 1);
  }

clang -target i686-pc-win32 -Os generates:

00000000 <?g@@YAXH@Z>:
   0:	6a 01                	push   $0x1
   2:	ff 74 24 08          	pushl  0x8(%esp)
   6:	e8 00 00 00 00       	call   b <?g@@YAXH@Z+0xb>
   b:	83 c4 08             	add    $0x8,%esp
   e:	c3                      ret

but with -O2 it generates:

00000000 <?g@@YAXH@Z>:
   0:	83 ec 08             	sub    $0x8,%esp
   3:	8b 44 24 0c          	mov    0xc(%esp),%eax
   7:	89 04 24             	mov    %eax,(%esp)
   a:	c7 44 24 04 01 00 00 	movl   $0x1,0x4(%esp)
  11:	00 
  12:	e8 00 00 00 00       	call   17 <?g@@YAXH@Z+0x17>
  17:	83 c4 08             	add    $0x8,%esp
  1a:	c3                      ret


Is the -O2 version actually faster enough to justify the size increase here?
Comment 1 Michael Kuperstein 2016-01-27 00:03:34 PST
I tend to agree.

I originally wanted it for all opt levels, but there was some pushback because of potential performance concerns. And since my main concern was -Os, I just never got to benchmarking it for -O2.

Adding Dave, who's probably a more appropriate contact for this than I am right now.
Comment 2 Hans Wennborg 2016-03-31 12:34:32 PDT
r264966