In the attached .ll you can find: %tmp64 = bitcast i32* %tmp1 to { i32 }* ; <{ i32 }*> [#uses=1] %tmp65 = getelementptr { i32 }* %tmp64, i32 0, i32 0 ; <i32*> [#uses=1] Thus %tmp65 is equal to %tmp1, but the optimizers miss this. This strange construction was produced by llvm-convert, or so it seems. I will try to find out why it is being produced in the first place.
Created attachment 710 [details] Small but not completely reduced testcase
Nice catch. Testcase here: Transforms/InstCombine/cast2.ll:test3 Patch here: http://lists.cs.uiuc.edu/pipermail/llvm-commits/Week-of-Mon-20070319/046249.html -Chris
Actually, this could be more general: trailing zeros can be eliminated, at least if all indices are constant. For example, indices "1,0" could be turned into "1" plus a bitcast.
Of course. Again, the goal isn't to reimplement instcombine :)