From: Benjamin Kramer Date: Thu, 6 Jan 2011 17:35:50 +0000 (+0000) Subject: Add a note from llvmdev, this time with more info. X-Git-Url: http://demsky.eecs.uci.edu/git/?a=commitdiff_plain;h=fa366800766d71e00ac1cc3adf623bef06800d0d;p=oota-llvm.git Add a note from llvmdev, this time with more info. git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@122966 91177308-0d34-0410-b5e6-96231b3b80d8 --- diff --git a/lib/Target/README.txt b/lib/Target/README.txt index 29bd10949e5..bedc893fbb1 100644 --- a/lib/Target/README.txt +++ b/lib/Target/README.txt @@ -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. + +//===---------------------------------------------------------------------===//