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

sdisel lowers this to really bad code #1297

Closed
lattner opened this issue Sep 27, 2006 · 3 comments
Closed

sdisel lowers this to really bad code #1297

lattner opened this issue Sep 27, 2006 · 3 comments
Assignees
Labels
bugzilla Issues migrated from bugzilla code-quality llvm:codegen

Comments

@lattner
Copy link
Collaborator

lattner commented Sep 27, 2006

Bugzilla Link 925
Resolution FIXED
Resolved on Feb 22, 2010 12:50
Version 1.8
OS All

Extended Description

In the stupid contrived testcase below, sdisel is breaking every critical edge from the switch to the
blahaha block, creating a ton of duplicated code and making switch lowering uglier than it should be.

void foo(int C) {
const char *s = "blah";

switch (C) {
case 1 ... 10:
s = "bonk";
goto blahaha;
}
s = "bork";
if (C & 123) s = "perfwap";

blahaha:
printf(s);
printf(s);
printf(s);
printf(s);
printf(s);
printf(s);
printf(s);
printf(s);
printf(s);
printf(s);
printf(s);
printf(s);
printf(s);
}

We end up with code like this:

LBB1_1: #entry.blahaha_crit_edge9
movl $_str1, %esi
jmp LBB1_14 #blahaha
LBB1_2: #entry.blahaha_crit_edge8
movl $_str1, %esi
jmp LBB1_14 #blahaha
LBB1_3: #entry.blahaha_crit_edge7
movl $_str1, %esi
jmp LBB1_14 #blahaha
LBB1_4: #entry.blahaha_crit_edge6
movl $_str1, %esi
jmp LBB1_14 #blahaha
LBB1_5: #entry.blahaha_crit_edge5
movl $_str1, %esi
jmp LBB1_14 #blahaha
...

When splitting critical edges into a block, SDIsel should factor all edges from a particular BB into a
single split block.

-Chris

@lattner
Copy link
Collaborator Author

lattner commented Sep 27, 2006

assigned to @lattner

@lattner
Copy link
Collaborator Author

lattner commented Oct 28, 2006

I have a patch for this, I'll commit it tomorrow.

@lattner
Copy link
Collaborator Author

lattner commented Oct 28, 2006

Fixed. Testcase here: CodeGen/Generic/switch-crit-edge-constant.ll

Patch here:
http://lists.cs.uiuc.edu/pipermail/llvm-commits/Week-of-Mon-20061023/039183.html

-Chris

@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

1 participant