llvm.org GIT mirror llvm / 74c996c
Use correct size for address space in BasicAA. The tests just hit this with a different sized address space since I haven't figured out how to use this to break it. I thought I committed this a long time ago, and I'm not sure why missing this hasn't caused any problems. git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@194903 91177308-0d34-0410-b5e6-96231b3b80d8 Matt Arsenault 6 years ago
3 changed file(s) with 44 addition(s) and 4 deletion(s). Raw diff Collapse all Expand all
325325 continue;
326326 }
327327
328 unsigned AS = GEPOp->getPointerAddressSpace();
328329 // Walk the indices of the GEP, accumulating them into BaseOff/VarIndices.
329330 gep_type_iterator GTI = gep_type_begin(GEPOp);
330331 for (User::const_op_iterator I = GEPOp->op_begin()+1,
353354 // If the integer type is smaller than the pointer size, it is implicitly
354355 // sign extended to pointer size.
355356 unsigned Width = Index->getType()->getIntegerBitWidth();
356 if (TD->getPointerSizeInBits() > Width)
357 if (TD->getPointerSizeInBits(AS) > Width)
357358 Extension = EK_SignExt;
358359
359360 // Use GetLinearExpression to decompose the index into a C1*V+C2 form.
381382
382383 // Make sure that we have a scale that makes sense for this target's
383384 // pointer size.
384 if (unsigned ShiftBits = 64-TD->getPointerSizeInBits()) {
385 if (unsigned ShiftBits = 64 - TD->getPointerSizeInBits(AS)) {
385386 Scale <<= ShiftBits;
386387 Scale = (int64_t)Scale >> ShiftBits;
387388 }
0 ; RUN: opt < %s -basicaa -gvn -instcombine -S 2>&1 | FileCheck %s
11
2 target datalayout = "e-p:32:32:32-i1:8:8-i8:8:8-i16:16:16-i32:32:32-i64:32:64-f32:32:32-f64:32:64-v64:64:64-v128:128:128-a0:0:64-f80:128:128"
2 target datalayout = "e-p:32:32:32-p1:16:16:16-i1:8:8-i8:8:8-i16:16:16-i32:32:32-i64:32:64-f32:32:32-f64:32:64-v64:64:64-v128:128:128-a0:0:64-f80:128:128"
33
44 ; Make sure that basicaa thinks R and r are must aliases.
55 define i32 @test1(i8 * %P) {
8282 %z = sub i32 %x, %y
8383 ret i32 %z
8484 ; CHECK-LABEL: @test5(
85 ; CHECK: ret i32 0
86 }
87
88 define i32 @test5_as1_smaller_size(i32 addrspace(1)* %p, i8 %i) {
89 %pi = getelementptr i32 addrspace(1)* %p, i8 %i
90 %i.next = add i8 %i, 1
91 %pi.next = getelementptr i32 addrspace(1)* %p, i8 %i.next
92 %x = load i32 addrspace(1)* %pi
93 store i32 42, i32 addrspace(1)* %pi.next
94 %y = load i32 addrspace(1)* %pi
95 %z = sub i32 %x, %y
96 ret i32 %z
97 ; CHECK-LABEL: @test5_as1_smaller_size(
98 ; CHECK: sext
99 ; CHECK: ret i32 0
100 }
101
102 define i32 @test5_as1_same_size(i32 addrspace(1)* %p, i16 %i) {
103 %pi = getelementptr i32 addrspace(1)* %p, i16 %i
104 %i.next = add i16 %i, 1
105 %pi.next = getelementptr i32 addrspace(1)* %p, i16 %i.next
106 %x = load i32 addrspace(1)* %pi
107 store i32 42, i32 addrspace(1)* %pi.next
108 %y = load i32 addrspace(1)* %pi
109 %z = sub i32 %x, %y
110 ret i32 %z
111 ; CHECK-LABEL: @test5_as1_same_size(
85112 ; CHECK: ret i32 0
86113 }
87114
11 ; the global.
22
33 ; RUN: opt < %s -basicaa -gvn -S | FileCheck %s
4 target datalayout = "E-p:64:64:64-a0:0:8-f32:32:32-f64:64:64-i1:8:8-i8:8:8-i16:16:16-i32:32:32-i64:32:64-v64:64:64-v128:128:128"
4 target datalayout = "E-p:64:64:64-p1:16:16:16-a0:0:8-f32:32:32-f64:64:64-i1:8:8-i8:8:8-i16:16:16-i32:32:32-i64:32:64-v64:64:64-v128:128:128"
55
66 @B = global i16 8
77
1313 %Z = sub i16 %Y, %X
1414 ret i16 %Z
1515 ; CHECK: ret i16 0
16 }
17
18 @B_as1 = addrspace(1) global i16 8
19
20 define i16 @test1_as1(i32 addrspace(1)* %P) {
21 ; CHECK-LABEL: @test1_as1(
22 ; CHECK: ret i16 0
23 %X = load i16 addrspace(1)* @B_as1
24 store i32 7, i32 addrspace(1)* %P
25 %Y = load i16 addrspace(1)* @B_as1
26 %Z = sub i16 %Y, %X
27 ret i16 %Z
1628 }
1729
1830 ; Cannot know anything about the size of this global.