abrown added the bug label to Issue #10719.
abrown added the cranelift label to Issue #10719.
abrown opened issue #10719:
See the following existing compilation test:
A constant from the post-function pool is being loaded into
%xmm1, but the instruction that would use itpaddusb, then re-loads it as it writes into%xmm1. Now, themovdquseems correct in one sense: memory addresses to packed instructions must be 128-bit aligned so, when converting anXmmMemAlignedto anXmmMem, Cranelift inserts an unaligned load. But the direct use bypaddusbmight also be correct: we may be aligning the start of the constant pool and so this may be just fine.Either way, something is not quite right, though:
- if the constant pool is _not_ aligned or this can't be communicated to the instruction,
paddusbshould not be using the address directly- if the constant pool _is_ aligned and communicated properly, then the
movdquis redundant and should be removedWhich is it? I'm leaning towards the latter because of sequences like the following:
Those instructions have no trouble accessing the pool by aligned address... or are they incorrect?
cfallin commented on issue #10719:
The constant pool does align 128-bit constants: here and then used here.
I'm not sure I understand the "
movdquis redundant" point though: there are two constants here, and twomovdqus; the firstmovdquloads the same constant as thepaddusbdoes, but intoxmm0, notxmm1; the secondmovdquloads a different constant. It looks like it's true that thepaddusbdoesn't reuse the value inxmm0-- is that the part you mean?
abrown commented on issue #10719:
I should have narrowed down that code snippet to:
movdqu 0x1c(%rip), %xmm1 paddusb 0x24(%rip), %xmm1What I see is both of these instructions loading the same constant, only the offsets are different because the instructions each live at different
%riplocations. Does that make more sense?
cfallin commented on issue #10719:
Ah! OK, so it's a deduplication issue? I don't think we dedup 128-bit constants right now; I don't recall why not, off the top of my head. If we did that, then in theory it should be possible to GVN the two arguments...
Last updated: Dec 06 2025 at 06:05 UTC