@@ -2256,17 +2256,24 @@ SDValue NVPTXTargetLowering::LowerEXTRACT_VECTOR_ELT(SDValue Op,
2256
2256
}
2257
2257
2258
2258
if (VectorVT == MVT::v2f32) {
2259
+ auto GetOperand = [&DAG, &DL](SDValue Op, SDValue Index) {
2260
+ if (const auto *ConstIdx = dyn_cast<ConstantSDNode>(Index))
2261
+ return Op.getOperand (ConstIdx->getZExtValue ());
2262
+ SDValue E0 = Op.getOperand (0 );
2263
+ SDValue E1 = Op.getOperand (1 );
2264
+ return DAG.getSelectCC (DL, Index, DAG.getIntPtrConstant (0 , DL), E0 , E1 ,
2265
+ ISD::CondCode::SETEQ);
2266
+ };
2259
2267
if (Vector.getOpcode () == ISD::BITCAST) {
2260
2268
// peek through v2f32 = bitcast (i64 = build_pair (i32 A, i32 B))
2261
2269
// where A:i32, B:i32 = CopyFromReg (i64 = F32X2 Operation ...)
2262
2270
SDValue Pair = Vector.getOperand (0 );
2263
2271
assert (Pair.getOpcode () == ISD::BUILD_PAIR);
2264
- return DAG.getNode (
2265
- ISD::BITCAST, DL, Op.getValueType (),
2266
- Pair.getOperand (cast<ConstantSDNode>(Index)->getZExtValue ()));
2272
+ return DAG.getNode (ISD::BITCAST, DL, Op.getValueType (),
2273
+ GetOperand (Pair, Index));
2267
2274
}
2268
2275
if (Vector.getOpcode () == ISD::BUILD_VECTOR)
2269
- return Vector. getOperand (cast<ConstantSDNode>( Index)-> getZExtValue () );
2276
+ return GetOperand (Vector, Index);
2270
2277
}
2271
2278
2272
2279
// Constant index will be matched by tablegen.
0 commit comments