Cute example from Chris Lattner.

llvm-svn: 31696
This commit is contained in:
Nick Lewycky 2006-11-13 00:23:28 +00:00
parent ad75361d42
commit 0df2ada9d4
1 changed files with 40 additions and 0 deletions

View File

@ -360,3 +360,43 @@ are turned into memcpy calls at the source level. We need a "loops to memcpy"
pass.
//===---------------------------------------------------------------------===//
-predsimplify should transform this:
void bad(unsigned x)
{
if (x > 4)
bar(12);
else if (x > 3)
bar(523);
else if (x > 2)
bar(36);
else if (x > 1)
bar(65);
else if (x > 0)
bar(45);
else
bar(367);
}
into:
void good(unsigned x)
{
if (x == 4)
bar(523);
else if (x == 3)
bar(36);
else if (x == 2)
bar(65);
else if (x == 1)
bar(45);
else if (x == 0)
bar(367);
else
bar(12);
}
to enable further optimizations.
//===---------------------------------------------------------------------===//