[PATCH] Handle big index in getelementptr instruction
Paweł Bylica
chfast at gmail.com
Tue Mar 10 13:55:58 PDT 2015
REPOSITORY
rL LLVM
================
Comment at: lib/CodeGen/SelectionDAG/FastISel.cpp:521
@@ -520,3 +520,3 @@
// N = N + Offset
- TotalOffs +=
- DL.getTypeAllocSize(Ty) * cast<ConstantInt>(CI)->getSExtValue();
+ auto I = CI->getValue().sextOrTrunc(sizeof(TotalOffs)*8).getSExtValue();
+ TotalOffs += DL.getTypeAllocSize(Ty) * I;
----------------
majnemer wrote:
> chfast wrote:
> > rnk wrote:
> > > rnk wrote:
> > > > Don't shadow the outer 'I' variable.
> > > This sizeof computation doesn't get PtrSize. LLVM is a cross compiler. You can compute it out of the loop.
> > I don't want a PtrSize, I want TotalOffs size in bits, because I'm going to add to that variable.
> In that case, please just use 64. LLVM assumes that pointers are not wider than 64-bits.
>
> Is this functionally different from:
> CI->getValue().trunc(64).getSExtValue();
>
> ?
It is different. `CI->getValue()` can be also smaller than i64, e.g i8. We need to sext if smaller, trunc if bigger.
http://reviews.llvm.org/D8219
EMAIL PREFERENCES
http://reviews.llvm.org/settings/panel/emailpreferences/
More information about the llvm-commits
mailing list