llvm.org GIT mirror llvm / 9fa366d
Merging r327651: ------------------------------------------------------------------------ r327651 | carrot | 2018-03-15 10:49:12 -0700 (Thu, 15 Mar 2018) | 9 lines [PPC] Avoid non-simple MVT in STBRX optimization PR35402 triggered this case. It bswap and stores a 48bit value, current STBRX optimization transforms it into STBRX. Unfortunately 48bit is not a simple MVT, there is no PPC instruction to support it, and it can't be automatically expanded by llvm, so caused a crash. This patch detects the non-simple MVT and returns early. Differential Revision: https://reviews.llvm.org/D44500 ------------------------------------------------------------------------ git-svn-id: https://llvm.org/svn/llvm-project/llvm/branches/release_60@329641 91177308-0d34-0410-b5e6-96231b3b80d8 Tom Stellard 2 years ago
2 changed file(s) with 23 addition(s) and 1 deletion(s). Raw diff Collapse all Expand all
1226312263 N->getOperand(1).getValueType() == MVT::i16 ||
1226412264 (Subtarget.hasLDBRX() && Subtarget.isPPC64() &&
1226512265 N->getOperand(1).getValueType() == MVT::i64))) {
12266 // STBRX can only handle simple types.
12267 EVT mVT = cast(N)->getMemoryVT();
12268 if (mVT.isExtended())
12269 break;
12270
1226612271 SDValue BSwapOp = N->getOperand(1).getOperand(0);
1226712272 // Do an any-extend to 32-bits if this is a half-word input.
1226812273 if (BSwapOp.getValueType() == MVT::i16)
1227012275
1227112276 // If the type of BSWAP operand is wider than stored memory width
1227212277 // it need to be shifted to the right side before STBRX.
12273 EVT mVT = cast(N)->getMemoryVT();
1227412278 if (Op1VT.bitsGT(mVT)) {
1227512279 int Shift = Op1VT.getSizeInBits() - mVT.getSizeInBits();
1227612280 BSwapOp = DAG.getNode(ISD::SRL, dl, Op1VT, BSwapOp,
0 ; RUN: llc -O2 < %s | FileCheck %s
1 target triple = "powerpc64le-linux-gnu"
2
3 define void @test(i8* %p, i64 %data) {
4 entry:
5 %0 = tail call i64 @llvm.bswap.i64(i64 %data)
6 %ptr = bitcast i8* %p to i48*
7 %val = trunc i64 %0 to i48
8 store i48 %val, i48* %ptr, align 1
9 ret void
10
11 ; CHECK: sth
12 ; CHECK: stw
13 ; CHECK-NOT: stdbrx
14
15 }
16
17 declare i64 @llvm.bswap.i64(i64)