summaryrefslogtreecommitdiff
path: root/llvm/test/CodeGen/ARM
diff options
context:
space:
mode:
authorAustin <zhenhangwang@huawei.com>2025-11-16 03:20:27 +0800
committerAustin <zhenhangwang@huawei.com>2025-11-16 03:20:27 +0800
commit3705921f60914df3cfb59e088cf9e476fe7992b7 (patch)
treefbcac6d8be76365f9cec1814b318116acf115f57 /llvm/test/CodeGen/ARM
parentd3439138e158541b65f3d759f5071a445d3297f2 (diff)
[CodeGen] add a command to force global merge
I found that in some performance scenarios, such as under O2, this pr can be helpful for a series of loading global variables.
Diffstat (limited to 'llvm/test/CodeGen/ARM')
-rw-r--r--llvm/test/CodeGen/ARM/force-global-merge.ll23
1 files changed, 23 insertions, 0 deletions
diff --git a/llvm/test/CodeGen/ARM/force-global-merge.ll b/llvm/test/CodeGen/ARM/force-global-merge.ll
new file mode 100644
index 000000000000..a7b791dc0a63
--- /dev/null
+++ b/llvm/test/CodeGen/ARM/force-global-merge.ll
@@ -0,0 +1,23 @@
+; RUN: llc -mtriple=arm-eabi -force-enable-global-merge %s -o - | FileCheck %s
+
+@g_value1 = dso_local local_unnamed_addr global i32 0, align 4
+@g_value2 = dso_local local_unnamed_addr global i32 0, align 4
+@g_value3 = dso_local local_unnamed_addr global i32 0, align 4
+@g_value4 = dso_local local_unnamed_addr global i32 0, align 4
+
+define dso_local i32 @foo1() local_unnamed_addr {
+entry:
+ %0 = load i32, ptr @g_value1, align 4
+ %1 = load i32, ptr @g_value2, align 4
+ %2 = load i32, ptr @g_value3, align 4
+ %3 = load i32, ptr @g_value4, align 4
+ %call = tail call i32 @foo(i32 %0, i32 %1, i32 %2, i32 %3)
+ ret i32 %call
+}
+
+declare i32 @foo(i32, i32, i32, i32)
+
+; CHECK: ldr [[BASE:r[0-9]+]], .LCPI0_0
+; CHECK: ldm [[BASE]], {[[R0:r[0-9]+]], [[R1:r[0-9]+]], [[R2:r[0-9]+]], [[R3:r[0-9]+]]}
+; CHECK: .LCPI0_0:
+; CHECK-NEXT: .long .L_MergedGlobals