File tree Expand file tree Collapse file tree 1 file changed +11
-5
lines changed
mlir/lib/Conversion/VectorToLLVM Expand file tree Collapse file tree 1 file changed +11
-5
lines changed Original file line number Diff line number Diff line change @@ -1096,14 +1096,20 @@ class VectorExtractOpConversion
1096
1096
SmallVector<OpFoldResult> positionVec = getMixedValues (
1097
1097
adaptor.getStaticPosition (), adaptor.getDynamicPosition (), rewriter);
1098
1098
1099
- // Determine if we need to extract a scalar as the result. We extract
1100
- // a scalar if the extract is full rank i.e. the number of indices is equal
1101
- // to source vector rank.
1102
- bool isScalarExtract =
1103
- positionVec.size () == extractOp.getSourceVectorType ().getRank ();
1099
+ // The LLVM lowering models multi dimension vectors as stacked 1-d vectors.
1100
+ // The stacking is modeled using arrays. We do this conversion from a
1101
+ // N-d vector extract to stacked 1-d vector extract in two steps:
1102
+ // - Extract a 1-d vector or a stack of 1-d vectors (llvm.extractvalue)
1103
+ // - Extract a scalar out of the 1-d vector if needed (llvm.extractelement)
1104
+
1104
1105
// Determine if we need to extract a slice out of the original vector. We
1105
1106
// always need to extract a slice if the input rank >= 2.
1106
1107
bool isSlicingExtract = extractOp.getSourceVectorType ().getRank () >= 2 ;
1108
+ // Determine if we need to extract a scalar as the result. We extract
1109
+ // a scalar if the extract is full rank i.e. the number of indices is equal
1110
+ // to source vector rank.
1111
+ bool isScalarExtract = static_cast <int64_t >(positionVec.size ()) ==
1112
+ extractOp.getSourceVectorType ().getRank ();
1107
1113
1108
1114
Value extracted = adaptor.getVector ();
1109
1115
if (isSlicingExtract) {
You can’t perform that action at this time.
0 commit comments