1 ; RUN: opt -S -basic-aa -loop-idiom < %s | FileCheck %s
3 target datalayout = "e-m:e-i64:64-f80:128-n8:16:32:64-S128-ni:4"
4 target triple = "x86_64-unknown-linux-gnu"
6 ; LIR'ing stores of pointers with address space 3 is fine, since
7 ; they're integral pointers.
8 define void @f_0(i8 addrspace(3)** %ptr) {
10 ; CHECK: call{{.*}}memset
16 %indvar = phi i64 [ 0, %entry ], [ %indvar.next, %for.body ]
17 %arrayidx = getelementptr i8 addrspace(3)*, i8 addrspace(3)** %ptr, i64 %indvar
18 store i8 addrspace(3)* null, i8 addrspace(3)** %arrayidx, align 4
19 %indvar.next = add i64 %indvar, 1
20 %exitcond = icmp eq i64 %indvar.next, 10000
21 br i1 %exitcond, label %for.end, label %for.body
27 ; LIR'ing stores of pointers with address space 4 is not ok, since
28 ; they're non-integral pointers. NOTE: Zero is special value which
29 ; can be converted, if we add said handling here, convert this test
30 ; to use any non-null pointer.
31 define void @f_1(i8 addrspace(4)** %ptr) {
33 ; CHECK-NOT: call{{.*}}memset
39 %indvar = phi i64 [ 0, %entry ], [ %indvar.next, %for.body ]
40 %arrayidx = getelementptr i8 addrspace(4)*, i8 addrspace(4)** %ptr, i64 %indvar
41 store i8 addrspace(4)* null, i8 addrspace(4)** %arrayidx, align 4
42 %indvar.next = add i64 %indvar, 1
43 %exitcond = icmp eq i64 %indvar.next, 10000
44 br i1 %exitcond, label %for.end, label %for.body
50 ; Same as previous case, but vector of non-integral pointers
51 define void @f_2(i8 addrspace(4)** %ptr) {
53 ; CHECK-NOT: call{{.*}}memset
58 %indvar = phi i64 [ 0, %entry ], [ %indvar.next, %for.body ]
59 %arrayidx = getelementptr i8 addrspace(4)*, i8 addrspace(4)** %ptr, i64 %indvar
60 %addr = bitcast i8 addrspace(4)** %arrayidx to <2 x i8 addrspace(4)*>*
61 store <2 x i8 addrspace(4)*> zeroinitializer, <2 x i8 addrspace(4)*>* %addr, align 8
62 %indvar.next = add i64 %indvar, 2
63 %exitcond = icmp eq i64 %indvar.next, 10000
64 br i1 %exitcond, label %for.end, label %for.body