Skip to content

Commit b7e4edc

Browse files
[LLVM][CodeGen] Update PPCFastISel::SelectRet for ConstantInt based vectors. (#159331)
The current implementation assumes ConstantInt return values are scalar, which is not true when use-constant-int-for-fixed-length-splat is enabled.
1 parent eed99d5 commit b7e4edc

File tree

2 files changed

+6
-1
lines changed

2 files changed

+6
-1
lines changed

llvm/lib/Target/PowerPC/PPCFastISel.cpp

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1707,7 +1707,8 @@ bool PPCFastISel::SelectRet(const Instruction *I) {
17071707

17081708
// Special case for returning a constant integer of any size - materialize
17091709
// the constant as an i64 and copy it to the return register.
1710-
if (const ConstantInt *CI = dyn_cast<ConstantInt>(RV)) {
1710+
if (isa<ConstantInt>(RV) && RV->getType()->isIntegerTy()) {
1711+
const ConstantInt *CI = cast<ConstantInt>(RV);
17111712
CCValAssign &VA = ValLocs[0];
17121713

17131714
Register RetReg = VA.getLocReg();

llvm/test/CodeGen/PowerPC/vec_constants.ll

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -3,6 +3,10 @@
33
; RUN: llc -verify-machineinstrs -O0 -mcpu=pwr7 -mtriple=powerpc64-ibm-aix-xcoff -vec-extabi < %s | FileCheck %s --check-prefixes=CHECK,BE
44
; RUN: llc -verify-machineinstrs -O0 -mcpu=pwr7 -mtriple=powerpc64le-unknown-linux-gnu < %s | FileCheck %s --check-prefixes=CHECK,LE
55

6+
; 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
7+
; 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
8+
; 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
9+
610
define void @test1(ptr %P1, ptr %P2, ptr %P3) nounwind {
711
; BE-LABEL: test1:
812
; BE: # %bb.0:

0 commit comments

Comments
 (0)