@@ -874,6 +874,10 @@ NVPTXTargetLowering::NVPTXTargetLowering(const NVPTXTargetMachine &TM,
874
874
setOperationAction (ISD::BITCAST, MVT::v2f32, Custom);
875
875
// Handle custom lowering for: f32 = extract_vector_elt v2f32
876
876
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);
877
881
}
878
882
879
883
// These map to conversion instructions for scalar FP types.
@@ -5268,6 +5272,31 @@ PerformBUILD_VECTORCombine(SDNode *N, TargetLowering::DAGCombinerInfo &DCI) {
5268
5272
return DAG.getNode (ISD::BITCAST, DL, VT, PRMT);
5269
5273
}
5270
5274
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
+
5271
5300
SDValue NVPTXTargetLowering::PerformDAGCombine (SDNode *N,
5272
5301
DAGCombinerInfo &DCI) const {
5273
5302
CodeGenOptLevel OptLevel = getTargetMachine ().getOptLevel ();
@@ -5302,6 +5331,8 @@ SDValue NVPTXTargetLowering::PerformDAGCombine(SDNode *N,
5302
5331
return PerformVSELECTCombine (N, DCI);
5303
5332
case ISD::BUILD_VECTOR:
5304
5333
return PerformBUILD_VECTORCombine (N, DCI);
5334
+ case ISD::OR:
5335
+ return PerformORCombine (N, DCI, OptLevel);
5305
5336
}
5306
5337
return SDValue ();
5307
5338
}
0 commit comments