Skip to content

Commit 6599c02

Browse files
authored
[HEXAGON] Fix bit boundary for isub_hi in HexagonBitSimplify (#82336)
Use bit boundary of 32 for high subregisters in HexagonBitSimplify. This fixes the subregister used in an upper half register store.
1 parent 163eaf3 commit 6599c02

File tree

2 files changed

+23
-1
lines changed

2 files changed

+23
-1
lines changed

llvm/lib/Target/Hexagon/HexagonBitSimplify.cpp

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1957,7 +1957,8 @@ bool BitSimplification::genStoreUpperHalf(MachineInstr *MI) {
19571957
return false;
19581958
const BitTracker::RegisterCell &RC = BT.lookup(RS.Reg);
19591959
RegHalf H;
1960-
if (!matchHalf(0, RC, 0, H))
1960+
unsigned B = (RS.Sub == Hexagon::isub_hi) ? 32 : 0;
1961+
if (!matchHalf(0, RC, B, H))
19611962
return false;
19621963
if (H.Low)
19631964
return false;
Lines changed: 21 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,21 @@
1+
# RUN: llc -march=hexagon -run-pass=hexagon-bit-simplify -o - %s | FileCheck %s
2+
3+
# This test checks if the HexagonBitSimplify pass correctly replaces a
4+
# S2_storerh_io with a S2_storerf_io that stores the upper halfword
5+
# of a high subregister using appropriate subregister boundaries.
6+
7+
# CHECK: S2_storerf_io %0, 28, %{{[0-9]+}}.isub_hi
8+
# CHECK-NOT: S2_storerf_io %0, 28, %{{[0-9]+}}.isub_lo
9+
10+
---
11+
name: test_store
12+
tracksRegLiveness: true
13+
body: |
14+
bb.0:
15+
liveins: $r0
16+
%0:intregs = COPY $r0
17+
%1:doubleregs = IMPLICIT_DEF
18+
%2:doubleregs = IMPLICIT_DEF
19+
%3:doubleregs = S2_shuffoh %2, %1
20+
S2_storerh_io %0, 28, %3.isub_hi
21+
...

0 commit comments

Comments
 (0)