mirror of
https://github.com/c64scene-ar/llvm-6502.git
synced 2025-01-14 00:32:55 +00:00
Don't apply on PPC64 the 32bit ADDIC optimizations as there's no overflow
with 32bit values. git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@133439 91177308-0d34-0410-b5e6-96231b3b80d8
This commit is contained in:
parent
5e27a1d468
commit
8e9d6720c3
@ -610,6 +610,9 @@ SDNode *PPCDAGToDAGISel::SelectSETCC(SDNode *N) {
|
||||
DebugLoc dl = N->getDebugLoc();
|
||||
unsigned Imm;
|
||||
ISD::CondCode CC = cast<CondCodeSDNode>(N->getOperand(2))->get();
|
||||
EVT PtrVT = CurDAG->getTargetLoweringInfo().getPointerTy();
|
||||
bool isPPC64 = (PtrVT == MVT::i64);
|
||||
|
||||
if (isInt32Immediate(N->getOperand(1), Imm)) {
|
||||
// We can codegen setcc op, imm very efficiently compared to a brcond.
|
||||
// Check for those cases here.
|
||||
@ -624,6 +627,7 @@ SDNode *PPCDAGToDAGISel::SelectSETCC(SDNode *N) {
|
||||
return CurDAG->SelectNodeTo(N, PPC::RLWINM, MVT::i32, Ops, 4);
|
||||
}
|
||||
case ISD::SETNE: {
|
||||
if (isPPC64) break;
|
||||
SDValue AD =
|
||||
SDValue(CurDAG->getMachineNode(PPC::ADDIC, dl, MVT::i32, MVT::Glue,
|
||||
Op, getI32Imm(~0U)), 0);
|
||||
@ -647,6 +651,7 @@ SDNode *PPCDAGToDAGISel::SelectSETCC(SDNode *N) {
|
||||
switch (CC) {
|
||||
default: break;
|
||||
case ISD::SETEQ:
|
||||
if (isPPC64) break;
|
||||
Op = SDValue(CurDAG->getMachineNode(PPC::ADDIC, dl, MVT::i32, MVT::Glue,
|
||||
Op, getI32Imm(1)), 0);
|
||||
return CurDAG->SelectNodeTo(N, PPC::ADDZE, MVT::i32,
|
||||
@ -655,6 +660,7 @@ SDNode *PPCDAGToDAGISel::SelectSETCC(SDNode *N) {
|
||||
getI32Imm(0)), 0),
|
||||
Op.getValue(1));
|
||||
case ISD::SETNE: {
|
||||
if (isPPC64) break;
|
||||
Op = SDValue(CurDAG->getMachineNode(PPC::NOR, dl, MVT::i32, Op, Op), 0);
|
||||
SDNode *AD = CurDAG->getMachineNode(PPC::ADDIC, dl, MVT::i32, MVT::Glue,
|
||||
Op, getI32Imm(~0U));
|
||||
@ -996,22 +1002,25 @@ SDNode *PPCDAGToDAGISel::Select(SDNode *N) {
|
||||
}
|
||||
case ISD::SELECT_CC: {
|
||||
ISD::CondCode CC = cast<CondCodeSDNode>(N->getOperand(4))->get();
|
||||
EVT PtrVT = CurDAG->getTargetLoweringInfo().getPointerTy();
|
||||
bool isPPC64 = (PtrVT == MVT::i64);
|
||||
|
||||
// Handle the setcc cases here. select_cc lhs, 0, 1, 0, cc
|
||||
if (ConstantSDNode *N1C = dyn_cast<ConstantSDNode>(N->getOperand(1)))
|
||||
if (ConstantSDNode *N2C = dyn_cast<ConstantSDNode>(N->getOperand(2)))
|
||||
if (ConstantSDNode *N3C = dyn_cast<ConstantSDNode>(N->getOperand(3)))
|
||||
if (N1C->isNullValue() && N3C->isNullValue() &&
|
||||
N2C->getZExtValue() == 1ULL && CC == ISD::SETNE &&
|
||||
// FIXME: Implement this optzn for PPC64.
|
||||
N->getValueType(0) == MVT::i32) {
|
||||
SDNode *Tmp =
|
||||
CurDAG->getMachineNode(PPC::ADDIC, dl, MVT::i32, MVT::Glue,
|
||||
N->getOperand(0), getI32Imm(~0U));
|
||||
return CurDAG->SelectNodeTo(N, PPC::SUBFE, MVT::i32,
|
||||
SDValue(Tmp, 0), N->getOperand(0),
|
||||
SDValue(Tmp, 1));
|
||||
}
|
||||
if (!isPPC64)
|
||||
if (ConstantSDNode *N1C = dyn_cast<ConstantSDNode>(N->getOperand(1)))
|
||||
if (ConstantSDNode *N2C = dyn_cast<ConstantSDNode>(N->getOperand(2)))
|
||||
if (ConstantSDNode *N3C = dyn_cast<ConstantSDNode>(N->getOperand(3)))
|
||||
if (N1C->isNullValue() && N3C->isNullValue() &&
|
||||
N2C->getZExtValue() == 1ULL && CC == ISD::SETNE &&
|
||||
// FIXME: Implement this optzn for PPC64.
|
||||
N->getValueType(0) == MVT::i32) {
|
||||
SDNode *Tmp =
|
||||
CurDAG->getMachineNode(PPC::ADDIC, dl, MVT::i32, MVT::Glue,
|
||||
N->getOperand(0), getI32Imm(~0U));
|
||||
return CurDAG->SelectNodeTo(N, PPC::SUBFE, MVT::i32,
|
||||
SDValue(Tmp, 0), N->getOperand(0),
|
||||
SDValue(Tmp, 1));
|
||||
}
|
||||
|
||||
SDValue CCReg = SelectCC(N->getOperand(0), N->getOperand(1), CC, dl);
|
||||
unsigned BROpc = getPredicateForSetCC(CC);
|
||||
|
29
test/CodeGen/PowerPC/ppc64-32bit-addic.ll
Normal file
29
test/CodeGen/PowerPC/ppc64-32bit-addic.ll
Normal file
@ -0,0 +1,29 @@
|
||||
; Check that the ADDIC optimizations are not applied on PPC64
|
||||
; RUN: llc < %s | FileCheck %s
|
||||
; ModuleID = 'os_unix.c'
|
||||
target datalayout = "E-p:64:64:64-i1:8:8-i8:8:8-i16:16:16-i32:32:32-i64:64:64-f32:32:32-f64:64:64-v128:128:128-n32:64"
|
||||
target triple = "powerpc64-unknown-freebsd9.0"
|
||||
|
||||
define i32 @notZero(i32 %call) nounwind {
|
||||
entry:
|
||||
; CHECK-NOT: addic
|
||||
%not.tobool = icmp ne i32 %call, 0
|
||||
%. = zext i1 %not.tobool to i32
|
||||
ret i32 %.
|
||||
}
|
||||
|
||||
define i32 @isMinusOne(i32 %call) nounwind {
|
||||
entry:
|
||||
; CHECK-NOT: addic
|
||||
%not.tobool = icmp eq i32 %call, -1
|
||||
%. = zext i1 %not.tobool to i32
|
||||
ret i32 %.
|
||||
}
|
||||
|
||||
define i32 @isNotMinusOne(i32 %call) nounwind {
|
||||
entry:
|
||||
; CHECK-NOT: addic
|
||||
%not.tobool = icmp ne i32 %call, -1
|
||||
%. = zext i1 %not.tobool to i32
|
||||
ret i32 %.
|
||||
}
|
Loading…
x
Reference in New Issue
Block a user