@@ -874,6 +874,10 @@ NVPTXTargetLowering::NVPTXTargetLowering(const NVPTXTargetMachine &TM,
874874 setOperationAction (ISD::BITCAST, MVT::v2f32, Custom);
875875 // Handle custom lowering for: f32 = extract_vector_elt v2f32
876876 setOperationAction (ISD::EXTRACT_VECTOR_ELT, MVT::v2f32, Custom);
877+ // Combine:
878+ // i64 = or (i64 = zero_extend X, i64 = shl (i64 = any_extend Y, 32))
879+ // -> i64 = build_pair (X, Y)
880+ setTargetDAGCombine (ISD::OR);
877881 }
878882
879883 // These map to conversion instructions for scalar FP types.
@@ -5268,6 +5272,31 @@ PerformBUILD_VECTORCombine(SDNode *N, TargetLowering::DAGCombinerInfo &DCI) {
52685272 return DAG.getNode (ISD::BITCAST, DL, VT, PRMT);
52695273}
52705274
5275+ static SDValue PerformORCombine (SDNode *N, TargetLowering::DAGCombinerInfo &DCI,
5276+ CodeGenOptLevel OptLevel) {
5277+ if (OptLevel == CodeGenOptLevel::None)
5278+ return SDValue ();
5279+
5280+ SDValue Op0 = N->getOperand (0 );
5281+ SDValue Op1 = N->getOperand (1 );
5282+
5283+ // i64 = or (i64 = zero_extend A, i64 = shl (i64 = any_extend B, 32))
5284+ // -> i64 = build_pair (A, B)
5285+ if (N->getValueType (0 ) == MVT::i64 && Op0.getOpcode () == ISD::ZERO_EXTEND &&
5286+ Op1.getOpcode () == ISD::SHL) {
5287+ SDValue SHLOp0 = Op1.getOperand (0 );
5288+ SDValue SHLOp1 = Op1.getOperand (1 );
5289+ if (const auto *Const = dyn_cast<ConstantSDNode>(SHLOp1);
5290+ Const && Const->getZExtValue () == 32 &&
5291+ SHLOp0.getOpcode () == ISD::ANY_EXTEND) {
5292+ SDLoc DL (N);
5293+ return DCI.DAG .getNode (ISD::BUILD_PAIR, DL, MVT::i64 ,
5294+ {Op0.getOperand (0 ), SHLOp0.getOperand (0 )});
5295+ }
5296+ }
5297+ return SDValue ();
5298+ }
5299+
52715300SDValue NVPTXTargetLowering::PerformDAGCombine (SDNode *N,
52725301 DAGCombinerInfo &DCI) const {
52735302 CodeGenOptLevel OptLevel = getTargetMachine ().getOptLevel ();
@@ -5302,6 +5331,8 @@ SDValue NVPTXTargetLowering::PerformDAGCombine(SDNode *N,
53025331 return PerformVSELECTCombine (N, DCI);
53035332 case ISD::BUILD_VECTOR:
53045333 return PerformBUILD_VECTORCombine (N, DCI);
5334+ case ISD::OR:
5335+ return PerformORCombine (N, DCI, OptLevel);
53055336 }
53065337 return SDValue ();
53075338}
0 commit comments