forked from OSchip/llvm-project
PPCISelLowering.cpp - don't dereference a dyn_cast<>.
dyn_cast<> can return nullptr which we would then dereference - use cast<> which will assert that the type is correct.
This commit is contained in:
parent
114e712c34
commit
01b77159e3
|
@ -13925,7 +13925,7 @@ static SDValue combineBVZEXTLOAD(SDNode *N, SelectionDAG &DAG) {
|
||||||
if (Operand.getOpcode() != ISD::LOAD)
|
if (Operand.getOpcode() != ISD::LOAD)
|
||||||
return SDValue();
|
return SDValue();
|
||||||
|
|
||||||
LoadSDNode *LD = dyn_cast<LoadSDNode>(Operand);
|
auto *LD = cast<LoadSDNode>(Operand);
|
||||||
EVT MemoryType = LD->getMemoryVT();
|
EVT MemoryType = LD->getMemoryVT();
|
||||||
|
|
||||||
// This transformation is only valid if the we are loading either a byte,
|
// This transformation is only valid if the we are loading either a byte,
|
||||||
|
@ -16571,9 +16571,7 @@ static SDValue combineADDToADDZE(SDNode *N, SelectionDAG &DAG,
|
||||||
SDVTList VTs = DAG.getVTList(MVT::i64, MVT::Glue);
|
SDVTList VTs = DAG.getVTList(MVT::i64, MVT::Glue);
|
||||||
SDValue Cmp = RHS.getOperand(0);
|
SDValue Cmp = RHS.getOperand(0);
|
||||||
SDValue Z = Cmp.getOperand(0);
|
SDValue Z = Cmp.getOperand(0);
|
||||||
auto *Constant = dyn_cast<ConstantSDNode>(Cmp.getOperand(1));
|
auto *Constant = cast<ConstantSDNode>(Cmp.getOperand(1));
|
||||||
|
|
||||||
assert(Constant && "Constant Should not be a null pointer.");
|
|
||||||
int64_t NegConstant = 0 - Constant->getSExtValue();
|
int64_t NegConstant = 0 - Constant->getSExtValue();
|
||||||
|
|
||||||
switch(cast<CondCodeSDNode>(Cmp.getOperand(2))->get()) {
|
switch(cast<CondCodeSDNode>(Cmp.getOperand(2))->get()) {
|
||||||
|
@ -17285,8 +17283,7 @@ PPC::AddrMode PPCTargetLowering::SelectOptimalAddrMode(const SDNode *Parent,
|
||||||
if (Flags & PPC::MOF_RPlusSImm16) {
|
if (Flags & PPC::MOF_RPlusSImm16) {
|
||||||
SDValue Op0 = N.getOperand(0);
|
SDValue Op0 = N.getOperand(0);
|
||||||
SDValue Op1 = N.getOperand(1);
|
SDValue Op1 = N.getOperand(1);
|
||||||
ConstantSDNode *CN = dyn_cast<ConstantSDNode>(Op1);
|
int16_t Imm = cast<ConstantSDNode>(Op1)->getAPIntValue().getZExtValue();
|
||||||
int16_t Imm = CN->getAPIntValue().getZExtValue();
|
|
||||||
if (!Align || isAligned(*Align, Imm)) {
|
if (!Align || isAligned(*Align, Imm)) {
|
||||||
Disp = DAG.getTargetConstant(Imm, DL, N.getValueType());
|
Disp = DAG.getTargetConstant(Imm, DL, N.getValueType());
|
||||||
Base = Op0;
|
Base = Op0;
|
||||||
|
@ -17312,7 +17309,7 @@ PPC::AddrMode PPCTargetLowering::SelectOptimalAddrMode(const SDNode *Parent,
|
||||||
// zero or load-immediate-shifted and the displacement will be
|
// zero or load-immediate-shifted and the displacement will be
|
||||||
// the low 16 bits of the address.
|
// the low 16 bits of the address.
|
||||||
else if (Flags & PPC::MOF_AddrIsSImm32) {
|
else if (Flags & PPC::MOF_AddrIsSImm32) {
|
||||||
ConstantSDNode *CN = dyn_cast<ConstantSDNode>(N);
|
auto *CN = cast<ConstantSDNode>(N);
|
||||||
EVT CNType = CN->getValueType(0);
|
EVT CNType = CN->getValueType(0);
|
||||||
uint64_t CNImm = CN->getZExtValue();
|
uint64_t CNImm = CN->getZExtValue();
|
||||||
// If this address fits entirely in a 16-bit sext immediate field, codegen
|
// If this address fits entirely in a 16-bit sext immediate field, codegen
|
||||||
|
|
Loading…
Reference in New Issue