mirror of
https://github.com/c64scene-ar/llvm-6502.git
synced 2024-12-14 11:32:34 +00:00
Use right address space size in InstCombineCompares
The test's output doesn't change, but this ensures this is actually hit with a different address space. git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@191701 91177308-0d34-0410-b5e6-96231b3b80d8
This commit is contained in:
parent
f9dd19f498
commit
3ca8f2e5d5
@ -394,9 +394,12 @@ FoldCmpLoadFromIndexedGlobal(GetElementPtrInst *GEP, GlobalVariable *GV,
|
||||
// If the index is larger than the pointer size of the target, truncate the
|
||||
// index down like the GEP would do implicitly. We don't have to do this for
|
||||
// an inbounds GEP because the index can't be out of range.
|
||||
if (!GEP->isInBounds() &&
|
||||
Idx->getType()->getPrimitiveSizeInBits() > TD->getPointerSizeInBits())
|
||||
Idx = Builder->CreateTrunc(Idx, TD->getIntPtrType(Idx->getContext()));
|
||||
if (!GEP->isInBounds()) {
|
||||
Type *IntPtrTy = TD->getIntPtrType(GEP->getType());
|
||||
unsigned PtrSize = IntPtrTy->getIntegerBitWidth();
|
||||
if (Idx->getType()->getPrimitiveSizeInBits() > PtrSize)
|
||||
Idx = Builder->CreateTrunc(Idx, IntPtrTy);
|
||||
}
|
||||
|
||||
// If the comparison is only true for one or two elements, emit direct
|
||||
// comparisons.
|
||||
|
@ -1,8 +1,12 @@
|
||||
; RUN: opt -instcombine -S < %s | FileCheck -check-prefix=NODL %s
|
||||
; RUN: opt -instcombine -S -default-data-layout="p:32:32:32-n8:16:32:64" < %s | FileCheck -check-prefix=P32 %s
|
||||
; RUN: opt -instcombine -S -default-data-layout="p:32:32:32-p1:16:16:16-n8:16:32:64" < %s | FileCheck -check-prefix=P32 %s
|
||||
|
||||
@G16 = internal constant [10 x i16] [i16 35, i16 82, i16 69, i16 81, i16 85,
|
||||
i16 73, i16 82, i16 69, i16 68, i16 0]
|
||||
|
||||
@G16_as1 = internal addrspace(1) constant [10 x i16] [i16 35, i16 82, i16 69, i16 81, i16 85,
|
||||
i16 73, i16 82, i16 69, i16 68, i16 0]
|
||||
|
||||
@GD = internal constant [6 x double]
|
||||
[double -10.0, double 1.0, double 4.0, double 2.0, double -20.0, double -40.0]
|
||||
|
||||
@ -56,6 +60,18 @@ define i1 @test1_noinbounds_i64(i64 %X) {
|
||||
; P32-NEXT: ret i1 %R
|
||||
}
|
||||
|
||||
define i1 @test1_noinbounds_as1(i32 %x) {
|
||||
%p = getelementptr [10 x i16] addrspace(1)* @G16_as1, i16 0, i32 %x
|
||||
%q = load i16 addrspace(1)* %p
|
||||
%r = icmp eq i16 %q, 0
|
||||
ret i1 %r
|
||||
|
||||
; P32-LABEL: @test1_noinbounds_as1(
|
||||
; P32-NEXT: trunc i32 %x to i16
|
||||
; P32-NEXT: %r = icmp eq i16 %1, 9
|
||||
; P32-NEXT: ret i1 %r
|
||||
}
|
||||
|
||||
define i1 @test2(i32 %X) {
|
||||
%P = getelementptr inbounds [10 x i16]* @G16, i32 0, i32 %X
|
||||
%Q = load i16* %P
|
||||
|
Loading…
Reference in New Issue
Block a user