mirror of
https://github.com/RPCS3/llvm-mirror.git
synced 2024-10-21 03:53:04 +02:00
Fold shift by size larger than type size to undef
Make llvm undef values generate ISD::UNDEF nodes llvm-svn: 21261
This commit is contained in:
parent
79c8b8fd1c
commit
a56527ea5f
@ -755,19 +755,12 @@ SDOperand SelectionDAG::getNode(unsigned Opcode, MVT::ValueType VT,
|
|||||||
|
|
||||||
case ISD::SHL:
|
case ISD::SHL:
|
||||||
case ISD::SRL:
|
case ISD::SRL:
|
||||||
// If the shift amount is bigger than the size of the data, simplify.
|
|
||||||
if (C2 >= MVT::getSizeInBits(N1.getValueType())) {
|
|
||||||
if (TLI.getShiftAmountFlavor() == TargetLowering::Mask) {
|
|
||||||
unsigned NewAmt =
|
|
||||||
C2 & ((1 << MVT::getSizeInBits(N1.getValueType()))-1);
|
|
||||||
return getNode(Opcode, VT, N1, getConstant(NewAmt,N2.getValueType()));
|
|
||||||
} else if (TLI.getShiftAmountFlavor() == TargetLowering::Extend) {
|
|
||||||
// Shifting all of the bits out?
|
|
||||||
return getConstant(0, N1.getValueType());
|
|
||||||
}
|
|
||||||
}
|
|
||||||
// FALL THROUGH.
|
|
||||||
case ISD::SRA:
|
case ISD::SRA:
|
||||||
|
// If the shift amount is bigger than the size of the data, then all the
|
||||||
|
// bits are shifted out. Simplify to loading constant zero.
|
||||||
|
if (C2 >= MVT::getSizeInBits(N1.getValueType())) {
|
||||||
|
return getNode(ISD::UNDEF, N1.getValueType());
|
||||||
|
}
|
||||||
if (C2 == 0) return N1;
|
if (C2 == 0) return N1;
|
||||||
break;
|
break;
|
||||||
|
|
||||||
|
@ -266,14 +266,7 @@ public:
|
|||||||
} else if (isa<ConstantPointerNull>(C)) {
|
} else if (isa<ConstantPointerNull>(C)) {
|
||||||
return N = DAG.getConstant(0, TLI.getPointerTy());
|
return N = DAG.getConstant(0, TLI.getPointerTy());
|
||||||
} else if (isa<UndefValue>(C)) {
|
} else if (isa<UndefValue>(C)) {
|
||||||
/// FIXME: Implement UNDEFVALUE better.
|
return N = DAG.getNode(ISD::UNDEF, VT);
|
||||||
if (MVT::isInteger(VT))
|
|
||||||
return N = DAG.getConstant(0, VT);
|
|
||||||
else if (MVT::isFloatingPoint(VT))
|
|
||||||
return N = DAG.getConstantFP(0, VT);
|
|
||||||
else
|
|
||||||
assert(0 && "Unknown value type!");
|
|
||||||
|
|
||||||
} else if (ConstantFP *CFP = dyn_cast<ConstantFP>(C)) {
|
} else if (ConstantFP *CFP = dyn_cast<ConstantFP>(C)) {
|
||||||
return N = DAG.getConstantFP(CFP->getValue(), VT);
|
return N = DAG.getConstantFP(CFP->getValue(), VT);
|
||||||
} else {
|
} else {
|
||||||
|
@ -61,7 +61,6 @@ namespace {
|
|||||||
setOperationAction(ISD::SREM, MVT::i32, Expand);
|
setOperationAction(ISD::SREM, MVT::i32, Expand);
|
||||||
setOperationAction(ISD::UREM, MVT::i32, Expand);
|
setOperationAction(ISD::UREM, MVT::i32, Expand);
|
||||||
|
|
||||||
setShiftAmountFlavor(Extend); // shl X, 32 == 0
|
|
||||||
setSetCCResultContents(ZeroOrOneSetCCResult);
|
setSetCCResultContents(ZeroOrOneSetCCResult);
|
||||||
addLegalFPImmediate(+0.0); // Necessary for FSEL
|
addLegalFPImmediate(+0.0); // Necessary for FSEL
|
||||||
addLegalFPImmediate(-0.0); //
|
addLegalFPImmediate(-0.0); //
|
||||||
|
Loading…
Reference in New Issue
Block a user