llvm-project/llvm/test/CodeGen/RISCV/global-merge-minsize-smalldata-nonzero.ll
Alex Bradbury 3787fbf040
[RISCV] Enable merging of external globals by default (#117880)
This follows up #115495 by enabling merging of external globals by
default, which had been left as a next step in order to make the
previous change more incremental and so we can more easily narrow down
on any identified regressions.

Enabling merging of external globals matches what Arm does (for non
mach-o targets), though AArch64 doesn't as there were [some
concerns](https://reviews.llvm.org/D61947) it might cause regressions in
some cases.

See https://github.com/llvm/llvm-project/pull/117880 for benchmark figures and discussion.
2024-12-11 16:06:49 +00:00

49 lines
1.6 KiB
LLVM

; NOTE: Assertions have been autogenerated by utils/update_llc_test_checks.py
; RUN: llc -mtriple=riscv64 -verify-machineinstrs < %s \
; RUN: | FileCheck %s -check-prefix=SMALL-DATA
; RUN: llc -mtriple=riscv64 -global-merge-min-data-size=0 -verify-machineinstrs < %s \
; RUN: | FileCheck %s -check-prefix=MINSIZE
@ig1 = internal global i32 0, align 4
@ig2 = internal global i32 0, align 4
@eg1 = dso_local global i32 0, align 4
@eg2 = dso_local global i32 0, align 4
; This test shows that GlobalDataMinSize is set to SmallDataLimit + 1 when
; SmallDataLimit module flag is set as non-zero, and that global-merge-min-data-size
; overrides the small data limit.
define void @f1(i32 %a) nounwind {
; SMALL-DATA-LABEL: f1:
; SMALL-DATA: # %bb.0:
; SMALL-DATA-NEXT: lui a1, %hi(ig1)
; SMALL-DATA-NEXT: sw a0, %lo(ig1)(a1)
; SMALL-DATA-NEXT: lui a1, %hi(ig2)
; SMALL-DATA-NEXT: sw a0, %lo(ig2)(a1)
; SMALL-DATA-NEXT: lui a1, %hi(eg1)
; SMALL-DATA-NEXT: sw a0, %lo(eg1)(a1)
; SMALL-DATA-NEXT: lui a1, %hi(eg2)
; SMALL-DATA-NEXT: sw a0, %lo(eg2)(a1)
; SMALL-DATA-NEXT: ret
;
; MINSIZE-LABEL: f1:
; MINSIZE: # %bb.0:
; MINSIZE-NEXT: lui a1, %hi(.L_MergedGlobals)
; MINSIZE-NEXT: sw a0, %lo(.L_MergedGlobals)(a1)
; MINSIZE-NEXT: addi a1, a1, %lo(.L_MergedGlobals)
; MINSIZE-NEXT: sw a0, 4(a1)
; MINSIZE-NEXT: sw a0, 8(a1)
; MINSIZE-NEXT: sw a0, 12(a1)
; MINSIZE-NEXT: ret
store i32 %a, ptr @ig1, align 4
store i32 %a, ptr @ig2, align 4
store i32 %a, ptr @eg1, align 4
store i32 %a, ptr @eg2, align 4
ret void
}
!llvm.module.flags = !{!0}
!0 = !{i32 8, !"SmallDataLimit", i32 8}