[PowerPC] Correctly compute 64-bit offsets in fast isel
authorUlrich Weigand <ulrich.weigand@de.ibm.com>
Thu, 31 Mar 2016 15:37:06 +0000 (15:37 +0000)
committerUlrich Weigand <ulrich.weigand@de.ibm.com>
Thu, 31 Mar 2016 15:37:06 +0000 (15:37 +0000)
commit3707ba80302b184c850ccdab2191650b75486742
tree311ca1ffe77dff4042cc8c41977a3067459ff22c
parenta621a7f9c30b86f7c38487ab2c24dea4b14043b3
[PowerPC] Correctly compute 64-bit offsets in fast isel

PPCSimplifyAddress contains this code:

  IntegerType *OffsetTy = ((VT == MVT::i32) ? Type::getInt32Ty(*Context)
                                            : Type::getInt64Ty(*Context));

to determine the type to be used for an index register, if one needs
to be created.  However, the "VT" here is the type of the data being
loaded or stored, *not* the type of an address.  This means that if
a data element of type i32 is accessed using an index that does not
not fit into 32 bits, a wrong address is computed here.

Note that PPCFastISel is only ever used on 64-bit currently, so the type
of an address is actually *always* MVT::i64.  Other parts of the code,
even in this same PPCSimplifyAddress routine, already rely on that fact.
Thus, this patch changes the code to simply unconditionally use
Type::getInt64Ty(*Context) as OffsetTy.

llvm-svn: 265023
llvm/lib/Target/PowerPC/PPCFastISel.cpp
llvm/test/CodeGen/PowerPC/fast-isel-i64offset.ll [new file with mode: 0644]