Skip to content

[Revert](fix) revert [ControlFlowOpt](feat) decompose pointers across control flow (#1344) - #1496

Open
245516766 wants to merge 1 commit into
triton-lang:main-devfrom
245516766:811-dev
Open

[Revert](fix) revert [ControlFlowOpt](feat) decompose pointers across control flow (#1344)#1496
245516766 wants to merge 1 commit into
triton-lang:main-devfrom
245516766:811-dev

Conversation

@245516766

Copy link
Copy Markdown
Contributor

… (#1344)"

This reverts commit 6dab8f4.

New contributor declaration

  • I am not making a trivial change, such as fixing a typo in a comment.

  • I have written a PR description following these
    rules.

  • I have run pre-commit run --from-ref origin/main --to-ref HEAD.

  • Select one of the following.

    • I have added tests.
      • /test for lit tests
      • /unittest for C++ tests
      • /python/test for end-to-end tests
    • This PR does not need a test because FILL THIS IN.
  • Select one of the following.

    • I have not added any lit tests.
    • The lit tests I have added follow these best practices,
      including the "tests should be minimal" section. (Usually running Python code
      and using the instructions it generates is not minimal.)

@github-actions github-actions Bot added compiler Changes to C/C++ compiler backend (lib/, include/) python Changes to Python runtime or bindings ascend-backend Changes to the Ascend NPU backend labels Aug 11, 2026
@245516766 245516766 changed the title Revert "[ControlFlowOpt](feat) decompose pointers across control flow… [Revert](fix) decompose pointers across control flow… Aug 11, 2026
@245516766 245516766 changed the title [Revert](fix) decompose pointers across control flow… [Revert](fix) revert [ControlFlowOpt](feat) decompose pointers across control flow (#1344) Aug 11, 2026
@github-actions

github-actions Bot commented Aug 11, 2026

Copy link
Copy Markdown
Contributor

🔍 OpenCodeReview found 6 issue(s) in this PR.

  • ✅ Successfully posted inline: 5 comment(s)
  • 📝 In summary (no line info): 1 comment(s)

[bug · critical]

📄 third_party/ascend/include/Utils/Utils.h

⚠️ GitHub could not post this as an inline comment: No line information provided

Same copy-paste bug in mulOpFoldResult: RHS side incorrectly uses lhsValue instead of rhsValue

Same pattern — RHS operand conversion uses lhsValue instead of rhsValue, causing arith::MulIOp to receive type-mismatched operands.

💡 Suggested Change

Before:

  if (rhsInt) {
    rhsValue = createConstIndexValueOp(loc, b, rhsInt.value());
  } else {
    lhsValue = convertToIndexIfNeeded(lhsValue, loc, b);
    assert(isa<IndexType>(lhsValue.getType()));
  }

After:

  if (rhsInt) {
    rhsValue = createConstIndexValueOp(loc, b, rhsInt.value());
  } else {
    rhsValue = convertToIndexIfNeeded(rhsValue, loc, b);
    assert(isa<IndexType>(rhsValue.getType()));
  }

Comment on lines 224 to 225
OpFoldResult subOpFoldResult(const OpFoldResult &lhs, const OpFoldResult &rhs,
const Location &loc, OpBuilder &b);

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

[bug · critical]
Same copy-paste bug in subOpFoldResult: RHS side incorrectly uses lhsValue instead of rhsValue

Same pattern as addOpFoldResult — when rhsInt is not set, lhsValue is converted again instead of rhsValue, causing rhsValue to retain its original non-index type, which will lead to MLIR verification failures for arith::SubIOp.

Suggestion:

Suggested change
OpFoldResult subOpFoldResult(const OpFoldResult &lhs, const OpFoldResult &rhs,
const Location &loc, OpBuilder &b);
if (rhsInt) {
rhsValue = createConstIndexValueOp(loc, b, rhsInt.value());
} else {
rhsValue = convertToIndexIfNeeded(rhsValue, loc, b);
assert(isa<IndexType>(rhsValue.getType()));
}

Comment on lines 230 to 231
OpFoldResult divOpFoldResult(const OpFoldResult &lhs, const OpFoldResult &rhs,
const Location &loc, OpBuilder &b);

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

[bug · critical]
Same copy-paste bug in divOpFoldResult: RHS side incorrectly uses lhsValue instead of rhsValue

Same pattern — RHS operand conversion uses lhsValue instead of rhsValue, causing arith::DivSIOp to receive type-mismatched operands.

Suggestion:

Suggested change
OpFoldResult divOpFoldResult(const OpFoldResult &lhs, const OpFoldResult &rhs,
const Location &loc, OpBuilder &b);
if (rhsInt) {
rhsValue = createConstIndexValueOp(loc, b, rhsInt.value());
} else {
rhsValue = convertToIndexIfNeeded(rhsValue, loc, b);
assert(isa<IndexType>(rhsValue.getType()));
}


bool isOne(const OpFoldResult ofr);

Value convertToIndexIfNeeded(Value intValue, const Location &loc, OpBuilder &b);

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

[bug · critical]
Copy-paste bug: RHS operand conversion incorrectly uses lhsValue instead of rhsValue

In the else branch handling the RHS (when rhsInt is falsy), the code converts lhsValue again instead of converting rhsValue. This means:

  • rhsValue remains unconverted (e.g., i32/i64 type instead of index type)
  • lhsValue gets re-converted (redundantly)
  • The subsequent arith::AddIOp receives operands with mismatched types, which will fail MLIR verification

This bug exists in all similar functions (subOpFoldResult, mulOpFoldResult, divOpFoldResult, remOpFoldResult, minOpFoldResult) — only maxOpFoldResult is correctly implemented.

Suggestion:

Suggested change
Value convertToIndexIfNeeded(Value intValue, const Location &loc, OpBuilder &b);
auto rhsValue = dyn_cast<Value>(rhs);
if (rhsInt) {
rhsValue = createConstIndexValueOp(loc, b, rhsInt.value());
} else {
rhsValue = convertToIndexIfNeeded(rhsValue, loc, b);
assert(isa<IndexType>(rhsValue.getType()));
}


bool isOne(const OpFoldResult ofr);

Value convertToIndexIfNeeded(Value intValue, const Location &loc, OpBuilder &b);

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

[bug · critical]
Same copy-paste bug in remOpFoldResult: RHS side incorrectly uses lhsValue instead of rhsValue

Same pattern — RHS operand conversion uses lhsValue instead of rhsValue, causing arith::RemSIOp to receive type-mismatched operands.

Suggestion:

Suggested change
Value convertToIndexIfNeeded(Value intValue, const Location &loc, OpBuilder &b);
if (rhsInt) {
rhsValue = createConstIndexValueOp(loc, b, rhsInt.value());
} else {
rhsValue = convertToIndexIfNeeded(rhsValue, loc, b);
assert(isa<IndexType>(rhsValue.getType()));
}


bool isOne(const OpFoldResult ofr);

Value convertToIndexIfNeeded(Value intValue, const Location &loc, OpBuilder &b);

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

[bug · critical]
Same copy-paste bug in minOpFoldResult: RHS side incorrectly uses lhsValue instead of rhsValue

Same pattern — RHS operand conversion uses lhsValue instead of rhsValue, causing arith::MinSIOp to receive type-mismatched operands.

Suggestion:

Suggested change
Value convertToIndexIfNeeded(Value intValue, const Location &loc, OpBuilder &b);
if (rhsInt) {
rhsValue = createConstIndexValueOp(loc, b, rhsInt.value());
} else {
rhsValue = convertToIndexIfNeeded(rhsValue, loc, b);
assert(isa<IndexType>(rhsValue.getType()));
}

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

ascend-backend Changes to the Ascend NPU backend compiler Changes to C/C++ compiler backend (lib/, include/) python Changes to Python runtime or bindings

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant