[llvm] [NFC][PowerPC] Pre-commit to optimize bswap64 builtin for power8 (PR #181776)
via llvm-commits
llvm-commits at lists.llvm.org
Mon Feb 16 21:52:24 PST 2026
llvmbot wrote:
<!--LLVM PR SUMMARY COMMENT-->
@llvm/pr-subscribers-backend-powerpc
Author: None (Himadhith)
<details>
<summary>Changes</summary>
The current codegen (for power 8 targets specifically) does not make use of the parallelism and does most of the operations sequentially. It will enhance the performance and also save us instructions.
This will be optimized in a future patch which will follow this NFC PR.
---
Full diff: https://github.com/llvm/llvm-project/pull/181776.diff
1 Files Affected:
- (added) llvm/test/CodeGen/PowerPC/p8-optimize-bswap64.ll (+24)
``````````diff
diff --git a/llvm/test/CodeGen/PowerPC/p8-optimize-bswap64.ll b/llvm/test/CodeGen/PowerPC/p8-optimize-bswap64.ll
new file mode 100644
index 0000000000000..135cf3b3a5e93
--- /dev/null
+++ b/llvm/test/CodeGen/PowerPC/p8-optimize-bswap64.ll
@@ -0,0 +1,24 @@
+; NOTE: Assertions have been autogenerated by utils/update_llc_test_checks.py UTC_ARGS: --version 6
+; RUN: llc -verify-machineinstrs -mcpu=pwr8 -mtriple=powerpc64-ibm-aix \
+; RUN: -ppc-asm-full-reg-names --ppc-vsr-nums-as-vr < %s | FileCheck %s
+define noundef i64 @swap8_openxl(i64 noundef %value) local_unnamed_addr #0 {
+; CHECK-LABEL: swap8_openxl:
+; CHECK: # %bb.0: # %entry
+; CHECK-NEXT: rotldi r5, r3, 16
+; CHECK-NEXT: rotldi r4, r3, 8
+; CHECK-NEXT: rldimi r4, r5, 8, 48
+; CHECK-NEXT: rotldi r5, r3, 24
+; CHECK-NEXT: rldimi r4, r5, 16, 40
+; CHECK-NEXT: rotldi r5, r3, 32
+; CHECK-NEXT: rldimi r4, r5, 24, 32
+; CHECK-NEXT: rotldi r5, r3, 48
+; CHECK-NEXT: rldimi r4, r5, 40, 16
+; CHECK-NEXT: rotldi r5, r3, 56
+; CHECK-NEXT: rldimi r4, r5, 48, 8
+; CHECK-NEXT: rldimi r4, r3, 56, 0
+; CHECK-NEXT: mr r3, r4
+; CHECK-NEXT: blr
+entry:
+ %0 = tail call i64 @llvm.bswap.i64(i64 %value)
+ ret i64 %0
+}
``````````
</details>
https://github.com/llvm/llvm-project/pull/181776
More information about the llvm-commits
mailing list