[llvm] 8e757b2 - [LICM] Adding the test as a precommit for the D113289
Djordje Todorovic via llvm-commits
llvm-commits at lists.llvm.org
Thu Dec 2 03:38:47 PST 2021
Author: Djordje Todorovic
Date: 2021-12-02T03:38:14-08:00
New Revision: 8e757b2383c90d81bc9661fd4ac070931a679ace
URL: https://github.com/llvm/llvm-project/commit/8e757b2383c90d81bc9661fd4ac070931a679ace
DIFF: https://github.com/llvm/llvm-project/commit/8e757b2383c90d81bc9661fd4ac070931a679ace.diff
LOG: [LICM] Adding the test as a precommit for the D113289
Added:
llvm/test/Transforms/LICM/hoist-load-without-store.ll
Modified:
Removed:
################################################################################
diff --git a/llvm/test/Transforms/LICM/hoist-load-without-store.ll b/llvm/test/Transforms/LICM/hoist-load-without-store.ll
new file mode 100644
index 0000000000000..b464f6b7328dd
--- /dev/null
+++ b/llvm/test/Transforms/LICM/hoist-load-without-store.ll
@@ -0,0 +1,66 @@
+; NOTE: Assertions have been autogenerated by utils/update_test_checks.py
+; RUN: opt -licm -S < %s | FileCheck %s
+
+;; C reproducer:
+;; void f(int *ptr, int n) {
+;; for (int i = 0; i < n; ++i) {
+;; int x = *ptr;
+;; if (x)
+;; break;
+;;
+;; *ptr = x + 1;
+;; }
+;; }
+
+define dso_local void @f(i32* nocapture %ptr, i32 %n) {
+; CHECK-LABEL: @f(
+; CHECK-NEXT: entry:
+; CHECK-NEXT: [[CMP7:%.*]] = icmp slt i32 0, [[N:%.*]]
+; CHECK-NEXT: br i1 [[CMP7]], label [[FOR_BODY_LR_PH:%.*]], label [[CLEANUP1:%.*]]
+; CHECK: for.body.lr.ph:
+; CHECK-NEXT: br label [[FOR_BODY:%.*]]
+; CHECK: for.body:
+; CHECK-NEXT: [[I_08:%.*]] = phi i32 [ 0, [[FOR_BODY_LR_PH]] ], [ [[INC:%.*]], [[IF_END:%.*]] ]
+; CHECK-NEXT: [[TMP0:%.*]] = load i32, i32* [[PTR:%.*]], align 4
+; CHECK-NEXT: [[TOBOOL_NOT:%.*]] = icmp eq i32 [[TMP0]], 0
+; CHECK-NEXT: br i1 [[TOBOOL_NOT]], label [[IF_END]], label [[FOR_BODY_CLEANUP1_CRIT_EDGE:%.*]]
+; CHECK: if.end:
+; CHECK-NEXT: store i32 1, i32* [[PTR]], align 4
+; CHECK-NEXT: [[INC]] = add nuw nsw i32 [[I_08]], 1
+; CHECK-NEXT: [[CMP:%.*]] = icmp slt i32 [[INC]], [[N]]
+; CHECK-NEXT: br i1 [[CMP]], label [[FOR_BODY]], label [[FOR_COND_CLEANUP1_CRIT_EDGE:%.*]]
+; CHECK: for.body.cleanup1_crit_edge:
+; CHECK-NEXT: br label [[CLEANUP1]]
+; CHECK: for.cond.cleanup1_crit_edge:
+; CHECK-NEXT: br label [[CLEANUP1]]
+; CHECK: cleanup1:
+; CHECK-NEXT: ret void
+;
+entry:
+ %cmp7 = icmp slt i32 0, %n
+ br i1 %cmp7, label %for.body.lr.ph, label %cleanup1
+
+for.body.lr.ph: ; preds = %entry
+ br label %for.body
+
+for.body: ; preds = %for.body.lr.ph, %if.end
+ %i.08 = phi i32 [ 0, %for.body.lr.ph ], [ %inc, %if.end ]
+ %0 = load i32, i32* %ptr, align 4
+ %tobool.not = icmp eq i32 %0, 0
+ br i1 %tobool.not, label %if.end, label %for.body.cleanup1_crit_edge
+
+if.end: ; preds = %for.body
+ store i32 1, i32* %ptr, align 4
+ %inc = add nuw nsw i32 %i.08, 1
+ %cmp = icmp slt i32 %inc, %n
+ br i1 %cmp, label %for.body, label %for.cond.cleanup1_crit_edge
+
+for.body.cleanup1_crit_edge: ; preds = %for.body
+ br label %cleanup1
+
+for.cond.cleanup1_crit_edge: ; preds = %if.end
+ br label %cleanup1
+
+cleanup1: ; preds = %for.cond.cleanup1_crit_edge, %for.body.cleanup1_crit_edge, %entry
+ ret void
+}
More information about the llvm-commits
mailing list