[llvm] 92c4172 - [NFC][LoopLoadElim] Extending type-mismatch testing
Jolanta Jensen via llvm-commits
llvm-commits at lists.llvm.org
Tue Aug 30 08:46:39 PDT 2022
Author: Jolanta Jensen
Date: 2022-08-30T16:44:19+01:00
New Revision: 92c4172756b33094aaa140879a861562b0114927
URL: https://github.com/llvm/llvm-project/commit/92c4172756b33094aaa140879a861562b0114927
DIFF: https://github.com/llvm/llvm-project/commit/92c4172756b33094aaa140879a861562b0114927.diff
LOG: [NFC][LoopLoadElim] Extending type-mismatch testing
Added IR for int-pointer type mismatch and int-vector
type mismatch. Regenerated CHECK lines using
the update_test_checks.py script.
Differential Revision: https://reviews.llvm.org/D132239
Added:
Modified:
llvm/test/Transforms/LoopLoadElim/type-mismatch-opaque-ptr.ll
llvm/test/Transforms/LoopLoadElim/type-mismatch.ll
Removed:
################################################################################
diff --git a/llvm/test/Transforms/LoopLoadElim/type-mismatch-opaque-ptr.ll b/llvm/test/Transforms/LoopLoadElim/type-mismatch-opaque-ptr.ll
index 126805462ab11..b1fb13f2f9f60 100644
--- a/llvm/test/Transforms/LoopLoadElim/type-mismatch-opaque-ptr.ll
+++ b/llvm/test/Transforms/LoopLoadElim/type-mismatch-opaque-ptr.ll
@@ -1,3 +1,4 @@
+; NOTE: Assertions have been autogenerated by utils/update_test_checks.py
; RUN: opt --opaque-pointers -loop-load-elim -S < %s | FileCheck %s
; Don't crash if the store and the load use
diff erent types.
@@ -9,9 +10,29 @@
target datalayout = "e-m:o-i64:64-f80:128-n8:16:32:64-S128"
-; CHECK-LABEL: @f(
define void @f(ptr noalias %A, ptr noalias %B, ptr noalias %C, i64 %N) {
-
+; CHECK-LABEL: @f(
+; CHECK-NEXT: entry:
+; CHECK-NEXT: br label [[FOR_BODY:%.*]]
+; CHECK: for.body:
+; CHECK-NEXT: [[INDVARS_IV:%.*]] = phi i64 [ 0, [[ENTRY:%.*]] ], [ [[INDVARS_IV_NEXT:%.*]], [[FOR_BODY]] ]
+; CHECK-NEXT: [[INDVARS_IV_NEXT]] = add nuw nsw i64 [[INDVARS_IV]], 1
+; CHECK-NEXT: [[AIDX_NEXT:%.*]] = getelementptr inbounds i32, ptr [[A:%.*]], i64 [[INDVARS_IV_NEXT]]
+; CHECK-NEXT: [[BIDX:%.*]] = getelementptr inbounds i32, ptr [[B:%.*]], i64 [[INDVARS_IV]]
+; CHECK-NEXT: [[CIDX:%.*]] = getelementptr inbounds i32, ptr [[C:%.*]], i64 [[INDVARS_IV]]
+; CHECK-NEXT: [[AIDX:%.*]] = getelementptr inbounds i32, ptr [[A]], i64 [[INDVARS_IV]]
+; CHECK-NEXT: [[B:%.*]] = load i32, ptr [[BIDX]], align 4
+; CHECK-NEXT: [[A_P1:%.*]] = add i32 [[B]], 2
+; CHECK-NEXT: store i32 [[A_P1]], ptr [[AIDX_NEXT]], align 4
+; CHECK-NEXT: [[A:%.*]] = load float, ptr [[AIDX]], align 4
+; CHECK-NEXT: [[C:%.*]] = fmul float [[A]], 2.000000e+00
+; CHECK-NEXT: [[C_INT:%.*]] = fptosi float [[C]] to i32
+; CHECK-NEXT: store i32 [[C_INT]], ptr [[CIDX]], align 4
+; CHECK-NEXT: [[EXITCOND:%.*]] = icmp eq i64 [[INDVARS_IV_NEXT]], [[N:%.*]]
+; CHECK-NEXT: br i1 [[EXITCOND]], label [[FOR_END:%.*]], label [[FOR_BODY]]
+; CHECK: for.end:
+; CHECK-NEXT: ret void
+;
entry:
br label %for.body
@@ -28,9 +49,7 @@ for.body: ; preds = %for.body, %entry
%a_p1 = add i32 %b, 2
store i32 %a_p1, ptr %Aidx_next, align 4
-; CHECK: %a = load float, ptr %Aidx, align 4
%a = load float, ptr %Aidx, align 4
-; CHECK-NEXT: %c = fmul float %a, 2.0
%c = fmul float %a, 2.0
%c.int = fptosi float %c to i32
store i32 %c.int, ptr %Cidx, align 4
@@ -50,9 +69,31 @@ for.end: ; preds = %for.body
; C[i] = ((float*)A)[i] * 2;
; }
-; CHECK-LABEL: @f2(
define void @f2(ptr noalias %A, ptr noalias %B, ptr noalias %C, i64 %N) {
-
+; CHECK-LABEL: @f2(
+; CHECK-NEXT: entry:
+; CHECK-NEXT: br label [[FOR_BODY:%.*]]
+; CHECK: for.body:
+; CHECK-NEXT: [[INDVARS_IV:%.*]] = phi i64 [ 0, [[ENTRY:%.*]] ], [ [[INDVARS_IV_NEXT:%.*]], [[FOR_BODY]] ]
+; CHECK-NEXT: [[INDVARS_IV_NEXT]] = add nuw nsw i64 [[INDVARS_IV]], 1
+; CHECK-NEXT: [[AIDX_NEXT:%.*]] = getelementptr inbounds i32, ptr [[A:%.*]], i64 [[INDVARS_IV_NEXT]]
+; CHECK-NEXT: [[BIDX:%.*]] = getelementptr inbounds i32, ptr [[B:%.*]], i64 [[INDVARS_IV]]
+; CHECK-NEXT: [[CIDX:%.*]] = getelementptr inbounds i32, ptr [[C:%.*]], i64 [[INDVARS_IV]]
+; CHECK-NEXT: [[AIDX:%.*]] = getelementptr inbounds i32, ptr [[A]], i64 [[INDVARS_IV]]
+; CHECK-NEXT: [[B:%.*]] = load i32, ptr [[BIDX]], align 4
+; CHECK-NEXT: [[A_P2:%.*]] = add i32 [[B]], 2
+; CHECK-NEXT: store i32 [[A_P2]], ptr [[AIDX_NEXT]], align 4
+; CHECK-NEXT: [[A_P3:%.*]] = add i32 [[B]], 3
+; CHECK-NEXT: store i32 [[A_P3]], ptr [[AIDX_NEXT]], align 4
+; CHECK-NEXT: [[A:%.*]] = load float, ptr [[AIDX]], align 4
+; CHECK-NEXT: [[C:%.*]] = fmul float [[A]], 2.000000e+00
+; CHECK-NEXT: [[C_INT:%.*]] = fptosi float [[C]] to i32
+; CHECK-NEXT: store i32 [[C_INT]], ptr [[CIDX]], align 4
+; CHECK-NEXT: [[EXITCOND:%.*]] = icmp eq i64 [[INDVARS_IV_NEXT]], [[N:%.*]]
+; CHECK-NEXT: br i1 [[EXITCOND]], label [[FOR_END:%.*]], label [[FOR_BODY]]
+; CHECK: for.end:
+; CHECK-NEXT: ret void
+;
entry:
br label %for.body
@@ -72,9 +113,7 @@ for.body: ; preds = %for.body, %entry
%a_p3 = add i32 %b, 3
store i32 %a_p3, ptr %Aidx_next, align 4
-; CHECK: %a = load float, ptr %Aidx, align 4
%a = load float, ptr %Aidx, align 4
-; CHECK-NEXT: %c = fmul float %a, 2.0
%c = fmul float %a, 2.0
%c.int = fptosi float %c to i32
store i32 %c.int, ptr %Cidx, align 4
@@ -85,3 +124,114 @@ for.body: ; preds = %for.body, %entry
for.end: ; preds = %for.body
ret void
}
+
+; Don't crash if the store and the load use
diff erent types.
+
+define void @f3(ptr noalias %A, ptr noalias %B, ptr noalias %C, i64 %N) {
+; CHECK-LABEL: @f3(
+; CHECK-NEXT: entry:
+; CHECK-NEXT: br label [[FOR_BODY:%.*]]
+; CHECK: for.body:
+; CHECK-NEXT: [[INDVARS_IV:%.*]] = phi i64 [ 0, [[ENTRY:%.*]] ], [ [[INDVARS_IV_NEXT:%.*]], [[FOR_BODY]] ]
+; CHECK-NEXT: [[INDVARS_IV_NEXT]] = add nuw nsw i64 [[INDVARS_IV]], 1
+; CHECK-NEXT: [[AIDX_NEXT:%.*]] = getelementptr inbounds i64, ptr [[A:%.*]], i64 [[INDVARS_IV_NEXT]]
+; CHECK-NEXT: [[BIDX:%.*]] = getelementptr inbounds i64, ptr [[B:%.*]], i64 [[INDVARS_IV]]
+; CHECK-NEXT: [[CIDX:%.*]] = getelementptr inbounds i64, ptr [[C:%.*]], i64 [[INDVARS_IV]]
+; CHECK-NEXT: [[AIDX:%.*]] = getelementptr inbounds i64, ptr [[A]], i64 [[INDVARS_IV]]
+; CHECK-NEXT: [[B:%.*]] = load i64, ptr [[BIDX]], align 8
+; CHECK-NEXT: [[A_P1:%.*]] = add i64 [[B]], 2
+; CHECK-NEXT: store i64 [[A_P1]], ptr [[AIDX_NEXT]], align 8
+; CHECK-NEXT: [[A:%.*]] = load ptr, ptr [[AIDX]], align 8
+; CHECK-NEXT: [[C:%.*]] = getelementptr i8, ptr [[A]], i64 57
+; CHECK-NEXT: [[C_I64P:%.*]] = ptrtoint ptr [[C]] to i64
+; CHECK-NEXT: store i64 [[C_I64P]], ptr [[CIDX]], align 8
+; CHECK-NEXT: [[EXITCOND:%.*]] = icmp eq i64 [[INDVARS_IV_NEXT]], [[N:%.*]]
+; CHECK-NEXT: br i1 [[EXITCOND]], label [[FOR_END:%.*]], label [[FOR_BODY]]
+; CHECK: for.end:
+; CHECK-NEXT: ret void
+;
+entry:
+ br label %for.body
+
+for.body: ; preds = %for.body, %entry
+ %indvars.iv = phi i64 [ 0, %entry ], [ %indvars.iv.next, %for.body ]
+ %indvars.iv.next = add nuw nsw i64 %indvars.iv, 1
+
+ %Aidx_next = getelementptr inbounds i64, ptr %A, i64 %indvars.iv.next
+ %Bidx = getelementptr inbounds i64, ptr %B, i64 %indvars.iv
+ %Cidx = getelementptr inbounds i64, ptr %C, i64 %indvars.iv
+ %Aidx = getelementptr inbounds i64, ptr %A, i64 %indvars.iv
+
+ %b = load i64, ptr %Bidx, align 8
+ %a_p1 = add i64 %b, 2
+ store i64 %a_p1, ptr %Aidx_next, align 8
+
+ %a = load ptr, ptr %Aidx , align 8
+ %c = getelementptr i8, ptr %a, i64 57
+ %c.i64p = ptrtoint i8* %c to i64
+ store i64 %c.i64p, ptr %Cidx, align 8
+
+ %exitcond = icmp eq i64 %indvars.iv.next, %N
+ br i1 %exitcond, label %for.end, label %for.body
+
+for.end: ; preds = %for.body
+ ret void
+}
+
+; Don't crash if the store and the load use
diff erent types.
+;
+; for (unsigned i = 0; i < 100; i++) {
+; A[i+1] = B[i] + 2;
+; C[i] = ((float*)A)[i] * 2;
+; }
+
+define void @f4(ptr noalias %A, ptr noalias %B, ptr noalias %C, i64 %N) {
+; CHECK-LABEL: @f4(
+; CHECK-NEXT: entry:
+; CHECK-NEXT: br label [[FOR_BODY:%.*]]
+; CHECK: for.body:
+; CHECK-NEXT: [[INDVARS_IV:%.*]] = phi i64 [ 0, [[ENTRY:%.*]] ], [ [[INDVARS_IV_NEXT:%.*]], [[FOR_BODY]] ]
+; CHECK-NEXT: [[INDVARS_IV_NEXT]] = add nuw nsw i64 [[INDVARS_IV]], 1
+; CHECK-NEXT: [[AIDX_NEXT:%.*]] = getelementptr inbounds i32, ptr [[A:%.*]], i64 [[INDVARS_IV_NEXT]]
+; CHECK-NEXT: [[BIDX:%.*]] = getelementptr inbounds i32, ptr [[B:%.*]], i64 [[INDVARS_IV]]
+; CHECK-NEXT: [[CIDX:%.*]] = getelementptr inbounds i32, ptr [[C:%.*]], i64 [[INDVARS_IV]]
+; CHECK-NEXT: [[AIDX:%.*]] = getelementptr inbounds i32, ptr [[A]], i64 [[INDVARS_IV]]
+; CHECK-NEXT: [[B:%.*]] = load i32, ptr [[BIDX]], align 4
+; CHECK-NEXT: [[A_P1:%.*]] = add i32 [[B]], 2
+; CHECK-NEXT: store i32 [[A_P1]], ptr [[AIDX_NEXT]], align 4
+; CHECK-NEXT: [[A:%.*]] = load <2 x half>, ptr [[AIDX]], align 4
+; CHECK-NEXT: [[C:%.*]] = fmul <2 x half> [[A]], <half 0xH4000, half 0xH4000>
+; CHECK-NEXT: [[C_INT:%.*]] = bitcast <2 x half> [[C]] to i32
+; CHECK-NEXT: store i32 [[C_INT]], ptr [[CIDX]], align 4
+; CHECK-NEXT: [[EXITCOND:%.*]] = icmp eq i64 [[INDVARS_IV_NEXT]], [[N:%.*]]
+; CHECK-NEXT: br i1 [[EXITCOND]], label [[FOR_END:%.*]], label [[FOR_BODY]]
+; CHECK: for.end:
+; CHECK-NEXT: ret void
+;
+entry:
+ br label %for.body
+
+for.body: ; preds = %for.body, %entry
+ %indvars.iv = phi i64 [ 0, %entry ], [ %indvars.iv.next, %for.body ]
+ %indvars.iv.next = add nuw nsw i64 %indvars.iv, 1
+
+ %Aidx_next = getelementptr inbounds i32, ptr %A, i64 %indvars.iv.next
+ %Bidx = getelementptr inbounds i32, ptr %B, i64 %indvars.iv
+ %Cidx = getelementptr inbounds i32, ptr %C, i64 %indvars.iv
+ %Aidx = getelementptr inbounds i32, ptr %A, i64 %indvars.iv
+
+ %b = load i32, ptr %Bidx, align 4
+ %a_p1 = add i32 %b, 2
+ store i32 %a_p1, ptr %Aidx_next, align 4
+
+ %a = load <2 x half>, <2 x half>* %Aidx, align 4
+ %c = fmul <2 x half> %a, <half 2.0, half 2.0>
+ %c.int = bitcast <2 x half> %c to i32
+ store i32 %c.int, ptr %Cidx, align 4
+
+ %exitcond = icmp eq i64 %indvars.iv.next, %N
+ br i1 %exitcond, label %for.end, label %for.body
+
+for.end: ; preds = %for.body
+ ret void
+}
diff --git a/llvm/test/Transforms/LoopLoadElim/type-mismatch.ll b/llvm/test/Transforms/LoopLoadElim/type-mismatch.ll
index ab8029bd35fb1..1702eac4da174 100644
--- a/llvm/test/Transforms/LoopLoadElim/type-mismatch.ll
+++ b/llvm/test/Transforms/LoopLoadElim/type-mismatch.ll
@@ -1,3 +1,4 @@
+; NOTE: Assertions have been autogenerated by utils/update_test_checks.py
; RUN: opt -loop-load-elim -S < %s | FileCheck %s
; Don't crash if the store and the load use
diff erent types.
@@ -9,9 +10,30 @@
target datalayout = "e-m:o-i64:64-f80:128-n8:16:32:64-S128"
-; CHECK-LABEL: @f(
define void @f(i32* noalias %A, i32* noalias %B, i32* noalias %C, i64 %N) {
-
+; CHECK-LABEL: @f(
+; CHECK-NEXT: entry:
+; CHECK-NEXT: br label [[FOR_BODY:%.*]]
+; CHECK: for.body:
+; CHECK-NEXT: [[INDVARS_IV:%.*]] = phi i64 [ 0, [[ENTRY:%.*]] ], [ [[INDVARS_IV_NEXT:%.*]], [[FOR_BODY]] ]
+; CHECK-NEXT: [[INDVARS_IV_NEXT]] = add nuw nsw i64 [[INDVARS_IV]], 1
+; CHECK-NEXT: [[AIDX_NEXT:%.*]] = getelementptr inbounds i32, i32* [[A:%.*]], i64 [[INDVARS_IV_NEXT]]
+; CHECK-NEXT: [[BIDX:%.*]] = getelementptr inbounds i32, i32* [[B:%.*]], i64 [[INDVARS_IV]]
+; CHECK-NEXT: [[CIDX:%.*]] = getelementptr inbounds i32, i32* [[C:%.*]], i64 [[INDVARS_IV]]
+; CHECK-NEXT: [[AIDX:%.*]] = getelementptr inbounds i32, i32* [[A]], i64 [[INDVARS_IV]]
+; CHECK-NEXT: [[AIDX_FLOAT:%.*]] = bitcast i32* [[AIDX]] to float*
+; CHECK-NEXT: [[B:%.*]] = load i32, i32* [[BIDX]], align 4
+; CHECK-NEXT: [[A_P1:%.*]] = add i32 [[B]], 2
+; CHECK-NEXT: store i32 [[A_P1]], i32* [[AIDX_NEXT]], align 4
+; CHECK-NEXT: [[A:%.*]] = load float, float* [[AIDX_FLOAT]], align 4
+; CHECK-NEXT: [[C:%.*]] = fmul float [[A]], 2.000000e+00
+; CHECK-NEXT: [[C_INT:%.*]] = fptosi float [[C]] to i32
+; CHECK-NEXT: store i32 [[C_INT]], i32* [[CIDX]], align 4
+; CHECK-NEXT: [[EXITCOND:%.*]] = icmp eq i64 [[INDVARS_IV_NEXT]], [[N:%.*]]
+; CHECK-NEXT: br i1 [[EXITCOND]], label [[FOR_END:%.*]], label [[FOR_BODY]]
+; CHECK: for.end:
+; CHECK-NEXT: ret void
+;
entry:
br label %for.body
@@ -29,9 +51,7 @@ for.body: ; preds = %for.body, %entry
%a_p1 = add i32 %b, 2
store i32 %a_p1, i32* %Aidx_next, align 4
-; CHECK: %a = load float, float* %Aidx.float, align 4
%a = load float, float* %Aidx.float, align 4
-; CHECK-NEXT: %c = fmul float %a, 2.0
%c = fmul float %a, 2.0
%c.int = fptosi float %c to i32
store i32 %c.int, i32* %Cidx, align 4
@@ -51,9 +71,32 @@ for.end: ; preds = %for.body
; C[i] = ((float*)A)[i] * 2;
; }
-; CHECK-LABEL: @f2(
define void @f2(i32* noalias %A, i32* noalias %B, i32* noalias %C, i64 %N) {
-
+; CHECK-LABEL: @f2(
+; CHECK-NEXT: entry:
+; CHECK-NEXT: br label [[FOR_BODY:%.*]]
+; CHECK: for.body:
+; CHECK-NEXT: [[INDVARS_IV:%.*]] = phi i64 [ 0, [[ENTRY:%.*]] ], [ [[INDVARS_IV_NEXT:%.*]], [[FOR_BODY]] ]
+; CHECK-NEXT: [[INDVARS_IV_NEXT]] = add nuw nsw i64 [[INDVARS_IV]], 1
+; CHECK-NEXT: [[AIDX_NEXT:%.*]] = getelementptr inbounds i32, i32* [[A:%.*]], i64 [[INDVARS_IV_NEXT]]
+; CHECK-NEXT: [[BIDX:%.*]] = getelementptr inbounds i32, i32* [[B:%.*]], i64 [[INDVARS_IV]]
+; CHECK-NEXT: [[CIDX:%.*]] = getelementptr inbounds i32, i32* [[C:%.*]], i64 [[INDVARS_IV]]
+; CHECK-NEXT: [[AIDX:%.*]] = getelementptr inbounds i32, i32* [[A]], i64 [[INDVARS_IV]]
+; CHECK-NEXT: [[AIDX_FLOAT:%.*]] = bitcast i32* [[AIDX]] to float*
+; CHECK-NEXT: [[B:%.*]] = load i32, i32* [[BIDX]], align 4
+; CHECK-NEXT: [[A_P2:%.*]] = add i32 [[B]], 2
+; CHECK-NEXT: store i32 [[A_P2]], i32* [[AIDX_NEXT]], align 4
+; CHECK-NEXT: [[A_P3:%.*]] = add i32 [[B]], 3
+; CHECK-NEXT: store i32 [[A_P3]], i32* [[AIDX_NEXT]], align 4
+; CHECK-NEXT: [[A:%.*]] = load float, float* [[AIDX_FLOAT]], align 4
+; CHECK-NEXT: [[C:%.*]] = fmul float [[A]], 2.000000e+00
+; CHECK-NEXT: [[C_INT:%.*]] = fptosi float [[C]] to i32
+; CHECK-NEXT: store i32 [[C_INT]], i32* [[CIDX]], align 4
+; CHECK-NEXT: [[EXITCOND:%.*]] = icmp eq i64 [[INDVARS_IV_NEXT]], [[N:%.*]]
+; CHECK-NEXT: br i1 [[EXITCOND]], label [[FOR_END:%.*]], label [[FOR_BODY]]
+; CHECK: for.end:
+; CHECK-NEXT: ret void
+;
entry:
br label %for.body
@@ -74,9 +117,7 @@ for.body: ; preds = %for.body, %entry
%a_p3 = add i32 %b, 3
store i32 %a_p3, i32* %Aidx_next, align 4
-; CHECK: %a = load float, float* %Aidx.float, align 4
%a = load float, float* %Aidx.float, align 4
-; CHECK-NEXT: %c = fmul float %a, 2.0
%c = fmul float %a, 2.0
%c.int = fptosi float %c to i32
store i32 %c.int, i32* %Cidx, align 4
@@ -87,3 +128,118 @@ for.body: ; preds = %for.body, %entry
for.end: ; preds = %for.body
ret void
}
+
+; Don't crash if the store and the load use
diff erent types.
+
+define void @f3(i64* noalias %A, i64* noalias %B, i64* noalias %C, i64 %N) {
+; CHECK-LABEL: @f3(
+; CHECK-NEXT: entry:
+; CHECK-NEXT: br label [[FOR_BODY:%.*]]
+; CHECK: for.body:
+; CHECK-NEXT: [[INDVARS_IV:%.*]] = phi i64 [ 0, [[ENTRY:%.*]] ], [ [[INDVARS_IV_NEXT:%.*]], [[FOR_BODY]] ]
+; CHECK-NEXT: [[INDVARS_IV_NEXT]] = add nuw nsw i64 [[INDVARS_IV]], 1
+; CHECK-NEXT: [[AIDX_NEXT:%.*]] = getelementptr inbounds i64, i64* [[A:%.*]], i64 [[INDVARS_IV_NEXT]]
+; CHECK-NEXT: [[BIDX:%.*]] = getelementptr inbounds i64, i64* [[B:%.*]], i64 [[INDVARS_IV]]
+; CHECK-NEXT: [[CIDX:%.*]] = getelementptr inbounds i64, i64* [[C:%.*]], i64 [[INDVARS_IV]]
+; CHECK-NEXT: [[AIDX:%.*]] = getelementptr inbounds i64, i64* [[A]], i64 [[INDVARS_IV]]
+; CHECK-NEXT: [[AIDX_I8P:%.*]] = bitcast i64* [[AIDX]] to i8**
+; CHECK-NEXT: [[B:%.*]] = load i64, i64* [[BIDX]], align 8
+; CHECK-NEXT: [[A_P1:%.*]] = add i64 [[B]], 2
+; CHECK-NEXT: store i64 [[A_P1]], i64* [[AIDX_NEXT]], align 8
+; CHECK-NEXT: [[A:%.*]] = load i8*, i8** [[AIDX_I8P]], align 8
+; CHECK-NEXT: [[C:%.*]] = getelementptr i8, i8* [[A]], i64 57
+; CHECK-NEXT: [[C_I64P:%.*]] = ptrtoint i8* [[C]] to i64
+; CHECK-NEXT: store i64 [[C_I64P]], i64* [[CIDX]], align 8
+; CHECK-NEXT: [[EXITCOND:%.*]] = icmp eq i64 [[INDVARS_IV_NEXT]], [[N:%.*]]
+; CHECK-NEXT: br i1 [[EXITCOND]], label [[FOR_END:%.*]], label [[FOR_BODY]]
+; CHECK: for.end:
+; CHECK-NEXT: ret void
+;
+entry:
+ br label %for.body
+
+for.body: ; preds = %for.body, %entry
+ %indvars.iv = phi i64 [ 0, %entry ], [ %indvars.iv.next, %for.body ]
+ %indvars.iv.next = add nuw nsw i64 %indvars.iv, 1
+
+ %Aidx_next = getelementptr inbounds i64, i64* %A, i64 %indvars.iv.next
+ %Bidx = getelementptr inbounds i64, i64* %B, i64 %indvars.iv
+ %Cidx = getelementptr inbounds i64, i64* %C, i64 %indvars.iv
+ %Aidx = getelementptr inbounds i64, i64* %A, i64 %indvars.iv
+ %Aidx.i8p = bitcast i64* %Aidx to i8**
+
+ %b = load i64, i64* %Bidx, align 8
+ %a_p1 = add i64 %b, 2
+ store i64 %a_p1, i64* %Aidx_next, align 8
+
+ %a = load i8*, i8** %Aidx.i8p, align 8
+ %c = getelementptr i8, i8* %a, i64 57
+ %c.i64p = ptrtoint i8* %c to i64
+ store i64 %c.i64p, i64* %Cidx, align 8
+
+ %exitcond = icmp eq i64 %indvars.iv.next, %N
+ br i1 %exitcond, label %for.end, label %for.body
+
+for.end: ; preds = %for.body
+ ret void
+}
+
+; Don't crash if the store and the load use
diff erent types.
+;
+; for (unsigned i = 0; i < 100; i++) {
+; A[i+1] = B[i] + 2;
+; C[i] = ((float*)A)[i] * 2;
+; }
+
+define void @f4(i32* noalias %A, i32* noalias %B, i32* noalias %C, i64 %N) {
+; CHECK-LABEL: @f4(
+; CHECK-NEXT: entry:
+; CHECK-NEXT: br label [[FOR_BODY:%.*]]
+; CHECK: for.body:
+; CHECK-NEXT: [[INDVARS_IV:%.*]] = phi i64 [ 0, [[ENTRY:%.*]] ], [ [[INDVARS_IV_NEXT:%.*]], [[FOR_BODY]] ]
+; CHECK-NEXT: [[INDVARS_IV_NEXT]] = add nuw nsw i64 [[INDVARS_IV]], 1
+; CHECK-NEXT: [[AIDX_NEXT:%.*]] = getelementptr inbounds i32, i32* [[A:%.*]], i64 [[INDVARS_IV_NEXT]]
+; CHECK-NEXT: [[BIDX:%.*]] = getelementptr inbounds i32, i32* [[B:%.*]], i64 [[INDVARS_IV]]
+; CHECK-NEXT: [[CIDX:%.*]] = getelementptr inbounds i32, i32* [[C:%.*]], i64 [[INDVARS_IV]]
+; CHECK-NEXT: [[AIDX:%.*]] = getelementptr inbounds i32, i32* [[A]], i64 [[INDVARS_IV]]
+; CHECK-NEXT: [[AIDX_FLOAT:%.*]] = bitcast i32* [[AIDX]] to <2 x half>*
+; CHECK-NEXT: [[B:%.*]] = load i32, i32* [[BIDX]], align 4
+; CHECK-NEXT: [[A_P1:%.*]] = add i32 [[B]], 2
+; CHECK-NEXT: store i32 [[A_P1]], i32* [[AIDX_NEXT]], align 4
+; CHECK-NEXT: [[A:%.*]] = load <2 x half>, <2 x half>* [[AIDX_FLOAT]], align 4
+; CHECK-NEXT: [[C:%.*]] = fmul <2 x half> [[A]], <half 0xH4000, half 0xH4000>
+; CHECK-NEXT: [[C_INT:%.*]] = bitcast <2 x half> [[C]] to i32
+; CHECK-NEXT: store i32 [[C_INT]], i32* [[CIDX]], align 4
+; CHECK-NEXT: [[EXITCOND:%.*]] = icmp eq i64 [[INDVARS_IV_NEXT]], [[N:%.*]]
+; CHECK-NEXT: br i1 [[EXITCOND]], label [[FOR_END:%.*]], label [[FOR_BODY]]
+; CHECK: for.end:
+; CHECK-NEXT: ret void
+;
+entry:
+ br label %for.body
+
+for.body: ; preds = %for.body, %entry
+ %indvars.iv = phi i64 [ 0, %entry ], [ %indvars.iv.next, %for.body ]
+ %indvars.iv.next = add nuw nsw i64 %indvars.iv, 1
+
+ %Aidx_next = getelementptr inbounds i32, i32* %A, i64 %indvars.iv.next
+ %Bidx = getelementptr inbounds i32, i32* %B, i64 %indvars.iv
+ %Cidx = getelementptr inbounds i32, i32* %C, i64 %indvars.iv
+ %Aidx = getelementptr inbounds i32, i32* %A, i64 %indvars.iv
+ %Aidx.float = bitcast i32* %Aidx to <2 x half>*
+
+ %b = load i32, i32* %Bidx, align 4
+ %a_p1 = add i32 %b, 2
+ store i32 %a_p1, i32* %Aidx_next, align 4
+
+ %a = load <2 x half>, <2 x half>* %Aidx.float, align 4
+ %c = fmul <2 x half> %a, <half 2.0, half 2.0>
+ %c.int = bitcast <2 x half> %c to i32
+ store i32 %c.int, i32* %Cidx, align 4
+
+ %exitcond = icmp eq i64 %indvars.iv.next, %N
+ br i1 %exitcond, label %for.end, label %for.body
+
+for.end: ; preds = %for.body
+ ret void
+}
More information about the llvm-commits
mailing list