[llvm] [LLVM][CodeGen] Update PPCFastISel::SelectRet for ConstantInt based vectors. (PR #159331)
via llvm-commits
llvm-commits at lists.llvm.org
Wed Sep 17 04:47:01 PDT 2025
llvmbot wrote:
<!--LLVM PR SUMMARY COMMENT-->
@llvm/pr-subscribers-backend-powerpc
Author: Paul Walker (paulwalker-arm)
<details>
<summary>Changes</summary>
The current implementation assumes ConstantInt return values are scalar, which is not true when use-constant-int-for-fixed-length-splat is enabled.
---
Full diff: https://github.com/llvm/llvm-project/pull/159331.diff
2 Files Affected:
- (modified) llvm/lib/Target/PowerPC/PPCFastISel.cpp (+2-1)
- (modified) llvm/test/CodeGen/PowerPC/vec_constants.ll (+4)
``````````diff
diff --git a/llvm/lib/Target/PowerPC/PPCFastISel.cpp b/llvm/lib/Target/PowerPC/PPCFastISel.cpp
index 0b68ba12e337f..ea4e597d0fd7d 100644
--- a/llvm/lib/Target/PowerPC/PPCFastISel.cpp
+++ b/llvm/lib/Target/PowerPC/PPCFastISel.cpp
@@ -1707,7 +1707,8 @@ bool PPCFastISel::SelectRet(const Instruction *I) {
// Special case for returning a constant integer of any size - materialize
// the constant as an i64 and copy it to the return register.
- if (const ConstantInt *CI = dyn_cast<ConstantInt>(RV)) {
+ if (isa<ConstantInt>(RV) && RV->getType()->isIntegerTy()) {
+ const ConstantInt *CI = cast<ConstantInt>(RV);
CCValAssign &VA = ValLocs[0];
Register RetReg = VA.getLocReg();
diff --git a/llvm/test/CodeGen/PowerPC/vec_constants.ll b/llvm/test/CodeGen/PowerPC/vec_constants.ll
index 3c14c14e06568..2b448fd05aeb5 100644
--- a/llvm/test/CodeGen/PowerPC/vec_constants.ll
+++ b/llvm/test/CodeGen/PowerPC/vec_constants.ll
@@ -3,6 +3,10 @@
; RUN: llc -verify-machineinstrs -O0 -mcpu=pwr7 -mtriple=powerpc64-ibm-aix-xcoff -vec-extabi < %s | FileCheck %s --check-prefixes=CHECK,BE
; RUN: llc -verify-machineinstrs -O0 -mcpu=pwr7 -mtriple=powerpc64le-unknown-linux-gnu < %s | FileCheck %s --check-prefixes=CHECK,LE
+; RUN: llc -verify-machineinstrs -O0 -mcpu=pwr7 -mtriple=powerpc64-unknown-linux-gnu -use-constant-int-for-fixed-length-splat -use-constant-fp-for-fixed-length-splat < %s | FileCheck %s --check-prefixes=CHECK,BE
+; RUN: llc -verify-machineinstrs -O0 -mcpu=pwr7 -mtriple=powerpc64-ibm-aix-xcoff -vec-extabi -use-constant-int-for-fixed-length-splat -use-constant-fp-for-fixed-length-splat < %s | FileCheck %s --check-prefixes=CHECK,BE
+; RUN: llc -verify-machineinstrs -O0 -mcpu=pwr7 -mtriple=powerpc64le-unknown-linux-gnu -use-constant-int-for-fixed-length-splat -use-constant-fp-for-fixed-length-splat < %s | FileCheck %s --check-prefixes=CHECK,LE
+
define void @test1(ptr %P1, ptr %P2, ptr %P3) nounwind {
; BE-LABEL: test1:
; BE: # %bb.0:
``````````
</details>
https://github.com/llvm/llvm-project/pull/159331
More information about the llvm-commits
mailing list