mirror of
https://github.com/c64scene-ar/llvm-6502.git
synced 2026-04-25 21:18:19 +00:00
Generalize ExtendUsesToFormExtLoad to be usable for ANY_EXTEND,
in addition to ZERO_EXTEND and SIGN_EXTEND. Fix a bug in the way it checked for live-out values, and simplify the way it find users by using SDNode::use_iterator's (relatively) new features. Also, make it slightly more permissive on targets with free truncates. In SelectionDAGBuild, avoid creating ANY_EXTEND nodes that are larger than necessary. If the target's SwitchAmountTy has enough bits, use it. This exposes the truncate to optimization early, enabling more optimizations. git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@68670 91177308-0d34-0410-b5e6-96231b3b80d8
This commit is contained in:
@@ -2190,8 +2190,24 @@ void SelectionDAGLowering::visitBinary(User &I, unsigned OpCode) {
|
||||
void SelectionDAGLowering::visitShift(User &I, unsigned Opcode) {
|
||||
SDValue Op1 = getValue(I.getOperand(0));
|
||||
SDValue Op2 = getValue(I.getOperand(1));
|
||||
if (!isa<VectorType>(I.getType())) {
|
||||
if (TLI.getPointerTy().bitsLT(Op2.getValueType()))
|
||||
if (!isa<VectorType>(I.getType()) &&
|
||||
Op2.getValueType() != TLI.getShiftAmountTy()) {
|
||||
// If the operand is smaller than the shift count type, promote it.
|
||||
if (TLI.getShiftAmountTy().bitsGT(Op2.getValueType()))
|
||||
Op2 = DAG.getNode(ISD::ANY_EXTEND, getCurDebugLoc(),
|
||||
TLI.getShiftAmountTy(), Op2);
|
||||
// If the operand is larger than the shift count type but the shift
|
||||
// count type has enough bits to represent any shift value, truncate
|
||||
// it now. This is a common case and it exposes the truncate to
|
||||
// optimization early.
|
||||
else if (TLI.getShiftAmountTy().getSizeInBits() >=
|
||||
Log2_32_Ceil(Op2.getValueType().getSizeInBits()))
|
||||
Op2 = DAG.getNode(ISD::TRUNCATE, getCurDebugLoc(),
|
||||
TLI.getShiftAmountTy(), Op2);
|
||||
// Otherwise we'll need to temporarily settle for some other
|
||||
// convenient type; type legalization will make adjustments as
|
||||
// needed.
|
||||
else if (TLI.getPointerTy().bitsLT(Op2.getValueType()))
|
||||
Op2 = DAG.getNode(ISD::TRUNCATE, getCurDebugLoc(),
|
||||
TLI.getPointerTy(), Op2);
|
||||
else if (TLI.getPointerTy().bitsGT(Op2.getValueType()))
|
||||
|
||||
Reference in New Issue
Block a user