Skip to content

Align the root declare of a byte dst at byte 1 of its channel - #457

Open
maleadt wants to merge 1 commit into
intel:masterfrom
maleadt:fix-byte-dst-root-align
Open

maleadt wants to merge 1 commit into
intel:masterfrom
maleadt:fix-byte-dst-root-align

Conversation

@maleadt

@maleadt maleadt commented Oct 22, 2026 •

Copy link
Copy Markdown

Fixes #456.

HWConformity::fixDstAlignment accepts a byte destination that starts at byte 1 of its execution channel. It takes that offset from tryToAlignOperand but ignores the function's result. When the operand itself can't be aligned, tryToAlignOperand returns false before aligning the operand's root declare (BuildIRImpl.cpp). The reported offset is then only relative to the declare, which RA may still place anywhere its own (word) alignment allows. If RA puts it at byte 2 of a dword, the byte lands at byte 3. Gen12LP can't write a byte destination there for a dword execution type, so the value is lost.

The pattern comes from localDefHoisting. It folds a mov from a dword into element 1 of a 2-byte variable, mov (1|M0) r6.11<4>:b r6.4<0;1,0>:d on TGL. DG2 and MTL generate the same instruction but happened to place it at byte 1.

This aligns the root declare to the execution type in that case, using tryToAlignOperandRootDcl. Other cases are unchanged.

The new ocloc test optimizations/byte-dst-root-align.cl (REQUIRES: regkeys, tgllp-supported) checks that no byte destination of a dword channel starts at byte 2 or 3. I ran its FileCheck lines against the ocloc output with and without the fix (it fails, then passes), but haven't run the LIT suite.

I checked the fix by building it into libigc 2.41.5 (JuliaPackaging/Yggdrasil#15280) and testing on a Tiger Lake Iris Xe:

Assisted by: Opus 5.5

fixDstAlignment accepts a byte dst that starts at byte 1 of its execution
channel, using the offset tryToAlignOperand reports. But when the operand
itself can't be aligned, tryToAlignOperand returns without aligning its
root declare, so that offset only holds relative to a declare RA may still
place anywhere its own alignment allows. A word-aligned declare at byte 2
of a dword then puts the byte at byte 3, which Gen12LP doesn't support:
the byte isn't written. Align the root declare to the execution type in
that case.

Fixes intel#456.

This branch has not been deployed

No deployments
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.

Gen12LP: byte dst placed at byte 3 of a dword after localDefHoisting, wrong value stored

1 participant