Skip to content

Commit 9429165

Browse files
topperctstellar
authored andcommitted
[PowerPC] Use getSignedTargetConstant in SelectOptimalAddrMode. (llvm#127305)
Fixes llvm#127298. (cherry picked from commit 256145b)
1 parent 8b73dad commit 9429165

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
@@ -19050,8 +19050,8 @@ PPC::AddrMode PPCTargetLowering::SelectOptimalAddrMode(const SDNode *Parent,
1905019050
int32_t Addr = (int32_t)CNImm;
1905119051
// Otherwise, break this down into LIS + Disp.
1905219052
Disp = DAG.getSignedTargetConstant((int16_t)Addr, DL, MVT::i32);
19053-
Base =
19054-
DAG.getTargetConstant((Addr - (int16_t)Addr) >> 16, DL, MVT::i32);
19053+
Base = DAG.getSignedTargetConstant((Addr - (int16_t)Addr) >> 16, DL,
19054+
MVT::i32);
1905519055
uint32_t LIS = CNType == MVT::i32 ? PPC::LIS : PPC::LIS8;
1905619056
Base = SDValue(DAG.getMachineNode(LIS, DL, CNType, Base), 0);
1905719057
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)