1
0
mirror of https://github.com/RPCS3/llvm-mirror.git synced 2024-11-23 11:13:28 +01:00

[SLSR] Call getPointerSizeInBits with the correct address space.

llvm-svn: 275083
This commit is contained in:
Jingyue Wu 2016-07-11 18:13:28 +00:00
parent fd6ab00139
commit b465fe9970
2 changed files with 22 additions and 5 deletions

View File

@ -505,7 +505,7 @@ void StraightLineStrengthReduce::allocateCandidatesAndFindBasisForGEP(
Value *ArrayIdx = GEP->getOperand(I);
uint64_t ElementSize = DL->getTypeAllocSize(*GTI);
if (ArrayIdx->getType()->getIntegerBitWidth() <=
DL->getPointerSizeInBits()) {
DL->getPointerSizeInBits(GEP->getAddressSpace())) {
// Skip factoring if ArrayIdx is wider than the pointer size, because
// ArrayIdx is implicitly truncated to the pointer size.
factorArrayIndex(ArrayIdx, BaseExpr, ElementSize, GEP);
@ -516,7 +516,7 @@ void StraightLineStrengthReduce::allocateCandidatesAndFindBasisForGEP(
Value *TruncatedArrayIdx = nullptr;
if (match(ArrayIdx, m_SExt(m_Value(TruncatedArrayIdx))) &&
TruncatedArrayIdx->getType()->getIntegerBitWidth() <=
DL->getPointerSizeInBits()) {
DL->getPointerSizeInBits(GEP->getAddressSpace())) {
// Skip factoring if TruncatedArrayIdx is wider than the pointer size,
// because TruncatedArrayIdx is implicitly truncated to the pointer size.
factorArrayIndex(TruncatedArrayIdx, BaseExpr, ElementSize, GEP);

View File

@ -1,6 +1,6 @@
; RUN: opt < %s -slsr -gvn -S | FileCheck %s
target datalayout = "e-i64:64-v16:16-v32:32-n16:32:64"
target datalayout = "e-i64:64-v16:16-v32:32-n16:32:64-p:64:64:64-p1:32:32:32"
; foo(input[0]);
; foo(input[s]);
@ -149,8 +149,8 @@ define void @slsr_out_of_bounds_gep(i32* %input, i32 %s) {
ret void
}
define void @slsr_gep_128bit(i32* %input, i128 %s) {
; CHECK-LABEL: @slsr_gep_128bit(
define void @slsr_gep_128bit_index(i32* %input, i128 %s) {
; CHECK-LABEL: @slsr_gep_128bit_index(
; p0 = &input[0]
%p0 = getelementptr inbounds i32, i32* %input, i128 0
call void @foo(i32* %p0)
@ -170,5 +170,22 @@ define void @slsr_gep_128bit(i32* %input, i128 %s) {
ret void
}
define void @slsr_gep_32bit_pointer(i32 addrspace(1)* %input, i64 %s) {
; CHECK-LABEL: @slsr_gep_32bit_pointer(
; p1 = &input[s]
%p1 = getelementptr inbounds i32, i32 addrspace(1)* %input, i64 %s
call void @baz(i32 addrspace(1)* %p1)
; p2 = &input[s * 2]
%s2 = mul nsw i64 %s, 2
%p2 = getelementptr inbounds i32, i32 addrspace(1)* %input, i64 %s2
; %s2 is wider than the pointer size of addrspace(1), so do not factor it.
; CHECK: %p2 = getelementptr inbounds i32, i32 addrspace(1)* %input, i64 %s2
call void @baz(i32 addrspace(1)* %p2)
ret void
}
declare void @foo(i32*)
declare void @bar(i64*)
declare void @baz(i32 addrspace(1)*)