Cute example from Chris Lattner.
authorNick Lewycky <nicholas@mxc.ca>
Mon, 13 Nov 2006 00:23:28 +0000 (00:23 +0000)
committerNick Lewycky <nicholas@mxc.ca>
Mon, 13 Nov 2006 00:23:28 +0000 (00:23 +0000)
git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@31696 91177308-0d34-0410-b5e6-96231b3b80d8

lib/Target/README.txt

index 3e5dbf6172dc749261ed075d15e1a2852907c280..18cd4f66f263a583e08e6a1a800f5332f77cf54c 100644 (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.
+
+//===---------------------------------------------------------------------===//