[llvm-commits] [llvm] r119942 - in /llvm/trunk: lib/Analysis/InstructionSimplify.cpp test/Transforms/InstCombine/2010-11-21-SizeZeroTypeGEP.ll

Frits van Bommel fvbommel at gmail.com
Sun Nov 21 06:20:08 PST 2010


On Sun, Nov 21, 2010 at 2:53 PM, Duncan Sands <baldrick at free.fr> wrote:
> More generally, if a gep index type has size zero, instcombine could replace the
> index with zero, but that is not done here.

You *could* do that here in certain cases. For instance, if the
pointer operand is constant and all non-constant indices are over
zero-sized types you could fold it to a constexpr gep with those
indices zero (or even a bitcast if all indices are then zero).

Might not be worth it though, as you'd probably still have to
duplicate pretty much all of that logic in instcombine to handle geps
with non-constant indices over non-zero-sized types. (And how many
non-constant indices over zero-sized types are you likely to encounter
anyway?)



More information about the llvm-commits mailing list