[llvm] [IR] Initial introduction of memset_pattern (PR #97583)
Nikita Popov via llvm-commits
llvm-commits at lists.llvm.org
Wed Sep 18 07:30:36 PDT 2024
================
@@ -0,0 +1,253 @@
+; NOTE: Assertions have been autogenerated by utils/update_llc_test_checks.py UTC_ARGS: --version 5
+; RUN: llc < %s -mtriple=riscv32 -mattr=+m \
+; RUN: | FileCheck %s --check-prefixes=RV32-BOTH,RV32
+; RUN: llc < %s -mtriple=riscv64 -mattr=+m \
+; RUN: | FileCheck %s --check-prefixes=RV64-BOTH,RV64
+; RUN: llc < %s -mtriple=riscv32 -mattr=+m,+unaligned-scalar-mem \
+; RUN: | FileCheck %s --check-prefixes=RV32-BOTH,RV32-FAST
+; RUN: llc < %s -mtriple=riscv64 -mattr=+m,+unaligned-scalar-mem \
+; RUN: | FileCheck %s --check-prefixes=RV64-BOTH,RV64-FAST
+
+; TODO: Due to the initial naive lowering implementation of memset.pattern in
+; PreISelIntrinsicLowering, the generated code is not good.
+
+define void @memset_1(ptr %a, i128 %value) nounwind {
+; RV32-BOTH-LABEL: memset_1:
+; RV32-BOTH: # %bb.0: # %storeloop.preheader
+; RV32-BOTH-NEXT: lw a2, 12(a1)
+; RV32-BOTH-NEXT: lw a3, 8(a1)
+; RV32-BOTH-NEXT: lw a4, 4(a1)
+; RV32-BOTH-NEXT: lw a1, 0(a1)
+; RV32-BOTH-NEXT: addi a5, a0, 16
+; RV32-BOTH-NEXT: .LBB0_1: # %storeloop
+; RV32-BOTH-NEXT: # =>This Inner Loop Header: Depth=1
+; RV32-BOTH-NEXT: sw a1, 0(a0)
+; RV32-BOTH-NEXT: sw a4, 4(a0)
+; RV32-BOTH-NEXT: sw a3, 8(a0)
+; RV32-BOTH-NEXT: sw a2, 12(a0)
+; RV32-BOTH-NEXT: addi a0, a0, 16
+; RV32-BOTH-NEXT: bne a0, a5, .LBB0_1
+; RV32-BOTH-NEXT: # %bb.2: # %split
+; RV32-BOTH-NEXT: ret
+;
+; RV64-BOTH-LABEL: memset_1:
+; RV64-BOTH: # %bb.0: # %storeloop.preheader
+; RV64-BOTH-NEXT: addi a3, a0, 16
+; RV64-BOTH-NEXT: .LBB0_1: # %storeloop
+; RV64-BOTH-NEXT: # =>This Inner Loop Header: Depth=1
+; RV64-BOTH-NEXT: sd a1, 0(a0)
+; RV64-BOTH-NEXT: sd a2, 8(a0)
+; RV64-BOTH-NEXT: addi a0, a0, 16
+; RV64-BOTH-NEXT: bne a0, a3, .LBB0_1
+; RV64-BOTH-NEXT: # %bb.2: # %split
+; RV64-BOTH-NEXT: ret
+ tail call void @llvm.memset.pattern(ptr align 8 %a, i128 %value, i64 1, i1 0)
----------------
nikic wrote:
For reference, I implemented support for that in https://github.com/llvm/llvm-project/pull/89172.
https://github.com/llvm/llvm-project/pull/97583
More information about the llvm-commits
mailing list