[llvm-commits] [LLVM, loop-unswitch, bugfix for #11429] Wrong behaviour for switches.
Stepan Dyatkovskiy
stpworld at narod.ru
Thu Nov 24 23:57:14 PST 2011
Hi all. Please find the patch in attachment for review. Regression tests
are attached in separated patch.
Short tests description:
2011-11-18-SimpleSwitch.ll
Check simple that simple switch will totally unswitched:
for (...)
switch(c) {
case 0: inc(); break;
case 1: dec(); break;
default: goto loop_exit;
}
loop_exit:
...
Result of processing should be 2 additional loops for c == 0 and for c == 1.
2011-11-18-TwoSwitches.ll
Check that second switch will unswitched too. Check that switches will
not unswitched again in new loop:
Initially we have the next:
for (...) {
switch(c) {
case 0: inc(); break;
}
switch(d) {
case 0: inc(); break;
}
}
After optimization we should got 3 additional loops: when (c == 0 && d
== 0), when (c == 0 && d != 0) and when (c != 0 && d == 0). Original
loop will activated for (c != 0 && d != 0):
if (c == 0 && d == 0) {
for (...) ... // All is clear here. Two "switch(0)" instructions.
} else if (c == 0 && d != 0) {
for (...) {
switch (0) { // c == 0
case 0: inc(); break;
}
switch (d) {
case 0: goto unreachable; // CHECK: That it will not unswitched
// again, since it looks "trivial",
// see LoopUnswitch::IsTrivialUnswitchCondition
}
}
} else if (c != 0 && d == 0) {
// the same...
...
} else { // if (c != 0 && d != 0)
// Original totally unswitched loop:
switch (c) {
case 0: goto unreachable;
}
switch (d) {
case 0: goto unreachable;
}
}
Stepan.
-------------- next part --------------
A non-text attachment was scrubbed...
Name: loop-unswitch-unswitchvals.patch
Type: text/x-patch
Size: 6510 bytes
Desc: not available
URL: <http://lists.llvm.org/pipermail/llvm-commits/attachments/20111125/4a6bbad3/attachment.bin>
-------------- next part --------------
A non-text attachment was scrubbed...
Name: loop-unswitch-unswitchvals-regtests.patch
Type: text/x-patch
Size: 9724 bytes
Desc: not available
URL: <http://lists.llvm.org/pipermail/llvm-commits/attachments/20111125/4a6bbad3/attachment-0001.bin>
More information about the llvm-commits
mailing list