diff options
| author | Ulrich Weigand <ulrich.weigand@de.ibm.com> | 2016-03-31 15:37:06 +0000 |
|---|---|---|
| committer | Ulrich Weigand <ulrich.weigand@de.ibm.com> | 2016-03-31 15:37:06 +0000 |
| commit | 3707ba80302b184c850ccdab2191650b75486742 (patch) | |
| tree | 311ca1ffe77dff4042cc8c41977a3067459ff22c /llvm/test | |
| parent | a621a7f9c30b86f7c38487ab2c24dea4b14043b3 (diff) | |
| download | bcm5719-llvm-3707ba80302b184c850ccdab2191650b75486742.tar.gz bcm5719-llvm-3707ba80302b184c850ccdab2191650b75486742.zip | |
[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
Diffstat (limited to 'llvm/test')
| -rw-r--r-- | llvm/test/CodeGen/PowerPC/fast-isel-i64offset.ll | 15 |
1 files changed, 15 insertions, 0 deletions
diff --git a/llvm/test/CodeGen/PowerPC/fast-isel-i64offset.ll b/llvm/test/CodeGen/PowerPC/fast-isel-i64offset.ll new file mode 100644 index 00000000000..e184ce4c3b3 --- /dev/null +++ b/llvm/test/CodeGen/PowerPC/fast-isel-i64offset.ll @@ -0,0 +1,15 @@ +; RUN: llc -mtriple powerpc64-unknown-linux-gnu -fast-isel -O0 < %s | FileCheck %s + +; Verify that pointer offsets larger than 32 bits work correctly. + +define void @test(i32* %array) { +; CHECK-LABEL: test: +; CHECK: lis [[REG:[0-9]+]], 16383 +; CHECK: ori [[REG]], [[REG]], 65535 +; CHECK: sldi [[REG]], [[REG]], 3 +; CHECK: stwx {{[0-9]+}}, 3, [[REG]] + %element = getelementptr i32, i32* %array, i64 2147483646 + store i32 1234, i32* %element + ret void +} + |

