Instcombine should eliminate the two bitcasts in this example: define i8* @test(i8* %v) { %A = alloca [4 x i8*], align 16 ; <[4 x i8*]*> [#uses=3] %B = getelementptr [4 x i8*]* %A, i32 0, i32 0 ; <i8**> [#uses=1] store i8* null, i8** %B %C = bitcast [4 x i8*]* %A to { [16 x i8] }* ; <{ [16 x i8] }*> [#uses=1] %D = getelementptr { [16 x i8] }* %C, i32 0, i32 0, i32 8 ; <i8*> [#uses=1] %E = bitcast i8* %D to i8** ; <i8**> [#uses=1] store i8* %v, i8** %E %F = getelementptr [4 x i8*]* %A, i32 0, i32 2 ; <i8**> [#uses=1] %G = load i8** %F ; <i8*> [#uses=1] ret i8* %G } Doing so would allow SROA to eliminate the alloca, turning the function into an identity function. -Chris
working on this.
Implemented, patch here: http://lists.cs.uiuc.edu/pipermail/llvm-commits/Week-of-Mon-20070423/048573.html Testcase here: Transforms/InstCombine/bitcast-gep.ll -Chris