[llvm] [LICM] Fix dropped metadata (PR #95221)
Tim Gymnich via llvm-commits
llvm-commits at lists.llvm.org
Wed Jun 12 05:58:04 PDT 2024
https://github.com/tgymnich updated https://github.com/llvm/llvm-project/pull/95221
>From ac5501cbe1014233b06e9c8fe48b81768732155d Mon Sep 17 00:00:00 2001
From: Tim Gymnich <tgymnich at icloud.com>
Date: Wed, 12 Jun 2024 14:40:54 +0200
Subject: [PATCH 1/3] add test
---
llvm/test/Transforms/LICM/licm-ci.ll | 43 ++++++++++++++++++++++++++++
1 file changed, 43 insertions(+)
create mode 100644 llvm/test/Transforms/LICM/licm-ci.ll
diff --git a/llvm/test/Transforms/LICM/licm-ci.ll b/llvm/test/Transforms/LICM/licm-ci.ll
new file mode 100644
index 0000000000000..91d3dd4b72050
--- /dev/null
+++ b/llvm/test/Transforms/LICM/licm-ci.ll
@@ -0,0 +1,43 @@
+; NOTE: Assertions have been autogenerated by utils/update_test_checks.py
+; RUN: opt -S -passes=licm < %s | FileCheck %s
+
+define void @vmp_test_vmp(ptr addrspace(3) noalias %in1, i32 %y.0, ptr addrspace(3) noalias %in2, ptr addrspace(3) noalias %in3, ptr addrspace(3) noalias %in4, ptr noalias nocapture writeonly %sum1.0.lcssa.out, ptr noalias nocapture writeonly %sum2.0.lcssa.out, ptr noalias nocapture writeonly %sum3.0.lcssa.out, ptr noalias nocapture writeonly %sum4.0.lcssa.out) local_unnamed_addr #2 {
+; CHECK-LABEL: @vmp_test_vmp(
+; CHECK-NEXT: one.iter.loop.entry15:
+; CHECK-NEXT: br label [[ONE_ITER_LOOP_ENTRY:%.*]]
+; CHECK: one.iter.loop.entry:
+; CHECK-NEXT: [[ONE_ITER_IV:%.*]] = phi i32 [ 0, [[ONE_ITER_LOOP_ENTRY15:%.*]] ], [ [[ONE_ITER_IV_NEXT:%.*]], [[ONE_ITER_LOOP_ENTRY]] ]
+; CHECK-NEXT: [[ONE_ITER_IV_NEXT]] = add i32 [[ONE_ITER_IV]], 1
+; CHECK-NEXT: [[TMP0:%.*]] = icmp eq i32 [[ONE_ITER_IV_NEXT]], 1
+; CHECK-NEXT: br i1 [[TMP0]], label [[ONE_ITER_LOOP_EXIT:%.*]], label [[ONE_ITER_LOOP_ENTRY]]
+; CHECK: one.iter.loop.exit:
+; CHECK-NEXT: [[MUL_LE:%.*]] = mul nsw i32 [[Y_0:%.*]], 48
+; CHECK-NEXT: [[TMP1:%.*]] = getelementptr inbounds i16, ptr addrspace(3) [[IN1:%.*]], i32 [[MUL_LE]]
+; CHECK-NEXT: [[WIDE_MASKED_LOAD_LE:%.*]] = tail call <4 x i16> @llvm.masked.load.v4i16.p3(ptr addrspace(3) [[TMP1]], i32 2, <4 x i1> <i1 true, i1 false, i1 true, i1 false>, <4 x i16> <i16 0, i16 poison, i16 0, i16 poison>)
+; CHECK-NEXT: [[TMP2:%.*]] = tail call i16 @llvm.vector.reduce.add.v4i16(<4 x i16> [[WIDE_MASKED_LOAD_LE]])
+; CHECK-NEXT: store i16 [[TMP2]], ptr [[SUM1_0_LCSSA_OUT:%.*]], align 4
+; CHECK-NEXT: ret void
+;
+one.iter.loop.entry15:
+ br label %one.iter.loop.entry
+
+one.iter.loop.entry: ; preds = %one.iter.loop.entry, %one.iter.loop.entry15
+ %one.iter.iv = phi i32 [ 0, %one.iter.loop.entry15 ], [ %one.iter.iv.next, %one.iter.loop.entry ]
+ %mul = mul nsw i32 %y.0, 48
+ %0 = getelementptr inbounds i16, ptr addrspace(3) %in1, i32 %mul
+ %wide.masked.load = tail call <4 x i16> @llvm.masked.load.v4i16.p3(ptr addrspace(3) %0, i32 2, <4 x i1> <i1 true, i1 false, i1 true, i1 false>, <4 x i16> <i16 0, i16 poison, i16 0, i16 poison>), !alias.scope !1, !noalias !2
+
+ %2 = tail call i16 @llvm.vector.reduce.add.v4i16(<4 x i16> %wide.masked.load)
+
+ %one.iter.iv.next = add i32 %one.iter.iv, 1
+ %16 = icmp eq i32 %one.iter.iv.next, 1
+ br i1 %16, label %one.iter.loop.exit, label %one.iter.loop.entry
+
+one.iter.loop.exit: ; preds = %one.iter.loop.entry
+ %.lcssa18 = phi i16 [ %2, %one.iter.loop.entry ]
+ store i16 %.lcssa18, ptr %sum1.0.lcssa.out, align 4
+ ret void
+}
+
+!1 = !{}
+!2 = !{}
>From 80862bc616922975bea565013eb791405254e6d3 Mon Sep 17 00:00:00 2001
From: Tim Gymnich <tgymnich at icloud.com>
Date: Tue, 11 Jun 2024 23:38:44 +0200
Subject: [PATCH 2/3] Fix dropped metadata in LICM
---
llvm/lib/Transforms/Scalar/LICM.cpp | 1 +
1 file changed, 1 insertion(+)
diff --git a/llvm/lib/Transforms/Scalar/LICM.cpp b/llvm/lib/Transforms/Scalar/LICM.cpp
index 5eccf7b4adb65..75883e0da214d 100644
--- a/llvm/lib/Transforms/Scalar/LICM.cpp
+++ b/llvm/lib/Transforms/Scalar/LICM.cpp
@@ -1453,6 +1453,7 @@ static Instruction *cloneInstructionInExitBlock(
}
New = CallInst::Create(CI, OpBundles);
+ New->copyMetadata(*CI);
} else {
New = I.clone();
}
>From 771f1c1604c3b24042a16cd081b5d21beff70d30 Mon Sep 17 00:00:00 2001
From: Tim Gymnich <tgymnich at icloud.com>
Date: Wed, 12 Jun 2024 14:57:13 +0200
Subject: [PATCH 3/3] update test
---
llvm/test/Transforms/LICM/licm-ci.ll | 2 +-
1 file changed, 1 insertion(+), 1 deletion(-)
diff --git a/llvm/test/Transforms/LICM/licm-ci.ll b/llvm/test/Transforms/LICM/licm-ci.ll
index 91d3dd4b72050..34b19af2681a5 100644
--- a/llvm/test/Transforms/LICM/licm-ci.ll
+++ b/llvm/test/Transforms/LICM/licm-ci.ll
@@ -13,7 +13,7 @@ define void @vmp_test_vmp(ptr addrspace(3) noalias %in1, i32 %y.0, ptr addrspace
; CHECK: one.iter.loop.exit:
; CHECK-NEXT: [[MUL_LE:%.*]] = mul nsw i32 [[Y_0:%.*]], 48
; CHECK-NEXT: [[TMP1:%.*]] = getelementptr inbounds i16, ptr addrspace(3) [[IN1:%.*]], i32 [[MUL_LE]]
-; CHECK-NEXT: [[WIDE_MASKED_LOAD_LE:%.*]] = tail call <4 x i16> @llvm.masked.load.v4i16.p3(ptr addrspace(3) [[TMP1]], i32 2, <4 x i1> <i1 true, i1 false, i1 true, i1 false>, <4 x i16> <i16 0, i16 poison, i16 0, i16 poison>)
+; CHECK-NEXT: [[WIDE_MASKED_LOAD_LE:%.*]] = tail call <4 x i16> @llvm.masked.load.v4i16.p3(ptr addrspace(3) [[TMP1]], i32 2, <4 x i1> <i1 true, i1 false, i1 true, i1 false>, <4 x i16> <i16 0, i16 poison, i16 0, i16 poison>), !alias.scope [[META0:![0-9]+]], !noalias [[META0]]
; CHECK-NEXT: [[TMP2:%.*]] = tail call i16 @llvm.vector.reduce.add.v4i16(<4 x i16> [[WIDE_MASKED_LOAD_LE]])
; CHECK-NEXT: store i16 [[TMP2]], ptr [[SUM1_0_LCSSA_OUT:%.*]], align 4
; CHECK-NEXT: ret void
More information about the llvm-commits
mailing list