Skip to content

fix[cartesian]: Scalarization of temporaries#2558

Open
romanc wants to merge 2 commits intoGridTools:mainfrom
romanc:romanc/fix-write-before-read-scalarization
Open

fix[cartesian]: Scalarization of temporaries#2558
romanc wants to merge 2 commits intoGridTools:mainfrom
romanc:romanc/fix-write-before-read-scalarization

Conversation

@romanc
Copy link
Copy Markdown
Contributor

@romanc romanc commented Mar 30, 2026

Description

Scalarization of read after write temporaries was eagerly scalarizing too many temporaries. If temporaries were written conditionaly, but read unconditionaly, the temporaries were still scalarized, leading to reads of undefined memory in case the condition for writing wasn't true.

This PR changes WriteBeforeReadTemporariesToScalars to never scalarize if the write is conditional. This is defensive in the sense that if the read had the same condition, we could still scalarize. That functionality can be added later if deemed necessary.

/cc @FlorianDeconinck

Requirements

  • All fixes and/or new features come with corresponding tests.
  • Important design decisions have been documented in the appropriate ADR inside the docs/development/ADRs/ folder.
    N/A

Scalarization of read after write temporaries was eagerly scalarizing
too many temporaries. If temporaries were written conditionaly, but read
unconditionaly, the temporaries were still scalarized, leading to reads
of undefined memory in case the condition for writing wasn't true.

This PR changes `WriteBeforeReadTemporariesToScalars` to never scalarize
if the write is conditional. This is defensive in the sense that if the
read had the same condition, we could still scalarize. That
functionality can be added later if deemed necessary.
@romanc romanc requested a review from twicki March 30, 2026 16:12
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.

1 participant