Skip to content

Commit 86ef9ee

Browse files
[HEXAGON] Enable Utilize Mask Instruction Pass only if the Arch (#102880)
version is greater than v66 No support for mask instruction before arch version v66
1 parent 7030280 commit 86ef9ee

File tree

2 files changed

+29
-0
lines changed

2 files changed

+29
-0
lines changed

llvm/lib/Target/Hexagon/HexagonMask.cpp

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -90,6 +90,9 @@ bool HexagonMask::runOnMachineFunction(MachineFunction &MF) {
9090

9191
if (!F.hasFnAttribute(Attribute::OptimizeForSize))
9292
return false;
93+
// Mask instruction is available only from v66
94+
if (!HST.hasV66Ops())
95+
return false;
9396
// The mask instruction available in v66 can be used to generate values in
9497
// registers using 2 immediates Eg. to form 0x07fffffc in R0, you would write
9598
// "R0 = mask(#25,#2)" Since it is a single-word instruction, it takes less
Lines changed: 26 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,26 @@
1+
; Enable Utlilize mask instruction pass only on v66 and above.
2+
; RUN: llc -mv60 -march=hexagon < %s -o /dev/null
3+
4+
target datalayout = "e-m:e-p:32:32:32-a:0-n16:32-i64:64:64-i32:32:32-i16:16:16-i1:8:8-f32:32:32-f64:64:64-v32:32:32-v64:64:64-v512:512:512-v1024:1024:1024-v2048:2048:2048"
5+
target triple = "hexagon"
6+
7+
@b = dso_local local_unnamed_addr global i8 0, align 1
8+
@a = dso_local local_unnamed_addr global i32 0, align 4
9+
10+
; Function Attrs: cold nounwind optsize memory(readwrite, argmem: none, inaccessiblemem: none)
11+
define dso_local void @c() local_unnamed_addr {
12+
entry:
13+
%0 = tail call i32 asm "", "=&r"()
14+
%and = and i32 %0, 134217727
15+
%tobool.not = icmp eq i32 %and, 0
16+
br i1 %tobool.not, label %if.end, label %if.then
17+
18+
if.then: ; preds = %entry
19+
%1 = load i8, ptr @b, align 1
20+
%loadedv = zext nneg i8 %1 to i32
21+
store i32 %loadedv, ptr @a, align 4
22+
br label %if.end
23+
24+
if.end: ; preds = %if.then, %entry
25+
ret void
26+
}

0 commit comments

Comments
 (0)