[llvm] 3e60d21 - [LoopDistribute] Add tests inspired by PR50296, PR50288.
Florian Hahn via llvm-commits
llvm-commits at lists.llvm.org
Thu Sep 2 00:19:52 PDT 2021
Author: Florian Hahn
Date: 2021-09-02T09:17:32+02:00
New Revision: 3e60d216a4829a0e9a5045afa3e060f89ea18b04
URL: https://github.com/llvm/llvm-project/commit/3e60d216a4829a0e9a5045afa3e060f89ea18b04
DIFF: https://github.com/llvm/llvm-project/commit/3e60d216a4829a0e9a5045afa3e060f89ea18b04.diff
LOG: [LoopDistribute] Add tests inspired by PR50296, PR50288.
Added:
llvm/test/Transforms/LoopDistribute/pointer-phi-in-loop.ll
Modified:
Removed:
################################################################################
diff --git a/llvm/test/Transforms/LoopDistribute/pointer-phi-in-loop.ll b/llvm/test/Transforms/LoopDistribute/pointer-phi-in-loop.ll
new file mode 100644
index 0000000000000..89c284832ef1f
--- /dev/null
+++ b/llvm/test/Transforms/LoopDistribute/pointer-phi-in-loop.ll
@@ -0,0 +1,100 @@
+; NOTE: Assertions have been autogenerated by utils/update_test_checks.py
+; RUN: opt -aa-pipeline=basic-aa -passes='loop-distribute' -enable-loop-distribute -S %s | FileCheck %s
+
+; Testcases inspired by PR50296, PR50288.
+
+define void @phi_load_store_distribute(i1 %c, i16* %A, i16* %B, i16* %C) {
+; CHECK-LABEL: @phi_load_store_distribute(
+; CHECK-NEXT: entry:
+; CHECK-NEXT: br label [[FOR_BODY:%.*]]
+; CHECK: for.body:
+; CHECK-NEXT: [[IV:%.*]] = phi i16 [ 0, [[ENTRY:%.*]] ], [ [[IV_NEXT:%.*]], [[IF_END:%.*]] ]
+; CHECK-NEXT: [[LV:%.*]] = load i16, i16* [[A:%.*]], align 1
+; CHECK-NEXT: store i16 [[LV]], i16* [[A]], align 1
+; CHECK-NEXT: br i1 [[C:%.*]], label [[IF_THEN:%.*]], label [[IF_END]]
+; CHECK: if.then:
+; CHECK-NEXT: [[LV2:%.*]] = load i16, i16* [[A]], align 1
+; CHECK-NEXT: br label [[IF_END]]
+; CHECK: if.end:
+; CHECK-NEXT: [[C_SINK:%.*]] = phi i16* [ [[B:%.*]], [[IF_THEN]] ], [ [[C:%.*]], [[FOR_BODY]] ]
+; CHECK-NEXT: [[LV3:%.*]] = load i16, i16* [[C_SINK]], align 2
+; CHECK-NEXT: [[ADD:%.*]] = add i16 [[LV3]], 10
+; CHECK-NEXT: store i16 [[ADD]], i16* [[C_SINK]], align 1
+; CHECK-NEXT: [[IV_NEXT]] = add nuw nsw i16 [[IV]], 1
+; CHECK-NEXT: [[TOBOOL_NOT:%.*]] = icmp eq i16 [[IV_NEXT]], 1000
+; CHECK-NEXT: br i1 [[TOBOOL_NOT]], label [[FOR_END_LOOPEXIT:%.*]], label [[FOR_BODY]]
+; CHECK: for.end.loopexit:
+; CHECK-NEXT: ret void
+;
+entry:
+ br label %for.body
+
+for.body: ; preds = %if.end, %entry
+ %iv = phi i16 [ 0, %entry ], [ %iv.next, %if.end ]
+ %lv = load i16, i16* %A, align 1
+ store i16 %lv, i16* %A, align 1
+ br i1 %c, label %if.then, label %if.end
+
+if.then: ; preds = %for.body
+ %lv2 = load i16, i16* %A, align 1
+ br label %if.end
+
+if.end: ; preds = %if.then, %for.body
+ %c.sink = phi i16* [ %B, %if.then ], [ %C, %for.body ]
+ %lv3 = load i16, i16* %c.sink
+ %add = add i16 %lv3, 10
+ store i16 %add, i16* %c.sink, align 1
+ %iv.next = add nuw nsw i16 %iv, 1
+ %tobool.not = icmp eq i16 %iv.next, 1000
+ br i1 %tobool.not, label %for.end.loopexit, label %for.body
+
+for.end.loopexit: ; preds = %if.end
+ ret void
+}
+
+define void @phi_load_distribute(i1 %c, i16* %A, i16* %B, i16* %C) {
+; CHECK-LABEL: @phi_load_distribute(
+; CHECK-NEXT: entry:
+; CHECK-NEXT: br label [[FOR_BODY:%.*]]
+; CHECK: for.body:
+; CHECK-NEXT: [[IV:%.*]] = phi i16 [ 0, [[ENTRY:%.*]] ], [ [[IV_NEXT:%.*]], [[IF_END:%.*]] ]
+; CHECK-NEXT: [[LV:%.*]] = load i16, i16* [[A:%.*]], align 1
+; CHECK-NEXT: store i16 [[LV]], i16* [[A]], align 1
+; CHECK-NEXT: br i1 [[C:%.*]], label [[IF_THEN:%.*]], label [[IF_END]]
+; CHECK: if.then:
+; CHECK-NEXT: [[LV2:%.*]] = load i16, i16* [[A]], align 1
+; CHECK-NEXT: br label [[IF_END]]
+; CHECK: if.end:
+; CHECK-NEXT: [[C_SINK:%.*]] = phi i16* [ [[B:%.*]], [[IF_THEN]] ], [ [[C:%.*]], [[FOR_BODY]] ]
+; CHECK-NEXT: [[LV3:%.*]] = load i16, i16* [[C_SINK]], align 2
+; CHECK-NEXT: [[IV_NEXT]] = add nuw nsw i16 [[IV]], 1
+; CHECK-NEXT: [[TOBOOL_NOT:%.*]] = icmp eq i16 [[IV_NEXT]], 1000
+; CHECK-NEXT: br i1 [[TOBOOL_NOT]], label [[FOR_END_LOOPEXIT:%.*]], label [[FOR_BODY]]
+; CHECK: for.end.loopexit:
+; CHECK-NEXT: ret void
+;
+entry:
+ br label %for.body
+
+for.body: ; preds = %if.end, %entry
+ %iv = phi i16 [ 0, %entry ], [ %iv.next, %if.end ]
+ %lv = load i16, i16* %A, align 1
+ store i16 %lv, i16* %A, align 1
+ br i1 %c, label %if.then, label %if.end
+
+if.then: ; preds = %for.body
+ %lv2 = load i16, i16* %A, align 1
+ br label %if.end
+
+if.end: ; preds = %if.then, %for.body
+ %c.sink = phi i16* [ %B, %if.then ], [ %C, %for.body ]
+ %lv3 = load i16, i16* %c.sink
+ %iv.next = add nuw nsw i16 %iv, 1
+ %tobool.not = icmp eq i16 %iv.next, 1000
+ br i1 %tobool.not, label %for.end.loopexit, label %for.body
+
+for.end.loopexit: ; preds = %if.end
+ ret void
+}
+
+
More information about the llvm-commits
mailing list