[llvm] [Loads] Pass DominatorTree if available (PR #95752)
Nikita Popov via llvm-commits
llvm-commits at lists.llvm.org
Tue Jun 18 00:20:23 PDT 2024
================
@@ -0,0 +1,63 @@
+; NOTE: Assertions have been autogenerated by utils/update_test_checks.py
+; RUN: opt -passes=licm -S < %s | FileCheck %s
+
+define dso_local void @f(i32 %ptr_i, ptr %ptr2, i32 %n, i32 %n2) {
+; CHECK-LABEL: @f(
+; CHECK-NEXT: entry:
+; CHECK-NEXT: [[CMP7:%.*]] = icmp slt i32 0, [[N:%.*]]
+; CHECK-NEXT: [[PTR:%.*]] = inttoptr i32 [[PTR_I:%.*]] to ptr
+; CHECK-NEXT: call void @llvm.assume(i1 true) [ "align"(ptr [[PTR]], i32 16), "dereferenceable"(ptr [[PTR]], i32 16) ]
+; CHECK-NEXT: br i1 [[CMP7]], label [[FOR_BODY_LR_PH:%.*]], label [[IF0:%.*]]
+; CHECK: if0:
+; CHECK-NEXT: store i32 0, ptr [[PTR2:%.*]], align 4
+; CHECK-NEXT: br label [[FOR_BODY_LR_PH]]
+; CHECK: for.body.lr.ph:
+; CHECK-NEXT: [[TOBOOL_NOT:%.*]] = icmp eq i32 [[N2:%.*]], 0
+; CHECK-NEXT: [[TMP0:%.*]] = load i32, ptr [[PTR]], align 4
+; 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: br i1 [[TOBOOL_NOT]], label [[IF_END]], label [[IF:%.*]]
+; CHECK: if:
+; CHECK-NEXT: store i32 [[TMP0]], ptr [[PTR2]], align 4
+; CHECK-NEXT: br label [[IF_END]]
+; CHECK: if.end:
+; 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 [[EXIT:%.*]]
+; CHECK: exit:
+; CHECK-NEXT: ret void
+;
+entry:
+ %cmp7 = icmp slt i32 0, %n
+ %ptr = inttoptr i32 %ptr_i to ptr
+ call void @llvm.assume(i1 true) [ "align"(ptr %ptr, i32 16), "dereferenceable"(ptr %ptr, i32 16) ]
+ br i1 %cmp7, label %for.body.lr.ph, label %if0
----------------
nikic wrote:
Is it possible to drop the loop precondition? It doesn't look like it's needed. (If nothing else, replace `%n` with positive constant.)
https://github.com/llvm/llvm-project/pull/95752
More information about the llvm-commits
mailing list