[PATCH] D150440: [X86][MC] Optimize more instructions from VEX3 to VEX2 and fix the incorrect control flow in X86MCInstLower

Kan Shengchen via Phabricator via llvm-commits llvm-commits at lists.llvm.org
Fri May 12 05:37:03 PDT 2023


skan created this revision.
Herald added subscribers: pengfei, dmgreen, gbedwell, hiraditya.
Herald added a reviewer: andreadb.
Herald added a project: All.
skan requested review of this revision.
Herald added a project: LLVM.
Herald added a subscriber: llvm-commits.

`X86MCInstLower::Lower` has a huge switch-cases, from which D150068 <https://reviews.llvm.org/D150068> removed
`VMOVSS`. It caused the unoptimized VMOVSS to wrongly fall
to the default label. The default label exchanged the 1st and 2nd
operand, but we should exchange the 0th and 2nd operand.

In this patch, we move the code in the default lable about "VEX3 to
VEX2" to the function `X86::optimizeInstFromVEX3ToVEX2` to fix the bug.

Since the function is shared, a side effect is that more encoding
optimizations are done on the Asmparser side. Considering we already
use reverse-encoding for optimization in AsmParser before this patch,
I believe the change is positive and expected.


Repository:
  rG LLVM Github Monorepo

https://reviews.llvm.org/D150440

Files:
  llvm/lib/Target/X86/AsmParser/X86AsmParser.cpp
  llvm/lib/Target/X86/MCTargetDesc/X86EncodingOptimization.cpp
  llvm/lib/Target/X86/MCTargetDesc/X86EncodingOptimization.h
  llvm/lib/Target/X86/X86MCInstLower.cpp
  llvm/test/MC/X86/x86_64-avx-encoding.s
  llvm/test/tools/llvm-mca/X86/show-encoding.s

-------------- next part --------------
A non-text attachment was scrubbed...
Name: D150440.521614.patch
Type: text/x-patch
Size: 8776 bytes
Desc: not available
URL: <http://lists.llvm.org/pipermail/llvm-commits/attachments/20230512/19acddb5/attachment.bin>


More information about the llvm-commits mailing list