diff options
author | Jan Voung <jvoung@chromium.org> | 2013-06-03 14:08:49 -0700 |
---|---|---|
committer | Jan Voung <jvoung@chromium.org> | 2013-06-03 14:08:49 -0700 |
commit | b32a69792213eef2ff93440ba09c659b28733169 (patch) | |
tree | f37b0db9158fc84f52b058394415da09ce1a31f0 /lib | |
parent | 8253f255b7936070b3bae07fe9aead104f2ecde7 (diff) |
PNaCl gep expansion: avoid mul by 1 for i8 arrays.
Makes the bitcode a tiny bit smaller, and avoids generating
shift left by 0 code under fast-isel.
BUG=https://code.google.com/p/nativeclient/issues/detail?id=3343
TEST=*.ll tests
R=mseaborn@chromium.org
Review URL: https://codereview.chromium.org/15861029
Diffstat (limited to 'lib')
-rw-r--r-- | lib/Transforms/NaCl/ExpandGetElementPtr.cpp | 14 |
1 files changed, 9 insertions, 5 deletions
diff --git a/lib/Transforms/NaCl/ExpandGetElementPtr.cpp b/lib/Transforms/NaCl/ExpandGetElementPtr.cpp index 974c3193de..1fe11293ca 100644 --- a/lib/Transforms/NaCl/ExpandGetElementPtr.cpp +++ b/lib/Transforms/NaCl/ExpandGetElementPtr.cpp @@ -106,11 +106,15 @@ static void ExpandGEP(GetElementPtrInst *GEP, DataLayout *DL, Type *PtrType) { } else { FlushOffset(&Ptr, &CurrentOffset, GEP, Debug, PtrType); Index = CastToPtrSize(Index, GEP, Debug, PtrType); - Instruction *Mul = BinaryOperator::Create( - Instruction::Mul, Index, ConstantInt::get(PtrType, ElementSize), - "gep_array", GEP); - Mul->setDebugLoc(Debug); - Ptr = BinaryOperator::Create(Instruction::Add, Ptr, Mul, "gep", GEP); + if (ElementSize != 1) { + Index = CopyDebug( + BinaryOperator::Create(Instruction::Mul, Index, + ConstantInt::get(PtrType, ElementSize), + "gep_array", GEP), + GEP); + } + Ptr = BinaryOperator::Create(Instruction::Add, Ptr, + Index, "gep", GEP); Ptr->setDebugLoc(Debug); } } |