Add a note from llvmdev, this time with more info.
authorBenjamin Kramer <benny.kra@googlemail.com>
Thu, 6 Jan 2011 17:35:50 +0000 (17:35 +0000)
committerBenjamin Kramer <benny.kra@googlemail.com>
Thu, 6 Jan 2011 17:35:50 +0000 (17:35 +0000)
git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@122966 91177308-0d34-0410-b5e6-96231b3b80d8

lib/Target/README.txt

index 29bd10949e58a5a3b1b836653b26fcb4a4753ba4..bedc893fbb10cb4f3d02f479361af38baf24172b 100644 (file)
@@ -2047,3 +2047,29 @@ entry:
 }
 //===---------------------------------------------------------------------===//
 
+clang -O3 currently compiles this code
+
+int g(unsigned int a) {
+  unsigned int c[100];
+  c[10] = a;
+  c[11] = a;
+  unsigned int b = c[10] + c[11];
+  if(b > a*2) a = 4;
+  else a = 8;
+  return a + 7;
+}
+
+into
+
+define i32 @g(i32 a) nounwind readnone {
+  %add = shl i32 %a, 1
+  %mul = shl i32 %a, 1
+  %cmp = icmp ugt i32 %add, %mul
+  %a.addr.0 = select i1 %cmp, i32 11, i32 15
+  ret i32 %a.addr.0
+}
+
+The icmp should fold to false. This CSE opportunity is only available
+after GVN and InstCombine have run.
+
+//===---------------------------------------------------------------------===//