Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Too much spill code generated after loop unrolling #1315

Closed
isanbard opened this issue Oct 12, 2006 · 5 comments
Closed

Too much spill code generated after loop unrolling #1315

isanbard opened this issue Oct 12, 2006 · 5 comments
Assignees
Labels
bugzilla Issues migrated from bugzilla code-quality llvm:codegen

Comments

@isanbard
Copy link
Contributor

Bugzilla Link 943
Resolution FIXED
Resolved on Mar 06, 2010 14:00
Version trunk
OS All
Attachments Extracted function

Extended Description

This code:

int value(uint64 b1, uint64 b2)
{
int i, j, k;
int value = 0;

for (k = 0; k < 2; k++)
for (i = 0; i < 6; i++)
for (j = 0; j < 2; j++)
if ((b2 & 0xf << (j + i * 6)) == 0xf << (j + i * 6))
value += 1000;

return value;
}

generates too many unnecessary spills/reloads when rerun through the optimizer (at -O2). See "***"
below:

LBB1_1: #bb17.preheader
movl $15, %eax
*** movb 39(%esp), %cl
movl %eax, %edx
shll %cl, %edx
*** movb 39(%esp), %cl
incb %cl
shll %cl, %eax
movl %edx, %ecx

The result is that the loop will run slower than if optimizations were turned on only once.

@isanbard
Copy link
Contributor Author

assigned to @lattner

@lattner
Copy link
Collaborator

lattner commented Oct 12, 2006

Taking a look.

@lattner
Copy link
Collaborator

lattner commented Oct 12, 2006

Fixed. Patch here:
http://lists.cs.uiuc.edu/pipermail/llvm-commits/Week-of-Mon-20061009/038511.html

The diff of produced code:

--- t.s 2006-10-11 18:57:23.000000000 -0700
+++ t2.s 2006-10-11 19:29:35.000000000 -0700
@@ -22,7 +22,6 @@
movb 39(%esp), %cl
movl %eax, %edx
shll %cl, %edx

  •   movb 39(%esp), %cl
      incb %cl
      shll %cl, %eax
      movl %edx, %ecx
    

@@ -73,7 +72,6 @@
movb 15(%esp), %cl
movl %esi, %eax
shll %cl, %eax

  •   movb 15(%esp), %cl
      incb %cl
      shll %cl, %esi
      movl %eax, %ecx
    

-Chris

@isanbard
Copy link
Contributor Author

Rockin'!

@isanbard
Copy link
Contributor Author

This sped up the fourinarow testpoiont on x86. It now has a smaller gap (~.5s instead of ~.9s) between
the times.

@llvmbot llvmbot transferred this issue from llvm/llvm-bugzilla-archive Dec 3, 2021
This issue was closed.
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
bugzilla Issues migrated from bugzilla code-quality llvm:codegen
Projects
None yet
Development

No branches or pull requests

2 participants