diff options
| author | Tim Northover <tnorthover@apple.com> | 2014-04-03 09:26:16 +0000 | 
|---|---|---|
| committer | Tim Northover <tnorthover@apple.com> | 2014-04-03 09:26:16 +0000 | 
| commit | 2ad88d3aab31f767f5adb56f71ac51b36c1cf899 (patch) | |
| tree | 0601baf8e45b1e5d98146211d7303123eaa979b4 /llvm/lib/Target/ARM64/ARM64ISelLowering.cpp | |
| parent | caccac10b7e1beeefeae4f389cfed78763dc6aae (diff) | |
| download | bcm5719-llvm-2ad88d3aab31f767f5adb56f71ac51b36c1cf899.tar.gz bcm5719-llvm-2ad88d3aab31f767f5adb56f71ac51b36c1cf899.zip | |
ARM64: always use i64 for the RHS of shift operations
Switching between i32 and i64 based on the LHS type is a good idea in
theory, but pre-legalisation uses i64 regardless of our choice,
leading to potential ISel errors.
Should fix PR19294.
llvm-svn: 205519
Diffstat (limited to 'llvm/lib/Target/ARM64/ARM64ISelLowering.cpp')
| -rw-r--r-- | llvm/lib/Target/ARM64/ARM64ISelLowering.cpp | 23 | 
1 files changed, 10 insertions, 13 deletions
| diff --git a/llvm/lib/Target/ARM64/ARM64ISelLowering.cpp b/llvm/lib/Target/ARM64/ARM64ISelLowering.cpp index 8164e6d2967..641f5916102 100644 --- a/llvm/lib/Target/ARM64/ARM64ISelLowering.cpp +++ b/llvm/lib/Target/ARM64/ARM64ISelLowering.cpp @@ -573,11 +573,6 @@ void ARM64TargetLowering::computeMaskedBitsForTargetNode(  }  MVT ARM64TargetLowering::getScalarShiftAmountTy(EVT LHSTy) const { -  if (!LHSTy.isSimple()) -    return MVT::i64; -  MVT SimpleVT = LHSTy.getSimpleVT(); -  if (SimpleVT == MVT::i32) -    return MVT::i32;    return MVT::i64;  } @@ -1534,10 +1529,10 @@ getARM64XALUOOp(ARM64CC::CondCode &CC, SDValue Op, SelectionDAG &DAG) {          // check we have to arithmetic shift right the 32nd bit of the result by          // 31 bits. Then we compare the result to the upper 32 bits.          SDValue UpperBits = DAG.getNode(ISD::SRL, DL, MVT::i64, Add, -                                        DAG.getConstant(32, MVT::i32)); +                                        DAG.getConstant(32, MVT::i64));          UpperBits = DAG.getNode(ISD::TRUNCATE, DL, MVT::i32, UpperBits);          SDValue LowerBits = DAG.getNode(ISD::SRA, DL, MVT::i32, Value, -                                        DAG.getConstant(31, MVT::i32)); +                                        DAG.getConstant(31, MVT::i64));          // It is important that LowerBits is last, otherwise the arithmetic          // shift will not be folded into the compare (SUBS).          SDVTList VTs = DAG.getVTList(MVT::i32, MVT::i32); @@ -1550,7 +1545,7 @@ getARM64XALUOOp(ARM64CC::CondCode &CC, SDValue Op, SelectionDAG &DAG) {          // pattern:          // (i64 ARM64ISD::SUBS i64 0, (i64 srl i64 %Mul, i64 32)          SDValue UpperBits = DAG.getNode(ISD::SRL, DL, MVT::i64, Mul, -                                        DAG.getConstant(32, MVT::i32)); +                                        DAG.getConstant(32, MVT::i64));          SDVTList VTs = DAG.getVTList(MVT::i64, MVT::i32);          Overflow =              DAG.getNode(ARM64ISD::SUBS, DL, VTs, DAG.getConstant(0, MVT::i64), @@ -1564,7 +1559,7 @@ getARM64XALUOOp(ARM64CC::CondCode &CC, SDValue Op, SelectionDAG &DAG) {      if (IsSigned) {        SDValue UpperBits = DAG.getNode(ISD::MULHS, DL, MVT::i64, LHS, RHS);        SDValue LowerBits = DAG.getNode(ISD::SRA, DL, MVT::i64, Value, -                                      DAG.getConstant(63, MVT::i32)); +                                      DAG.getConstant(63, MVT::i64));        // It is important that LowerBits is last, otherwise the arithmetic        // shift will not be folded into the compare (SUBS).        SDVTList VTs = DAG.getVTList(MVT::i64, MVT::i32); @@ -6330,16 +6325,18 @@ static SDValue performMulCombine(SDNode *N, SelectionDAG &DAG,      if (VP1.isPowerOf2()) {        // Multiplying by one less than a power of two, replace with a shift        // and a subtract. -      SDValue ShiftedVal = DAG.getNode(ISD::SHL, SDLoc(N), VT, N->getOperand(0), -                                       DAG.getConstant(VP1.logBase2(), VT)); +      SDValue ShiftedVal = +          DAG.getNode(ISD::SHL, SDLoc(N), VT, N->getOperand(0), +                      DAG.getConstant(VP1.logBase2(), MVT::i64));        return DAG.getNode(ISD::SUB, SDLoc(N), VT, ShiftedVal, N->getOperand(0));      }      APInt VM1 = Value - 1;      if (VM1.isPowerOf2()) {        // Multiplying by one more than a power of two, replace with a shift        // and an add. -      SDValue ShiftedVal = DAG.getNode(ISD::SHL, SDLoc(N), VT, N->getOperand(0), -                                       DAG.getConstant(VM1.logBase2(), VT)); +      SDValue ShiftedVal = +          DAG.getNode(ISD::SHL, SDLoc(N), VT, N->getOperand(0), +                      DAG.getConstant(VM1.logBase2(), MVT::i64));        return DAG.getNode(ISD::ADD, SDLoc(N), VT, ShiftedVal, N->getOperand(0));      }    } | 

