Skip to content

Commit 052c5bf

Browse files
committed
[PPC] Do not emit extswsli in 32BIT mode when using -mcpu=pwr9
It looks like in some circumstances when compiling with `-mcpu=pwr9` we create an EXTSWSLI node when which causes llc to fail. No such error occurs in pwr8 or lower. This occurs in 32BIT AIX and BE Linux. the cause seems to be that the default return in combineSHL is to create an EXTSWSLI node. Adding a check for whether we are in PPC64 before that fixes the issue. Reviewed By: #powerpc, nemanjai Differential Revision: https://reviews.llvm.org/D87046
1 parent 2c394bd commit 052c5bf

File tree

2 files changed

+31
-3
lines changed

2 files changed

+31
-3
lines changed

llvm/lib/Target/PowerPC/PPCISelLowering.cpp

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -16322,10 +16322,10 @@ SDValue PPCTargetLowering::combineSHL(SDNode *N, DAGCombinerInfo &DCI) const {
1632216322

1632316323
SDValue N0 = N->getOperand(0);
1632416324
ConstantSDNode *CN1 = dyn_cast<ConstantSDNode>(N->getOperand(1));
16325-
if (!Subtarget.isISA3_0() ||
16325+
if (!Subtarget.isISA3_0() || !Subtarget.isPPC64() ||
1632616326
N0.getOpcode() != ISD::SIGN_EXTEND ||
16327-
N0.getOperand(0).getValueType() != MVT::i32 ||
16328-
CN1 == nullptr || N->getValueType(0) != MVT::i64)
16327+
N0.getOperand(0).getValueType() != MVT::i32 || CN1 == nullptr ||
16328+
N->getValueType(0) != MVT::i64)
1632916329
return SDValue();
1633016330

1633116331
// We can't save an operation here if the value is already extended, and
Lines changed: 28 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,28 @@
1+
; NOTE: Assertions have been autogenerated by utils/update_llc_test_checks.py
2+
; RUN: llc -verify-machineinstrs -mtriple=powerpc \
3+
; RUN: -mcpu=pwr9 < %s | FileCheck %s --check-prefix=32BIT
4+
5+
; RUN: llc -verify-machineinstrs -mtriple=powerpc64 \
6+
; RUN: -mcpu=pwr9 < %s | FileCheck %s --check-prefix=64BIT
7+
8+
define dso_local void @foo(i32 %inta, i64* %long_intb) {
9+
entry:
10+
%conv = sext i32 %inta to i64
11+
%shl = shl nsw i64 %conv, 8
12+
store i64 %shl, i64* %long_intb, align 8
13+
ret void
14+
}
15+
16+
; CHECK-LABEL: foo:
17+
18+
; 32BIT-DAG: srawi [[REG1:[0-9]+]], [[REG2:[0-9]+]], 31
19+
; 32BIT-DAG: rotlwi [[REG3:[0-9]+]], [[REG2]], 8
20+
; 32BIT-DAG: slwi [[REG4:[0-9]+]], [[REG2]], 8
21+
; 32BIT-DAG: rlwimi [[REG5:[0-9]+]], [[REG1]], 8, 0, 23
22+
; 32BIT-DAG: stw [[REG4]], 4([[REG6:[0-9]+]])
23+
; 32BIT-DAG: stw [[REG5]], 0([[REG6]])
24+
; 32BIT: blr
25+
26+
; 64BIT: extswsli [[REG1:[0-9]+]], [[REG2:[0-9]+]], 8
27+
; 64BIT-NEXT: std [[REG1]], 0([[REG3:[0-9]+]])
28+
; 64BIT-NEXT: blr

0 commit comments

Comments
 (0)