target datalayout = "e-i64:64-v16:16-v32:32-n16:32:64"
target triple = "nvptx64-unknown-unknown"
-declare void @foo(float*)
+declare void @foo(ptr)
; foo(&a[i]);
; foo(&a[i + j]);
; t = &a[i];
; foo(t);
; foo(t + j);
-define void @reassociate_gep(float* %a, i64 %i, i64 %j) {
+define void @reassociate_gep(ptr %a, i64 %i, i64 %j) {
; CHECK-LABEL: @reassociate_gep(
%1 = add i64 %i, %j
- %2 = getelementptr float, float* %a, i64 %i
-; CHECK: [[t1:[^ ]+]] = getelementptr float, float* %a, i64 %i
- call void @foo(float* %2)
-; CHECK: call void @foo(float* [[t1]])
- %3 = getelementptr float, float* %a, i64 %1
-; CHECK: [[t2:[^ ]+]] = getelementptr float, float* [[t1]], i64 %j
- call void @foo(float* %3)
-; CHECK: call void @foo(float* [[t2]])
+ %2 = getelementptr float, ptr %a, i64 %i
+; CHECK: [[t1:[^ ]+]] = getelementptr float, ptr %a, i64 %i
+ call void @foo(ptr %2)
+; CHECK: call void @foo(ptr [[t1]])
+ %3 = getelementptr float, ptr %a, i64 %1
+; CHECK: [[t2:[^ ]+]] = getelementptr float, ptr [[t1]], i64 %j
+ call void @foo(ptr %3)
+; CHECK: call void @foo(ptr [[t2]])
ret void
}
; foo(t2);
; t3 = t2 + sext(i); // sext(i) should be GVN'ed.
; foo(t3);
-define void @reassociate_gep_nsw(float* %a, i32 %i, i32 %j) {
+define void @reassociate_gep_nsw(ptr %a, i32 %i, i32 %j) {
; CHECK-LABEL: @reassociate_gep_nsw(
%idxprom.j = sext i32 %j to i64
- %1 = getelementptr float, float* %a, i64 %idxprom.j
-; CHECK: [[t1:[^ ]+]] = getelementptr float, float* %a, i64 %idxprom.j
- call void @foo(float* %1)
-; CHECK: call void @foo(float* [[t1]])
+ %1 = getelementptr float, ptr %a, i64 %idxprom.j
+; CHECK: [[t1:[^ ]+]] = getelementptr float, ptr %a, i64 %idxprom.j
+ call void @foo(ptr %1)
+; CHECK: call void @foo(ptr [[t1]])
%2 = add nsw i32 %i, %j
%idxprom.2 = sext i32 %2 to i64
- %3 = getelementptr float, float* %a, i64 %idxprom.2
+ %3 = getelementptr float, ptr %a, i64 %idxprom.2
; CHECK: [[sexti:[^ ]+]] = sext i32 %i to i64
-; CHECK: [[t2:[^ ]+]] = getelementptr float, float* [[t1]], i64 [[sexti]]
- call void @foo(float* %3)
-; CHECK: call void @foo(float* [[t2]])
+; CHECK: [[t2:[^ ]+]] = getelementptr float, ptr [[t1]], i64 [[sexti]]
+ call void @foo(ptr %3)
+; CHECK: call void @foo(ptr [[t2]])
%4 = add nsw i32 %2, %i
%idxprom.4 = sext i32 %4 to i64
- %5 = getelementptr float, float* %a, i64 %idxprom.4
-; CHECK: [[t3:[^ ]+]] = getelementptr float, float* [[t2]], i64 [[sexti]]
- call void @foo(float* %5)
-; CHECK: call void @foo(float* [[t3]])
+ %5 = getelementptr float, ptr %a, i64 %idxprom.4
+; CHECK: [[t3:[^ ]+]] = getelementptr float, ptr [[t2]], i64 [[sexti]]
+ call void @foo(ptr %5)
+; CHECK: call void @foo(ptr [[t3]])
ret void
}
; foo(t1);
; t2 = t1 + sext(i);
; foo(t2);
-define void @reassociate_gep_assume(float* %a, i32 %i, i32 %j) {
+define void @reassociate_gep_assume(ptr %a, i32 %i, i32 %j) {
; CHECK-LABEL: @reassociate_gep_assume(
; assume(j >= 0)
%cmp = icmp sgt i32 %j, -1
call void @llvm.assume(i1 %cmp2)
%idxprom.j = zext i32 %j to i64
- %2 = getelementptr float, float* %a, i64 %idxprom.j
-; CHECK: [[t1:[^ ]+]] = getelementptr float, float* %a, i64 %idxprom.j
- call void @foo(float* %2)
-; CHECK: call void @foo(float* [[t1]])
+ %2 = getelementptr float, ptr %a, i64 %idxprom.j
+; CHECK: [[t1:[^ ]+]] = getelementptr float, ptr %a, i64 %idxprom.j
+ call void @foo(ptr %2)
+; CHECK: call void @foo(ptr [[t1]])
%idxprom.1 = zext i32 %1 to i64
- %3 = getelementptr float, float* %a, i64 %idxprom.1
+ %3 = getelementptr float, ptr %a, i64 %idxprom.1
; CHECK: [[sexti:[^ ]+]] = sext i32 %i to i64
-; CHECK: [[t2:[^ ]+]] = getelementptr float, float* [[t1]], i64 [[sexti]]
- call void @foo(float* %3)
-; CHECK: call void @foo(float* [[t2]])
+; CHECK: [[t2:[^ ]+]] = getelementptr float, ptr [[t1]], i64 [[sexti]]
+ call void @foo(ptr %3)
+; CHECK: call void @foo(ptr [[t2]])
ret void
}
; Do not split the second GEP because sext(i + j) != sext(i) + sext(j).
-define void @reassociate_gep_no_nsw(float* %a, i32 %i, i32 %j) {
+define void @reassociate_gep_no_nsw(ptr %a, i32 %i, i32 %j) {
; CHECK-LABEL: @reassociate_gep_no_nsw(
%1 = add i32 %i, %j
- %2 = getelementptr float, float* %a, i32 %j
-; CHECK: getelementptr float, float* %a, i32 %j
- call void @foo(float* %2)
- %3 = getelementptr float, float* %a, i32 %1
-; CHECK: getelementptr float, float* %a, i32 %1
- call void @foo(float* %3)
+ %2 = getelementptr float, ptr %a, i32 %j
+; CHECK: getelementptr float, ptr %a, i32 %j
+ call void @foo(ptr %2)
+ %3 = getelementptr float, ptr %a, i32 %1
+; CHECK: getelementptr float, ptr %a, i32 %1
+ call void @foo(ptr %3)
ret void
}
-define void @reassociate_gep_128(float* %a, i128 %i, i128 %j) {
+define void @reassociate_gep_128(ptr %a, i128 %i, i128 %j) {
; CHECK-LABEL: @reassociate_gep_128(
%1 = add i128 %i, %j
- %2 = getelementptr float, float* %a, i128 %i
-; CHECK: [[t1:[^ ]+]] = getelementptr float, float* %a, i128 %i
- call void @foo(float* %2)
-; CHECK: call void @foo(float* [[t1]])
- %3 = getelementptr float, float* %a, i128 %1
+ %2 = getelementptr float, ptr %a, i128 %i
+; CHECK: [[t1:[^ ]+]] = getelementptr float, ptr %a, i128 %i
+ call void @foo(ptr %2)
+; CHECK: call void @foo(ptr [[t1]])
+ %3 = getelementptr float, ptr %a, i128 %1
; CHECK: [[truncj:[^ ]+]] = trunc i128 %j to i64
-; CHECK: [[t2:[^ ]+]] = getelementptr float, float* [[t1]], i64 [[truncj]]
- call void @foo(float* %3)
-; CHECK: call void @foo(float* [[t2]])
+; CHECK: [[t2:[^ ]+]] = getelementptr float, ptr [[t1]], i64 [[truncj]]
+ call void @foo(ptr %3)
+; CHECK: call void @foo(ptr [[t2]])
ret void
}
%struct.complex = type { float, float }
-declare void @bar(%struct.complex*)
+declare void @bar(ptr)
-define void @different_types(%struct.complex* %input, i64 %i) {
+define void @different_types(ptr %input, i64 %i) {
; CHECK-LABEL: @different_types(
- %t1 = getelementptr %struct.complex, %struct.complex* %input, i64 %i
- call void @bar(%struct.complex* %t1)
+; CHECK-NEXT: %t1 = getelementptr %struct.complex, ptr %input, i64 %i
+; CHECK-NEXT: call void @bar(ptr %t1)
+; CHECK-NEXT: %t2 = getelementptr float, ptr %t1, i64 10
+; CHECK-NEXT: call void @foo(ptr %t2)
+ %t1 = getelementptr %struct.complex, ptr %input, i64 %i
+ call void @bar(ptr %t1)
%j = add i64 %i, 5
- %t2 = getelementptr %struct.complex, %struct.complex* %input, i64 %j, i32 0
-; CHECK: [[cast:[^ ]+]] = bitcast %struct.complex* %t1 to float*
-; CHECK-NEXT: %t2 = getelementptr float, float* [[cast]], i64 10
-; CHECK-NEXT: call void @foo(float* %t2)
- call void @foo(float* %t2)
+ %t2 = getelementptr %struct.complex, ptr %input, i64 %j, i32 0
+ call void @foo(ptr %t2)
ret void
}
}
; Pointer types are not supported yet
-define i32* @smax_test8(i32* %a, i32* %b, i32* %c) {
+define ptr @smax_test8(ptr %a, ptr %b, ptr %c) {
; CHECK-LABEL: @smax_test8(
-; CHECK-NEXT: [[C1:%.*]] = icmp sgt i32* [[A:%.*]], [[B:%.*]]
-; CHECK-NEXT: [[SMAX1:%.*]] = select i1 [[C1]], i32* [[A]], i32* [[B]]
-; CHECK-NEXT: [[C2:%.*]] = icmp sgt i32* [[B]], [[C:%.*]]
-; CHECK-NEXT: [[SMAX2:%.*]] = select i1 [[C2]], i32* [[B]], i32* [[C]]
-; CHECK-NEXT: [[C3:%.*]] = icmp sgt i32* [[SMAX2]], [[A]]
-; CHECK-NEXT: [[SMAX3:%.*]] = select i1 [[C3]], i32* [[SMAX2]], i32* [[A]]
-; CHECK-NEXT: [[C4:%.*]] = icmp sgt i32* [[SMAX1]], [[SMAX3]]
-; CHECK-NEXT: [[RES:%.*]] = select i1 [[C4]], i32* [[SMAX1]], i32* [[SMAX3]]
-; CHECK-NEXT: ret i32* [[RES]]
+; CHECK-NEXT: [[C1:%.*]] = icmp sgt ptr [[A:%.*]], [[B:%.*]]
+; CHECK-NEXT: [[SMAX1:%.*]] = select i1 [[C1]], ptr [[A]], ptr [[B]]
+; CHECK-NEXT: [[C2:%.*]] = icmp sgt ptr [[B]], [[C:%.*]]
+; CHECK-NEXT: [[SMAX2:%.*]] = select i1 [[C2]], ptr [[B]], ptr [[C]]
+; CHECK-NEXT: [[C3:%.*]] = icmp sgt ptr [[SMAX2]], [[A]]
+; CHECK-NEXT: [[SMAX3:%.*]] = select i1 [[C3]], ptr [[SMAX2]], ptr [[A]]
+; CHECK-NEXT: [[C4:%.*]] = icmp sgt ptr [[SMAX1]], [[SMAX3]]
+; CHECK-NEXT: [[RES:%.*]] = select i1 [[C4]], ptr [[SMAX1]], ptr [[SMAX3]]
+; CHECK-NEXT: ret ptr [[RES]]
;
- %c1 = icmp sgt i32* %a, %b
- %smax1 = select i1 %c1, i32* %a, i32* %b
- %c2 = icmp sgt i32* %b, %c
- %smax2 = select i1 %c2, i32* %b, i32* %c
- %c3 = icmp sgt i32* %smax2, %a
- %smax3 = select i1 %c3, i32* %smax2, i32* %a
- %c4 = icmp sgt i32* %smax1, %smax3
- %res = select i1 %c4, i32* %smax1, i32* %smax3
- ret i32* %res
+ %c1 = icmp sgt ptr %a, %b
+ %smax1 = select i1 %c1, ptr %a, ptr %b
+ %c2 = icmp sgt ptr %b, %c
+ %smax2 = select i1 %c2, ptr %b, ptr %c
+ %c3 = icmp sgt ptr %smax2, %a
+ %smax3 = select i1 %c3, ptr %smax2, ptr %a
+ %c4 = icmp sgt ptr %smax1, %smax3
+ %res = select i1 %c4, ptr %smax1, ptr %smax3
+ ret ptr %res
}
}
; Pointer types are not supported yet
-define i32* @smin_test8(i32* %a, i32* %b, i32* %c) {
+define ptr @smin_test8(ptr %a, ptr %b, ptr %c) {
; CHECK-LABEL: @smin_test8(
-; CHECK-NEXT: [[C1:%.*]] = icmp slt i32* [[A:%.*]], [[B:%.*]]
-; CHECK-NEXT: [[UMIN1:%.*]] = select i1 [[C1]], i32* [[A]], i32* [[B]]
-; CHECK-NEXT: [[C2:%.*]] = icmp slt i32* [[B]], [[C:%.*]]
-; CHECK-NEXT: [[UMIN2:%.*]] = select i1 [[C2]], i32* [[B]], i32* [[C]]
-; CHECK-NEXT: [[C3:%.*]] = icmp slt i32* [[UMIN2]], [[A]]
-; CHECK-NEXT: [[UMIN3:%.*]] = select i1 [[C3]], i32* [[UMIN2]], i32* [[A]]
-; CHECK-NEXT: [[C4:%.*]] = icmp slt i32* [[UMIN1]], [[UMIN3]]
-; CHECK-NEXT: [[RES:%.*]] = select i1 [[C4]], i32* [[UMIN1]], i32* [[UMIN3]]
-; CHECK-NEXT: ret i32* [[RES]]
+; CHECK-NEXT: [[C1:%.*]] = icmp slt ptr [[A:%.*]], [[B:%.*]]
+; CHECK-NEXT: [[UMIN1:%.*]] = select i1 [[C1]], ptr [[A]], ptr [[B]]
+; CHECK-NEXT: [[C2:%.*]] = icmp slt ptr [[B]], [[C:%.*]]
+; CHECK-NEXT: [[UMIN2:%.*]] = select i1 [[C2]], ptr [[B]], ptr [[C]]
+; CHECK-NEXT: [[C3:%.*]] = icmp slt ptr [[UMIN2]], [[A]]
+; CHECK-NEXT: [[UMIN3:%.*]] = select i1 [[C3]], ptr [[UMIN2]], ptr [[A]]
+; CHECK-NEXT: [[C4:%.*]] = icmp slt ptr [[UMIN1]], [[UMIN3]]
+; CHECK-NEXT: [[RES:%.*]] = select i1 [[C4]], ptr [[UMIN1]], ptr [[UMIN3]]
+; CHECK-NEXT: ret ptr [[RES]]
;
- %c1 = icmp slt i32* %a, %b
- %umin1 = select i1 %c1, i32* %a, i32* %b
- %c2 = icmp slt i32* %b, %c
- %umin2 = select i1 %c2, i32* %b, i32* %c
- %c3 = icmp slt i32* %umin2, %a
- %umin3 = select i1 %c3, i32* %umin2, i32* %a
- %c4 = icmp slt i32* %umin1, %umin3
- %res = select i1 %c4, i32* %umin1, i32* %umin3
- ret i32* %res
+ %c1 = icmp slt ptr %a, %b
+ %umin1 = select i1 %c1, ptr %a, ptr %b
+ %c2 = icmp slt ptr %b, %c
+ %umin2 = select i1 %c2, ptr %b, ptr %c
+ %c3 = icmp slt ptr %umin2, %a
+ %umin3 = select i1 %c3, ptr %umin2, ptr %a
+ %c4 = icmp slt ptr %umin1, %umin3
+ %res = select i1 %c4, ptr %umin1, ptr %umin3
+ ret ptr %res
}
}
; Pointer types are not supported yet
-define i32* @umax_test8(i32* %a, i32* %b, i32* %c) {
+define ptr @umax_test8(ptr %a, ptr %b, ptr %c) {
; CHECK-LABEL: @umax_test8(
-; CHECK-NEXT: [[C1:%.*]] = icmp ugt i32* [[A:%.*]], [[B:%.*]]
-; CHECK-NEXT: [[SMAX1:%.*]] = select i1 [[C1]], i32* [[A]], i32* [[B]]
-; CHECK-NEXT: [[C2:%.*]] = icmp ugt i32* [[B]], [[C:%.*]]
-; CHECK-NEXT: [[SMAX2:%.*]] = select i1 [[C2]], i32* [[B]], i32* [[C]]
-; CHECK-NEXT: [[C3:%.*]] = icmp ugt i32* [[SMAX2]], [[A]]
-; CHECK-NEXT: [[SMAX3:%.*]] = select i1 [[C3]], i32* [[SMAX2]], i32* [[A]]
-; CHECK-NEXT: [[C4:%.*]] = icmp ugt i32* [[SMAX1]], [[SMAX3]]
-; CHECK-NEXT: [[RES:%.*]] = select i1 [[C4]], i32* [[SMAX1]], i32* [[SMAX3]]
-; CHECK-NEXT: ret i32* [[RES]]
+; CHECK-NEXT: [[C1:%.*]] = icmp ugt ptr [[A:%.*]], [[B:%.*]]
+; CHECK-NEXT: [[SMAX1:%.*]] = select i1 [[C1]], ptr [[A]], ptr [[B]]
+; CHECK-NEXT: [[C2:%.*]] = icmp ugt ptr [[B]], [[C:%.*]]
+; CHECK-NEXT: [[SMAX2:%.*]] = select i1 [[C2]], ptr [[B]], ptr [[C]]
+; CHECK-NEXT: [[C3:%.*]] = icmp ugt ptr [[SMAX2]], [[A]]
+; CHECK-NEXT: [[SMAX3:%.*]] = select i1 [[C3]], ptr [[SMAX2]], ptr [[A]]
+; CHECK-NEXT: [[C4:%.*]] = icmp ugt ptr [[SMAX1]], [[SMAX3]]
+; CHECK-NEXT: [[RES:%.*]] = select i1 [[C4]], ptr [[SMAX1]], ptr [[SMAX3]]
+; CHECK-NEXT: ret ptr [[RES]]
;
- %c1 = icmp ugt i32* %a, %b
- %smax1 = select i1 %c1, i32* %a, i32* %b
- %c2 = icmp ugt i32* %b, %c
- %smax2 = select i1 %c2, i32* %b, i32* %c
- %c3 = icmp ugt i32* %smax2, %a
- %smax3 = select i1 %c3, i32* %smax2, i32* %a
- %c4 = icmp ugt i32* %smax1, %smax3
- %res = select i1 %c4, i32* %smax1, i32* %smax3
- ret i32* %res
+ %c1 = icmp ugt ptr %a, %b
+ %smax1 = select i1 %c1, ptr %a, ptr %b
+ %c2 = icmp ugt ptr %b, %c
+ %smax2 = select i1 %c2, ptr %b, ptr %c
+ %c3 = icmp ugt ptr %smax2, %a
+ %smax3 = select i1 %c3, ptr %smax2, ptr %a
+ %c4 = icmp ugt ptr %smax1, %smax3
+ %res = select i1 %c4, ptr %smax1, ptr %smax3
+ ret ptr %res
}
}
; Pointer types are not supported yet
-define i32* @umin_test8(i32* %a, i32* %b, i32* %c) {
+define ptr @umin_test8(ptr %a, ptr %b, ptr %c) {
; CHECK-LABEL: @umin_test8(
-; CHECK-NEXT: [[C1:%.*]] = icmp ult i32* [[A:%.*]], [[B:%.*]]
-; CHECK-NEXT: [[UMIN1:%.*]] = select i1 [[C1]], i32* [[A]], i32* [[B]]
-; CHECK-NEXT: [[C2:%.*]] = icmp ult i32* [[B]], [[C:%.*]]
-; CHECK-NEXT: [[UMIN2:%.*]] = select i1 [[C2]], i32* [[B]], i32* [[C]]
-; CHECK-NEXT: [[C3:%.*]] = icmp ult i32* [[UMIN2]], [[A]]
-; CHECK-NEXT: [[UMIN3:%.*]] = select i1 [[C3]], i32* [[UMIN2]], i32* [[A]]
-; CHECK-NEXT: [[C4:%.*]] = icmp ult i32* [[UMIN1]], [[UMIN3]]
-; CHECK-NEXT: [[RES:%.*]] = select i1 [[C4]], i32* [[UMIN1]], i32* [[UMIN3]]
-; CHECK-NEXT: ret i32* [[RES]]
+; CHECK-NEXT: [[C1:%.*]] = icmp ult ptr [[A:%.*]], [[B:%.*]]
+; CHECK-NEXT: [[UMIN1:%.*]] = select i1 [[C1]], ptr [[A]], ptr [[B]]
+; CHECK-NEXT: [[C2:%.*]] = icmp ult ptr [[B]], [[C:%.*]]
+; CHECK-NEXT: [[UMIN2:%.*]] = select i1 [[C2]], ptr [[B]], ptr [[C]]
+; CHECK-NEXT: [[C3:%.*]] = icmp ult ptr [[UMIN2]], [[A]]
+; CHECK-NEXT: [[UMIN3:%.*]] = select i1 [[C3]], ptr [[UMIN2]], ptr [[A]]
+; CHECK-NEXT: [[C4:%.*]] = icmp ult ptr [[UMIN1]], [[UMIN3]]
+; CHECK-NEXT: [[RES:%.*]] = select i1 [[C4]], ptr [[UMIN1]], ptr [[UMIN3]]
+; CHECK-NEXT: ret ptr [[RES]]
;
- %c1 = icmp ult i32* %a, %b
- %umin1 = select i1 %c1, i32* %a, i32* %b
- %c2 = icmp ult i32* %b, %c
- %umin2 = select i1 %c2, i32* %b, i32* %c
- %c3 = icmp ult i32* %umin2, %a
- %umin3 = select i1 %c3, i32* %umin2, i32* %a
- %c4 = icmp ult i32* %umin1, %umin3
- %res = select i1 %c4, i32* %umin1, i32* %umin3
- ret i32* %res
+ %c1 = icmp ult ptr %a, %b
+ %umin1 = select i1 %c1, ptr %a, ptr %b
+ %c2 = icmp ult ptr %b, %c
+ %umin2 = select i1 %c2, ptr %b, ptr %c
+ %c3 = icmp ult ptr %umin2, %a
+ %umin3 = select i1 %c3, ptr %umin2, ptr %a
+ %c4 = icmp ult ptr %umin1, %umin3
+ %res = select i1 %c4, ptr %umin1, ptr %umin3
+ ret ptr %res
}