Skip to content

Commit 471302d

Browse files
committed
fix(t2u): preserve descriptor base displacement
Compose the analyzed pointer-base displacement with the complete descriptor carrier instead of replacing it during marked addptr parsing. Reject incompatible displacement types while preserving the existing descriptor ownership and structured-axis metadata.
1 parent eb5633d commit 471302d

1 file changed

Lines changed: 14 additions & 4 deletions

File tree

third_party/ascend/lib/TritonToUnstructure/OffsetAnalysis.cpp

Lines changed: 14 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -598,9 +598,9 @@ void parseAddPtr(triton::AddPtrOp op, const Location &loc,
598598
isRebuild || ptrOffsetInfo.isPointerDescriptorOwned();
599599

600600
if (isCompleteOffsetCarrier) {
601-
// CFO has already accumulated every displacement relative to the common
602-
// base into this operand. Do not parse through its SCF producer or add the
603-
// base analysis' synthetic zero offset a second time.
601+
// The carrier is complete relative to the descriptor base, but parsing
602+
// that base may expose an additional displacement from its scalar source.
603+
// Preserve both parts when reconstructing the complete pointer offset.
604604
auto offsetType = dyn_cast<RankedTensorType>(offsetValue.getType());
605605
auto offsetElementType =
606606
offsetType ? dyn_cast<IntegerType>(offsetType.getElementType())
@@ -626,7 +626,17 @@ void parseAddPtr(triton::AddPtrOp op, const Location &loc,
626626
offsetValue = rewriter.create<arith::ExtSIOp>(op.getLoc(), carrierType,
627627
offsetValue);
628628
}
629-
ptrOffsetInfo.setOffset(offsetValue);
629+
Value baseDisplacement = ptrOffsetInfo.getOffset();
630+
if (!baseDisplacement ||
631+
baseDisplacement.getType() != offsetValue.getType()) {
632+
op.emitOpError(
633+
"expected pointer-base displacement compatible with complete "
634+
"carrier");
635+
return;
636+
}
637+
Value completeOffset = rewriter.create<arith::AddIOp>(
638+
op.getLoc(), baseDisplacement, offsetValue);
639+
ptrOffsetInfo.setOffset(completeOffset);
630640
// setUnstructured() updates only the per-axis classification; it does not
631641
// clear the independent scalar-like property inherited from a splatted
632642
// base. A complete offset carrier is intentionally opaque here, so there

0 commit comments

Comments
 (0)