Skip to content

Commit 256145b

Browse files
authored
[PowerPC] Use getSignedTargetConstant in SelectOptimalAddrMode. (#127305)
Fixes #127298.
1 parent e5f5517 commit 256145b

File tree

2 files changed

+15
-2
lines changed

2 files changed

+15
-2
lines changed

Diff for: llvm/lib/Target/PowerPC/PPCISelLowering.cpp

+2-2
Original file line numberDiff line numberDiff line change
@@ -19110,8 +19110,8 @@ PPC::AddrMode PPCTargetLowering::SelectOptimalAddrMode(const SDNode *Parent,
1911019110
int32_t Addr = (int32_t)CNImm;
1911119111
// Otherwise, break this down into LIS + Disp.
1911219112
Disp = DAG.getSignedTargetConstant((int16_t)Addr, DL, MVT::i32);
19113-
Base =
19114-
DAG.getTargetConstant((Addr - (int16_t)Addr) >> 16, DL, MVT::i32);
19113+
Base = DAG.getSignedTargetConstant((Addr - (int16_t)Addr) >> 16, DL,
19114+
MVT::i32);
1911519115
uint32_t LIS = CNType == MVT::i32 ? PPC::LIS : PPC::LIS8;
1911619116
Base = SDValue(DAG.getMachineNode(LIS, DL, CNType, Base), 0);
1911719117
break;

Diff for: llvm/test/CodeGen/PowerPC/pr127298.ll

+13
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,13 @@
1+
; NOTE: Assertions have been autogenerated by utils/update_llc_test_checks.py UTC_ARGS: --version 5
2+
; RUN: llc < %s -mtriple=powerpc | FileCheck %s
3+
4+
define void @foo() {
5+
; CHECK-LABEL: foo:
6+
; CHECK: # %bb.0: # %Entry
7+
; CHECK-NEXT: lis 3, -8530
8+
; CHECK-NEXT: lbz 3, -16657(3)
9+
; CHECK-NEXT: blr
10+
Entry:
11+
%0 = load volatile i8, ptr inttoptr (i32 -559038737 to ptr), align 1
12+
ret void
13+
}

0 commit comments

Comments
 (0)