Align predicates for SSSE3/AVX2 pmulhrsw/smulhrs expanders
GCC now correctly aligns predicates for SSSE3/AVX2 vector multiplication expanders on i386, resolving an internal compiler error when handling unaligned memory.
This commit fixes an internal compiler error (ICE) in GCC on i386 related to vector multiplication, specifically for SSSE3 and AVX2 pmulhrsw and smulhrs instructions. The issue arose because a previous change updated the pattern predicates from nonimmediate_operand to vector_operand, but the corresponding expanders retained the old predicates. This discrepancy meant that when unaligned memory was involved, the pattern would not match while the expander tried to expand it directly as memory, leading to a crash. The fix updates the expander predicates to use vector_operand, aligning them with the patterns.
In Details
The GCC i386 backend uses .md files to define instruction patterns and their expanders. This commit addresses config/i386/sse.md, specifically predicates for <ssse3_avx2>_pmulhrsw<mode>3 and smulhrs<mode>3 expanders. The nonimmediate_operand predicate permits memory operands that are not necessarily register-aligned, whereas vector_operand allows only aligned vector registers or memory. The PR68991 fix changed patterns to vector_operand but left expanders with nonimmediate_operand. On targets without TARGET_AVX, this mismatch caused an ICE when unaligned memory was encount…
For Context
When you write code that performs complex calculations, such as multiplying many numbers in parallel using vector instructions (like those found in SSSE3 and AVX2 on Intel and AMD processors), compilers like GCC translate these operations into specific machine instructions. For these vector operations, GCC uses internal rules called "predicates" to decide how to generate the most efficient machine code. This commit fixes a bug where the compiler's rules for generating certain vector multiplication instructions (specifically pmulhrsw and smulhrs) were out of sync. One set of rules (for matching patterns) got updated to expect only aligned vector data, but the rules for actually generating the instructions (the "expanders") did not. This mismatch caused the compiler to crash when it encountered vector data that wasn't perfectly aligned in memory, leading to an "Internal Compiler Error." The fix updates the expander rules to match the pattern rules, preventing these crashes.