Skip to content

Repair transformation legality checks - #58

Open
lm-sousa wants to merge 143 commits into
fix/transformation-legality-checksfrom
fix/repair-transformation-legality-checks
Open

Repair transformation legality checks#58
lm-sousa wants to merge 143 commits into
fix/transformation-legality-checksfrom
fix/repair-transformation-legality-checks

Conversation

@lm-sousa

@lm-sousa lm-sousa commented Aug 4, 2026

Copy link
Copy Markdown
Member

The stacked parent PR exposed several fundamental correctness problems: traversal errors were swallowed, legality checks inspected rendered source, loop relationships were inferred from iterator names or proxy identity, and several joinpoints did not carry their backing AST nodes. That made transformations silently skip nodes or approve unsafe rewrites.

This layer repairs those invariants with AST-based, conservative legality checks and adds focused regressions for dependencies, explicit loop steps, nested bounds, reused iterator names, and real 3mm transformations.

Validation:

  • npm run build
  • npm run lint
  • API tests: 3 suites, 13 tests passed

Model: OpenAI Codex (gpt-5.6-luna), operating as the implementation agent.

Process-ing and others added 26 commits August 4, 2026 15:02
Co-authored-by: Copilot Autofix powered by AI <175728472+Copilot@users.noreply.github.com>
Updates repository name of push-mirror
…rmation-legality-checks

# Conflicts:
#	.github/workflows/nightly.yml
Copilot AI lite review requested due to automatic review settings August 4, 2026 16:52

Copilot AI left a comment

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.

Copilot wasn't able to review this pull request because it exceeds the maximum number of lines (20,000). Try reducing the number of changed lines and requesting a review from Copilot again.

@lm-sousa lm-sousa changed the title fix/repair transformation legality checks Repair transformation legality checks Aug 4, 2026

@chatgpt-codex-connector chatgpt-codex-connector Bot left a comment

Copy link
Copy Markdown

Choose a reason for hiding this comment

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

💡 Codex Review

Here are some automated review suggestions for this pull request.

Reviewed commit: 48cff8e5db

ℹ️ About Codex in GitHub

Your team has set up Codex to review pull requests in this repo. Reviews are triggered when you

  • Open a pull request for review
  • Mark a draft as ready
  • Comment "@codex review".

If Codex has suggestions, it will comment; otherwise it will react with 👍.

Codex can also answer questions or update the PR. Try commenting "@codex address that feedback".

Comment on lines +179 to +181
const reads = arrayNames(summary.arrayReads);
const writes = arrayNames(summary.arrayWrites);
return intersects(reads, writes);

Copy link
Copy Markdown

Choose a reason for hiding this comment

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

P1 Badge Treat write-after-write hazards as loop-carried dependencies

Reject repeated writes to the same array when changing loop order, not only read/write intersections. For example, interchanging do i; do j; A(i+j)=i changes which (i,j) pair writes each overlapping element last, but this summary has array writes and no array reads, so both canInterchange and canTile currently accept it and can silently change results.

Useful? React with 👍 / 👎.

Comment on lines +81 to +85
if (variable instanceof ArraySubscriptExpr) {
result.arrayWrites.push({ name: variable.var.name });
for (const name of scalarReferences(variable)) {
result.scalarReads.add(name);
}

Copy link
Copy Markdown

Choose a reason for hiding this comment

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

P1 Badge Record array reads used in assignment subscripts

Include nested array accesses on the left-hand side in arrayReads. In a fusion candidate where the first loop assigns A(B(i)) and the second writes B(i+1), the original first loop reads every old B value before any writes, whereas the fused loop can read a value written by the preceding iteration; because scalarReferences(variable) excludes array bases and only RHS arrays are added to arrayReads, this dependency is missed and the loops are incorrectly fused.

Useful? React with 👍 / 👎.

Comment on lines +187 to +189
if (reference.var.name === name) return true;
} else if (reference.name === name) {
return true;

Copy link
Copy Markdown

Choose a reason for hiding this comment

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

P1 Badge Compare Fortran identifiers case-insensitively

Normalize identifier case before testing references because Fortran identifiers are case-insensitive and the parser preserves source spelling. If the outer iterator is written as i while an inner bound refers to I, this exact comparison misses the reference, allowing interchange or tiling of a triangular iteration space and changing the executed iterations; the same issue affects dependency summaries containing mixed-case uses.

Useful? React with 👍 / 👎.

Comment on lines +111 to +115
function freshName(preferred: string, usedNames: Set<string>): string {
let name = preferred;
let suffix = 2;
while (usedNames.has(name)) {
name = `${preferred}_${suffix}`;

Copy link
Copy Markdown

Choose a reason for hiding this comment

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

P1 Badge Make generated tile-name collision checks case-insensitive

Check usedNames using normalized Fortran identifiers. With a loop variable i and an existing declaration such as I_TILE, the set does not consider generated i_tile occupied, so tiling reuses the existing variable as its tile counter and can overwrite user state or alter loop bounds.

Useful? React with 👍 / 👎.

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

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

5 participants