@@ -244,8 +244,7 @@ class ARMDAGToDAGISel : public SelectionDAGISel {
244
244
bool tryInlineAsm (SDNode *N);
245
245
246
246
void SelectConcatVector (SDNode *N);
247
- void SelectCMPZ (SDNode *N, bool &SwitchEQNEToPLMI);
248
-
247
+
249
248
bool trySMLAWSMULW (SDNode *N);
250
249
251
250
void SelectCMP_SWAP (SDNode *N);
@@ -2694,83 +2693,6 @@ void ARMDAGToDAGISel::SelectConcatVector(SDNode *N) {
2694
2693
ReplaceNode (N, createDRegPairNode (VT, N->getOperand (0 ), N->getOperand (1 )));
2695
2694
}
2696
2695
2697
- static Optional<std::pair<unsigned , unsigned >>
2698
- getContiguousRangeOfSetBits (const APInt &A) {
2699
- unsigned FirstOne = A.getBitWidth () - A.countLeadingZeros () - 1 ;
2700
- unsigned LastOne = A.countTrailingZeros ();
2701
- if (A.countPopulation () != (FirstOne - LastOne + 1 ))
2702
- return Optional<std::pair<unsigned ,unsigned >>();
2703
- return std::make_pair (FirstOne, LastOne);
2704
- }
2705
-
2706
- void ARMDAGToDAGISel::SelectCMPZ (SDNode *N, bool &SwitchEQNEToPLMI) {
2707
- assert (N->getOpcode () == ARMISD::CMPZ);
2708
- SwitchEQNEToPLMI = false ;
2709
-
2710
- if (!Subtarget->isThumb ())
2711
- // FIXME: Work out whether it is profitable to do this in A32 mode - LSL and
2712
- // LSR don't exist as standalone instructions - they need the barrel shifter.
2713
- return ;
2714
- // select (cmpz (and X, C), #0) -> (LSLS X) or (LSRS X) or (LSRS (LSLS X))
2715
- SDValue And = N->getOperand (0 );
2716
- SDValue Zero = N->getOperand (1 );
2717
- if (!isa<ConstantSDNode>(Zero) || !cast<ConstantSDNode>(Zero)->isNullValue () ||
2718
- And->getOpcode () != ISD::AND)
2719
- return ;
2720
- SDValue X = And.getOperand (0 );
2721
- auto C = dyn_cast<ConstantSDNode>(And.getOperand (1 ));
2722
-
2723
- if (!C || !X->hasOneUse ())
2724
- return ;
2725
- auto Range = getContiguousRangeOfSetBits (C->getAPIntValue ());
2726
- if (!Range)
2727
- return ;
2728
-
2729
- // There are several ways to lower this:
2730
- SDNode *NewN;
2731
- SDLoc dl (N);
2732
-
2733
- auto EmitShift = [&](unsigned Opc, SDValue Src, unsigned Imm) -> SDNode* {
2734
- if (Subtarget->isThumb2 ()) {
2735
- Opc = (Opc == ARM::tLSLri) ? ARM::t2LSLri : ARM::t2LSRri;
2736
- SDValue Ops[] = { Src, CurDAG->getTargetConstant (Imm, dl, MVT::i32),
2737
- getAL (CurDAG, dl), CurDAG->getRegister (0 , MVT::i32),
2738
- CurDAG->getRegister (0 , MVT::i32) };
2739
- return CurDAG->getMachineNode (Opc, dl, MVT::i32, Ops);
2740
- } else {
2741
- SDValue Ops[] = {CurDAG->getRegister (ARM::CPSR, MVT::i32), Src,
2742
- CurDAG->getTargetConstant (Imm, dl, MVT::i32),
2743
- getAL (CurDAG, dl), CurDAG->getRegister (0 , MVT::i32)};
2744
- return CurDAG->getMachineNode (Opc, dl, MVT::i32, Ops);
2745
- }
2746
- };
2747
-
2748
- if (Range->second == 0 ) {
2749
- // 1. Mask includes the LSB -> Simply shift the top N bits off
2750
- NewN = EmitShift (ARM::tLSLri, X, 31 - Range->first );
2751
- ReplaceNode (And.getNode (), NewN);
2752
- } else if (Range->first == 31 ) {
2753
- // 2. Mask includes the MSB -> Simply shift the bottom N bits off
2754
- NewN = EmitShift (ARM::tLSRri, X, Range->second );
2755
- ReplaceNode (And.getNode (), NewN);
2756
- } else if (Range->first == Range->second ) {
2757
- // 3. Only one bit is set. We can shift this into the sign bit and use a
2758
- // PL/MI comparison.
2759
- NewN = EmitShift (ARM::tLSLri, X, 31 - Range->first );
2760
- ReplaceNode (And.getNode (), NewN);
2761
-
2762
- SwitchEQNEToPLMI = true ;
2763
- } else if (!Subtarget->hasV6T2Ops ()) {
2764
- // 4. Do a double shift to clear bottom and top bits, but only in
2765
- // thumb-1 mode as in thumb-2 we can use UBFX.
2766
- NewN = EmitShift (ARM::tLSLri, X, 31 - Range->first );
2767
- NewN = EmitShift (ARM::tLSRri, SDValue (NewN, 0 ),
2768
- Range->second + (31 - Range->first ));
2769
- ReplaceNode (And.getNode (), NewN);
2770
- }
2771
-
2772
- }
2773
-
2774
2696
void ARMDAGToDAGISel::Select (SDNode *N) {
2775
2697
SDLoc dl (N);
2776
2698
@@ -2998,7 +2920,6 @@ void ARMDAGToDAGISel::Select(SDNode *N) {
2998
2920
return ;
2999
2921
}
3000
2922
}
3001
-
3002
2923
break ;
3003
2924
}
3004
2925
case ARMISD::VMOVRRD:
@@ -3189,27 +3110,9 @@ void ARMDAGToDAGISel::Select(SDNode *N) {
3189
3110
assert (N2.getOpcode () == ISD::Constant);
3190
3111
assert (N3.getOpcode () == ISD::Register);
3191
3112
3192
- unsigned CC = (unsigned ) cast<ConstantSDNode>(N2)->getZExtValue ();
3193
-
3194
- if (InFlag.getOpcode () == ARMISD::CMPZ) {
3195
- bool SwitchEQNEToPLMI;
3196
- SelectCMPZ (InFlag.getNode (), SwitchEQNEToPLMI);
3197
- InFlag = N->getOperand (4 );
3198
-
3199
- if (SwitchEQNEToPLMI) {
3200
- switch ((ARMCC::CondCodes)CC) {
3201
- default : llvm_unreachable (" CMPZ must be either NE or EQ!" );
3202
- case ARMCC::NE:
3203
- CC = (unsigned )ARMCC::MI;
3204
- break ;
3205
- case ARMCC::EQ:
3206
- CC = (unsigned )ARMCC::PL;
3207
- break ;
3208
- }
3209
- }
3210
- }
3211
-
3212
- SDValue Tmp2 = CurDAG->getTargetConstant (CC, dl, MVT::i32);
3113
+ SDValue Tmp2 = CurDAG->getTargetConstant (((unsigned )
3114
+ cast<ConstantSDNode>(N2)->getZExtValue ()), dl,
3115
+ MVT::i32);
3213
3116
SDValue Ops[] = { N1, Tmp2, N3, Chain, InFlag };
3214
3117
SDNode *ResNode = CurDAG->getMachineNode (Opc, dl, MVT::Other,
3215
3118
MVT::Glue, Ops);
@@ -3264,38 +3167,6 @@ void ARMDAGToDAGISel::Select(SDNode *N) {
3264
3167
// Other cases are autogenerated.
3265
3168
break ;
3266
3169
}
3267
-
3268
- case ARMISD::CMOV: {
3269
- SDValue InFlag = N->getOperand (4 );
3270
-
3271
- if (InFlag.getOpcode () == ARMISD::CMPZ) {
3272
- bool SwitchEQNEToPLMI;
3273
- SelectCMPZ (InFlag.getNode (), SwitchEQNEToPLMI);
3274
-
3275
- if (SwitchEQNEToPLMI) {
3276
- SDValue ARMcc = N->getOperand (2 );
3277
- ARMCC::CondCodes CC =
3278
- (ARMCC::CondCodes)cast<ConstantSDNode>(ARMcc)->getZExtValue ();
3279
-
3280
- switch (CC) {
3281
- default : llvm_unreachable (" CMPZ must be either NE or EQ!" );
3282
- case ARMCC::NE:
3283
- CC = ARMCC::MI;
3284
- break ;
3285
- case ARMCC::EQ:
3286
- CC = ARMCC::PL;
3287
- break ;
3288
- }
3289
- SDValue NewARMcc = CurDAG->getConstant ((unsigned )CC, dl, MVT::i32);
3290
- SDValue Ops[] = {N->getOperand (0 ), N->getOperand (1 ), NewARMcc,
3291
- N->getOperand (3 ), N->getOperand (4 )};
3292
- CurDAG->MorphNodeTo (N, ARMISD::CMOV, N->getVTList (), Ops);
3293
- }
3294
-
3295
- }
3296
- // Other cases are autogenerated.
3297
- break ;
3298
- }
3299
3170
3300
3171
case ARMISD::VZIP: {
3301
3172
unsigned Opc = 0 ;
0 commit comments