Re: [PATCH] x86: Check XMM destination when optimizing 128-bit VPBROADCASTQ

Project / Subsystem

binutils / x86

Date

2026-05-27

Proposer

H.J. Lu <hjl.tools@gmail.com>

Source type

public_inbox

Consensus

Committed

Sentiment

/10

Technical tradeoffs

  • The fix adds a check for XMM destination, which may slightly increase the overhead of the optimization process, but it prevents incorrect code generation.

All attributes

project
binutils
subsystem
x86
patch_id
discussion_id
CAMe9rOqa0uyxS_U2eQYQxZYsDx+_srnsLrZ7f72Y4hxkCjpVvA@mail.gmail.com
source_type
public_inbox
title
Re: [PATCH] x86: Check XMM destination when optimizing 128-bit VPBROADCASTQ
headline
x86: Check XMM destination when optimizing 128-bit VPBROADCASTQ
tldr
Fixes a bug where 256-bit VPBROADCASTQ instructions were incorrectly optimized to 128-bit VPUNPCKLQDQ instructions by checking for XMM destination.
proposer
H.J. Lu <hjl.tools@gmail.com>
consensus
Committed
outcome
committed
sentiment_score
technical_tradeoffs
  • The fix adds a check for XMM destination, which may slightly increase the overhead of the optimization process, but it prevents incorrect code generation.
series_id
series_role
standalone
series_parts
[]
tags
  • x86
  • assembler
  • optimization
  • VPBROADCASTQ
  • AVX2
bugzilla_url
date
2026-05-27T00:00:00.000Z

Re: [PATCH] x86: Check XMM destination when optimizing 128-bit VPBROADCASTQ

H.J. Lu fixed a bug in the x86 assembler where the optimization of 128-bit VPBROADCASTQ instructions could lead to incorrect code generation when the destination operand was a YMM register. The original optimization, intended to replace vpbroadcastq %xmmN, %xmmM with vpunpcklqdq %xmmN, %xmmN, %xmmM (N < 8), failed to check if the destination operand was an XMM register. This resulted in 256-bit vpbroadcastq %xmmN, %ymmM being incorrectly transformed into vpunpcklqdq %xmmN, %xmmN, %xmmM. The fix adds a check for XMM destination to prevent this incorrect optimization.