[llvm] r275083 - [SLSR] Call getPointerSizeInBits with the correct address space.
Jingyue Wu via llvm-commits
llvm-commits at lists.llvm.org
Mon Jul 11 11:13:28 PDT 2016
Author: jingyue
Date: Mon Jul 11 13:13:28 2016
New Revision: 275083
URL: http://llvm.org/viewvc/llvm-project?rev=275083&view=rev
Log:
[SLSR] Call getPointerSizeInBits with the correct address space.
Modified:
llvm/trunk/lib/Transforms/Scalar/StraightLineStrengthReduce.cpp
llvm/trunk/test/Transforms/StraightLineStrengthReduce/slsr-gep.ll
Modified: llvm/trunk/lib/Transforms/Scalar/StraightLineStrengthReduce.cpp
URL: http://llvm.org/viewvc/llvm-project/llvm/trunk/lib/Transforms/Scalar/StraightLineStrengthReduce.cpp?rev=275083&r1=275082&r2=275083&view=diff
==============================================================================
--- llvm/trunk/lib/Transforms/Scalar/StraightLineStrengthReduce.cpp (original)
+++ llvm/trunk/lib/Transforms/Scalar/StraightLineStrengthReduce.cpp Mon Jul 11 13:13:28 2016
@@ -505,7 +505,7 @@ void StraightLineStrengthReduce::allocat
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::allocat
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);
Modified: llvm/trunk/test/Transforms/StraightLineStrengthReduce/slsr-gep.ll
URL: http://llvm.org/viewvc/llvm-project/llvm/trunk/test/Transforms/StraightLineStrengthReduce/slsr-gep.ll?rev=275083&r1=275082&r2=275083&view=diff
==============================================================================
--- llvm/trunk/test/Transforms/StraightLineStrengthReduce/slsr-gep.ll (original)
+++ llvm/trunk/test/Transforms/StraightLineStrengthReduce/slsr-gep.ll Mon Jul 11 13:13:28 2016
@@ -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*
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
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)*)
More information about the llvm-commits
mailing list