From ed2b7b7b1ced2b24ba9fa86646488ce49ca58ff3 Mon Sep 17 00:00:00 2001 From: zhijian Date: Thu, 3 Jul 2025 15:31:34 -0400 Subject: [PATCH 1/2] [PowerPC] Pre-commit test case to ensure that milicode is not used for memcmp, but instead a library call is used on AIX OS --- llvm/test/CodeGen/PowerPC/memintr32.ll | 26 ++++++++++++ llvm/test/CodeGen/PowerPC/memintr64.ll | 59 ++++++++++++++++++++++++++ 2 files changed, 85 insertions(+) create mode 100644 llvm/test/CodeGen/PowerPC/memintr32.ll create mode 100644 llvm/test/CodeGen/PowerPC/memintr64.ll diff --git a/llvm/test/CodeGen/PowerPC/memintr32.ll b/llvm/test/CodeGen/PowerPC/memintr32.ll new file mode 100644 index 0000000000000..d80ecb412727e --- /dev/null +++ b/llvm/test/CodeGen/PowerPC/memintr32.ll @@ -0,0 +1,26 @@ +; NOTE: Assertions have been autogenerated by utils/update_llc_test_checks.py UTC_ARGS: --version 5 +; RUN: llc -verify-machineinstrs -mcpu=pwr9 -ppc-asm-full-reg-names -mtriple=powerpc-ibm-aix < %s | \ +; RUN: FileCheck %s --check-prefix=CHECK-AIX-32-P9 + + +define i32 @memcmp_test(ptr nocapture noundef readonly %ptr1, ptr nocapture noundef readonly %ptr2, i32 noundef %num) local_unnamed_addr { +; CHECK-AIX-32-P9-LABEL: memcmp_test: +; CHECK-AIX-32-P9: # %bb.0: # %entry +; CHECK-AIX-32-P9-NEXT: mflr r0 +; CHECK-AIX-32-P9-NEXT: stwu r1, -64(r1) +; CHECK-AIX-32-P9-NEXT: stw r0, 72(r1) +; CHECK-AIX-32-P9-NEXT: bl .memcmp[PR] +; CHECK-AIX-32-P9-NEXT: nop +; CHECK-AIX-32-P9-NEXT: addi r1, r1, 64 +; CHECK-AIX-32-P9-NEXT: lwz r0, 8(r1) +; CHECK-AIX-32-P9-NEXT: mtlr r0 +; CHECK-AIX-32-P9-NEXT: blr +entry: + %call = tail call i32 @memcmp(ptr noundef %ptr1, ptr noundef %ptr2, i32 noundef %num) + ret i32 %call +} + +declare i32 @memcmp(ptr noundef captures(none), ptr noundef captures(none), i32 noundef) local_unnamed_addr + + + diff --git a/llvm/test/CodeGen/PowerPC/memintr64.ll b/llvm/test/CodeGen/PowerPC/memintr64.ll new file mode 100644 index 0000000000000..adf0ea16de3db --- /dev/null +++ b/llvm/test/CodeGen/PowerPC/memintr64.ll @@ -0,0 +1,59 @@ +; NOTE: Assertions have been autogenerated by utils/update_llc_test_checks.py UTC_ARGS: --version 5 +; RUN: llc -verify-machineinstrs -mcpu=pwr9 -ppc-asm-full-reg-names \ +; RUN: -mtriple=powerpc64le-unknown-linux-gnu < %s | \ +; RUN: FileCheck %s --check-prefix=CHECK-LE-P9 +; RUN: llc -verify-machineinstrs -mcpu=pwr9 -ppc-asm-full-reg-names \ +; RUN: -mtriple=powerpc64-unknown-linux-gnu < %s | \ +; RUN: FileCheck %s --check-prefix=CHECK-BE-P9 +; RUN: llc -verify-machineinstrs -mcpu=pwr9 -ppc-asm-full-reg-names \ +; RUN: -mtriple=powerpc64-ibm-aix < %s | \ +; RUN: FileCheck %s --check-prefix=CHECK-AIX-64-P9 + +define noundef i32 @_Z11memcmp_testPKvS0_m(ptr noundef readonly captures(none) %ptr1, ptr noundef readonly captures(none) %ptr2, i64 noundef %num) local_unnamed_addr { +; CHECK-LE-P9-LABEL: _Z11memcmp_testPKvS0_m: +; CHECK-LE-P9: # %bb.0: # %entry +; CHECK-LE-P9-NEXT: mflr r0 +; CHECK-LE-P9-NEXT: stdu r1, -32(r1) +; CHECK-LE-P9-NEXT: std r0, 48(r1) +; CHECK-LE-P9-NEXT: .cfi_def_cfa_offset 32 +; CHECK-LE-P9-NEXT: .cfi_offset lr, 16 +; CHECK-LE-P9-NEXT: bl memcmp +; CHECK-LE-P9-NEXT: nop +; CHECK-LE-P9-NEXT: addi r1, r1, 32 +; CHECK-LE-P9-NEXT: ld r0, 16(r1) +; CHECK-LE-P9-NEXT: mtlr r0 +; CHECK-LE-P9-NEXT: blr +; +; CHECK-BE-P9-LABEL: _Z11memcmp_testPKvS0_m: +; CHECK-BE-P9: # %bb.0: # %entry +; CHECK-BE-P9-NEXT: mflr r0 +; CHECK-BE-P9-NEXT: stdu r1, -112(r1) +; CHECK-BE-P9-NEXT: std r0, 128(r1) +; CHECK-BE-P9-NEXT: .cfi_def_cfa_offset 112 +; CHECK-BE-P9-NEXT: .cfi_offset lr, 16 +; CHECK-BE-P9-NEXT: bl memcmp +; CHECK-BE-P9-NEXT: nop +; CHECK-BE-P9-NEXT: addi r1, r1, 112 +; CHECK-BE-P9-NEXT: ld r0, 16(r1) +; CHECK-BE-P9-NEXT: mtlr r0 +; CHECK-BE-P9-NEXT: blr +; +; CHECK-AIX-64-P9-LABEL: _Z11memcmp_testPKvS0_m: +; CHECK-AIX-64-P9: # %bb.0: # %entry +; CHECK-AIX-64-P9-NEXT: mflr r0 +; CHECK-AIX-64-P9-NEXT: stdu r1, -112(r1) +; CHECK-AIX-64-P9-NEXT: std r0, 128(r1) +; CHECK-AIX-64-P9-NEXT: bl .memcmp[PR] +; CHECK-AIX-64-P9-NEXT: nop +; CHECK-AIX-64-P9-NEXT: addi r1, r1, 112 +; CHECK-AIX-64-P9-NEXT: ld r0, 16(r1) +; CHECK-AIX-64-P9-NEXT: mtlr r0 +; CHECK-AIX-64-P9-NEXT: blr +entry: + %call = tail call i32 @memcmp(ptr noundef %ptr1, ptr noundef %ptr2, i64 noundef %num) + ret i32 %call +} + +declare i32 @memcmp(ptr noundef captures(none), ptr noundef captures(none), i64 noundef) local_unnamed_addr + + From ab1b33fecd25e989a94a878523705461c7d68853 Mon Sep 17 00:00:00 2001 From: zhijian Date: Fri, 4 Jul 2025 11:33:14 -0400 Subject: [PATCH 2/2] address comment --- llvm/test/CodeGen/PowerPC/memintr32.ll | 17 +++++++++++++++-- llvm/test/CodeGen/PowerPC/memintr64.ll | 8 ++------ 2 files changed, 17 insertions(+), 8 deletions(-) diff --git a/llvm/test/CodeGen/PowerPC/memintr32.ll b/llvm/test/CodeGen/PowerPC/memintr32.ll index d80ecb412727e..c07a5af17e48a 100644 --- a/llvm/test/CodeGen/PowerPC/memintr32.ll +++ b/llvm/test/CodeGen/PowerPC/memintr32.ll @@ -2,8 +2,10 @@ ; RUN: llc -verify-machineinstrs -mcpu=pwr9 -ppc-asm-full-reg-names -mtriple=powerpc-ibm-aix < %s | \ ; RUN: FileCheck %s --check-prefix=CHECK-AIX-32-P9 +; RUN: llc -verify-machineinstrs -mcpu=pwr9 -ppc-asm-full-reg-names -mtriple=powerpc-unknown-linux-gnu < %s | \ +; RUN: FileCheck %s --check-prefix=CHECK-LINUX32-P9 -define i32 @memcmp_test(ptr nocapture noundef readonly %ptr1, ptr nocapture noundef readonly %ptr2, i32 noundef %num) local_unnamed_addr { +define i32 @memcmp_test(ptr nocapture noundef readonly %ptr1, ptr nocapture noundef readonly %ptr2, i32 noundef %num) nounwind { ; CHECK-AIX-32-P9-LABEL: memcmp_test: ; CHECK-AIX-32-P9: # %bb.0: # %entry ; CHECK-AIX-32-P9-NEXT: mflr r0 @@ -15,12 +17,23 @@ define i32 @memcmp_test(ptr nocapture noundef readonly %ptr1, ptr nocapture noun ; CHECK-AIX-32-P9-NEXT: lwz r0, 8(r1) ; CHECK-AIX-32-P9-NEXT: mtlr r0 ; CHECK-AIX-32-P9-NEXT: blr +; +; CHECK-LINUX32-P9-LABEL: memcmp_test: +; CHECK-LINUX32-P9: # %bb.0: # %entry +; CHECK-LINUX32-P9-NEXT: mflr r0 +; CHECK-LINUX32-P9-NEXT: stwu r1, -16(r1) +; CHECK-LINUX32-P9-NEXT: stw r0, 20(r1) +; CHECK-LINUX32-P9-NEXT: bl memcmp +; CHECK-LINUX32-P9-NEXT: lwz r0, 20(r1) +; CHECK-LINUX32-P9-NEXT: addi r1, r1, 16 +; CHECK-LINUX32-P9-NEXT: mtlr r0 +; CHECK-LINUX32-P9-NEXT: blr entry: %call = tail call i32 @memcmp(ptr noundef %ptr1, ptr noundef %ptr2, i32 noundef %num) ret i32 %call } -declare i32 @memcmp(ptr noundef captures(none), ptr noundef captures(none), i32 noundef) local_unnamed_addr +declare i32 @memcmp(ptr noundef captures(none), ptr noundef captures(none), i32 noundef) nounwind diff --git a/llvm/test/CodeGen/PowerPC/memintr64.ll b/llvm/test/CodeGen/PowerPC/memintr64.ll index adf0ea16de3db..b3a6650b8f6e6 100644 --- a/llvm/test/CodeGen/PowerPC/memintr64.ll +++ b/llvm/test/CodeGen/PowerPC/memintr64.ll @@ -9,14 +9,12 @@ ; RUN: -mtriple=powerpc64-ibm-aix < %s | \ ; RUN: FileCheck %s --check-prefix=CHECK-AIX-64-P9 -define noundef i32 @_Z11memcmp_testPKvS0_m(ptr noundef readonly captures(none) %ptr1, ptr noundef readonly captures(none) %ptr2, i64 noundef %num) local_unnamed_addr { +define noundef i32 @_Z11memcmp_testPKvS0_m(ptr noundef readonly captures(none) %ptr1, ptr noundef readonly captures(none) %ptr2, i64 noundef %num) nounwind { ; CHECK-LE-P9-LABEL: _Z11memcmp_testPKvS0_m: ; CHECK-LE-P9: # %bb.0: # %entry ; CHECK-LE-P9-NEXT: mflr r0 ; CHECK-LE-P9-NEXT: stdu r1, -32(r1) ; CHECK-LE-P9-NEXT: std r0, 48(r1) -; CHECK-LE-P9-NEXT: .cfi_def_cfa_offset 32 -; CHECK-LE-P9-NEXT: .cfi_offset lr, 16 ; CHECK-LE-P9-NEXT: bl memcmp ; CHECK-LE-P9-NEXT: nop ; CHECK-LE-P9-NEXT: addi r1, r1, 32 @@ -29,8 +27,6 @@ define noundef i32 @_Z11memcmp_testPKvS0_m(ptr noundef readonly captures(none) % ; CHECK-BE-P9-NEXT: mflr r0 ; CHECK-BE-P9-NEXT: stdu r1, -112(r1) ; CHECK-BE-P9-NEXT: std r0, 128(r1) -; CHECK-BE-P9-NEXT: .cfi_def_cfa_offset 112 -; CHECK-BE-P9-NEXT: .cfi_offset lr, 16 ; CHECK-BE-P9-NEXT: bl memcmp ; CHECK-BE-P9-NEXT: nop ; CHECK-BE-P9-NEXT: addi r1, r1, 112 @@ -54,6 +50,6 @@ entry: ret i32 %call } -declare i32 @memcmp(ptr noundef captures(none), ptr noundef captures(none), i64 noundef) local_unnamed_addr +declare i32 @memcmp(ptr noundef captures(none), ptr noundef captures(none), i64 noundef) nounwind