[llvm] [LoopFusion] Forget loop and block dispositions after latch merge (PR #166233)
via llvm-commits
llvm-commits at lists.llvm.org
Tue Nov 4 09:29:36 PST 2025
================
@@ -0,0 +1,62 @@
+; RUN: opt -passes=loop-fusion -disable-output -stats < %s 2>&1 | FileCheck -check-prefix=STAT %s
+; STAT: 1 loop-fusion - Loops fused
+
+; C Code
+;
+;; for (int i = 0; i < 100; ++i)
+;; Array[i][i] = -i;
+;; for (int row = 0; row < 100; ++row)
+;; for (int col = 0; col < 100; ++col)
+;; if (col != row)
+;; Array[row][col] = row + col;
+
+
+define i32 @forget_dispositions() nounwind {
+entry:
+ %Array = alloca [100 x [100 x i32]], align 4
+ br label %for.body
+
+for.body: ; preds = %for.body, %entry
+ %indvars.iv33 = phi i64 [ 0, %entry ], [ %indvars.iv.next34, %for.body ]
+ %0 = trunc i64 %indvars.iv33 to i32
+ %sub = sub i32 0, %0
+ %arrayidx2 = getelementptr inbounds [100 x [100 x i32]], ptr %Array, i64 0, i64 %indvars.iv33, i64 %indvars.iv33
+ store i32 %sub, ptr %arrayidx2, align 4
+ %indvars.iv.next34 = add i64 %indvars.iv33, 1
+ %lftr.wideiv35 = trunc i64 %indvars.iv.next34 to i32
+ %exitcond36 = icmp eq i32 %lftr.wideiv35, 100
+ br i1 %exitcond36, label %for.cond6.preheader, label %for.body
+
+for.cond6.preheader: ; preds = %for.body, %for.inc17
+ %indvars.iv29 = phi i64 [ %indvars.iv.next30, %for.inc17 ], [ 0, %for.body ]
+ br label %for.body8
+
+for.body8: ; preds = %for.inc14, %for.cond6.preheader
+ %indvars.iv = phi i64 [ 0, %for.cond6.preheader ], [ %indvars.iv.next, %for.inc14 ]
+ %1 = trunc i64 %indvars.iv to i32
+ %2 = trunc i64 %indvars.iv29 to i32
----------------
CongzheUalberta wrote:
Could you simplify the test IR? For example you may get rid of all `trunc` instructions.
https://github.com/llvm/llvm-project/pull/166233
More information about the llvm-commits
mailing list