]> granicus.if.org Git - clang/commit
Implement rdar://7530813 - collapse multiple GEP instructions in IRgen
authorChris Lattner <sabre@nondot.org>
Sat, 26 Jun 2010 23:03:20 +0000 (23:03 +0000)
committerChris Lattner <sabre@nondot.org>
Sat, 26 Jun 2010 23:03:20 +0000 (23:03 +0000)
commit9269d5c05bebe634dc9f08a37b192c6977fbc067
treebef7c711473bfa6c4d6ac2e7e8d656fcafbd8f26
parent1cba3eab014efdf352da6b8ea91a1a120e81112b
Implement rdar://7530813 - collapse multiple GEP instructions in IRgen

This avoids generating two gep's for common array operations.  Before
we would generate something like:

  %tmp = load i32* %X.addr                        ; <i32> [#uses=1]
  %arraydecay = getelementptr inbounds [100 x i32]* %A, i32 0, i32 0 ; <i32*> [#uses=1]
  %arrayidx = getelementptr inbounds i32* %arraydecay, i32 %tmp ; <i32*> [#uses=1]
  %tmp1 = load i32* %arrayidx                     ; <i32> [#uses=1]

Now we generate:

  %tmp = load i32* %X.addr                        ; <i32> [#uses=1]
  %arrayidx = getelementptr inbounds [100 x i32]* %A, i32 0, i32 %tmp ; <i32*> [#uses=1]
  %tmp1 = load i32* %arrayidx                     ; <i32> [#uses=1]

Less IR is better at -O0.

git-svn-id: https://llvm.org/svn/llvm-project/cfe/trunk@106966 91177308-0d34-0410-b5e6-96231b3b80d8
lib/CodeGen/CGExpr.cpp
test/CodeGen/address-space-field2.c
test/CodeGen/address-space-field3.c
test/CodeGen/address-space-field4.c
test/CodeGen/exprs.c