Skip to content

[Hexagon] Flip subreg bit for reverse pairs hvx .new #75873

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Merged
merged 2 commits into from
Jan 18, 2024
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 2 additions & 0 deletions llvm/lib/Target/Hexagon/Disassembler/HexagonDisassembler.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -512,6 +512,8 @@ DecodeStatus HexagonDisassembler::getSingleInstruction(MCInst &MI, MCInst &MCB,
const bool Rev = HexagonMCInstrInfo::IsReverseVecRegPair(Producer);
const unsigned ProdPairIndex =
Rev ? Producer - Hexagon::WR0 : Producer - Hexagon::W0;
if (Rev)
SubregBit = !SubregBit;
Producer = (ProdPairIndex << 1) + SubregBit + Hexagon::V0;
} else if (SubregBit)
// Hexagon PRM 10.11 New-value operands
Expand Down
6 changes: 4 additions & 2 deletions llvm/lib/Target/Hexagon/MCTargetDesc/HexagonMCInstrInfo.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -1036,8 +1036,10 @@ unsigned HexagonMCInstrInfo::SubregisterBit(unsigned Consumer,
unsigned Producer2) {
// If we're a single vector consumer of a double producer, set subreg bit
// based on if we're accessing the lower or upper register component
if (IsVecRegPair(Producer) && IsVecRegSingle(Consumer))
return (Consumer - Hexagon::V0) & 0x1;
if (IsVecRegPair(Producer) && IsVecRegSingle(Consumer)) {
unsigned Rev = IsReverseVecRegPair(Producer);
return ((Consumer - Hexagon::V0) & 0x1) ^ Rev;
}
if (Producer2 != Hexagon::NoRegister)
return Consumer == Producer;
return 0;
Expand Down
18 changes: 18 additions & 0 deletions llvm/test/MC/Hexagon/hvx-nv-pair-reverse.s
Original file line number Diff line number Diff line change
@@ -0,0 +1,18 @@
# RUN: llvm-mc -triple=hexagon -mv69 -mhvx -filetype=obj %s | \
# RUN: llvm-objdump --triple=hexagon --mcpu=hexagonv69 --mattr=+hvx -d - | \
# RUN: FileCheck %s
# CHECK: 00000000 <.text>:

{
V4:5.w = vadd(V1:0.w, V3:2.w)
vmem(r0+#0) = v4.new
}
# CHECK-NEXT: 1c6240c5 { v4:5.w = vadd(v1:0.w,v3:2.w)
# CHECK-NEXT: 2820c023 vmem(r0+#0x0) = v4.new }

{
V4:5.w = vadd(V1:0.w, V3:2.w)
vmem(r0+#0) = v5.new
}
# CHECK-NEXT: 1c6240c5 { v4:5.w = vadd(v1:0.w,v3:2.w)
# CHECK-NEXT: 2820c022 vmem(r0+#0x0) = v5.new }