Skip to content

[PowerPC][Backend] using signed extend value instead of zero extend value for isIntS34Immediate() #118703

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Merged
merged 3 commits into from
Dec 5, 2024
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
8 changes: 4 additions & 4 deletions llvm/lib/Target/PowerPC/PPCISelLowering.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -2703,7 +2703,7 @@ bool llvm::isIntS34Immediate(SDNode *N, int64_t &Imm) {
if (!isa<ConstantSDNode>(N))
return false;

Imm = (int64_t)N->getAsZExtVal();
Imm = (int64_t)cast<ConstantSDNode>(N)->getSExtValue();
return isInt<34>(Imm);
}
bool llvm::isIntS34Immediate(SDValue Op, int64_t &Imm) {
Expand Down Expand Up @@ -2925,7 +2925,7 @@ bool PPCTargetLowering::SelectAddressRegImm34(SDValue N, SDValue &Disp,
if (N.getOpcode() == ISD::ADD) {
if (!isIntS34Immediate(N.getOperand(1), Imm))
return false;
Disp = DAG.getTargetConstant(Imm, dl, N.getValueType());
Disp = DAG.getSignedTargetConstant(Imm, dl, N.getValueType());
if (FrameIndexSDNode *FI = dyn_cast<FrameIndexSDNode>(N.getOperand(0)))
Base = DAG.getTargetFrameIndex(FI->getIndex(), N.getValueType());
else
Expand All @@ -2946,12 +2946,12 @@ bool PPCTargetLowering::SelectAddressRegImm34(SDValue N, SDValue &Disp,
Base = DAG.getTargetFrameIndex(FI->getIndex(), N.getValueType());
else
Base = N.getOperand(0);
Disp = DAG.getTargetConstant(Imm, dl, N.getValueType());
Disp = DAG.getSignedTargetConstant(Imm, dl, N.getValueType());
return true;
}

if (isIntS34Immediate(N, Imm)) { // If the address is a 34-bit const.
Disp = DAG.getTargetConstant(Imm, dl, N.getValueType());
Disp = DAG.getSignedTargetConstant(Imm, dl, N.getValueType());
Base = DAG.getRegister(PPC::ZERO8, N.getValueType());
return true;
}
Expand Down
17 changes: 17 additions & 0 deletions llvm/test/CodeGen/PowerPC/pr118695.ll
Original file line number Diff line number Diff line change
@@ -0,0 +1,17 @@
; RUN: llc < %s -verify-machineinstrs -mtriple=powerpc-aix- -mcpu=pwr10 | FileCheck %s

; CHECK: # %bb.0: # %bb
; CHECK-NEXT: lwz 3, L..C0(2) # @dvar
; CHECK-NEXT: plxv 0, -152758(3), 0
; CHECK-NEXT: stxv 0, 0(3)
; CHECK-NEXT: blr

%0 = type <{ double }>
@dvar = external global [2352637 x %0]

define void @Test() {
bb:
%i9 = load <2 x double>, ptr getelementptr inbounds (i8, ptr @dvar, i64 -152758), align 8
store <2 x double> %i9, ptr @dvar, align 8
ret void
}
Loading