Skip to content

Commit cfba1a9

Browse files
committed
[Hexagon] pX.new cannot be used with p3:0 as producer
Writes to p3:0 do not produce new values, we should bar any .new consumer trying to use it as a producer.
1 parent b47d1ba commit cfba1a9

File tree

3 files changed

+37
-1
lines changed

3 files changed

+37
-1
lines changed

llvm/lib/Target/Hexagon/MCTargetDesc/HexagonMCChecker.cpp

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -391,7 +391,7 @@ bool HexagonMCChecker::checkPredicates() {
391391
for (const auto &I : NewPreds) {
392392
unsigned P = I;
393393

394-
if (!Defs.count(P) || LatePreds.count(P)) {
394+
if (!Defs.count(P) || LatePreds.count(P) || Defs.count(Hexagon::P3_0)) {
395395
// Error out if the new predicate register is not defined,
396396
// or defined "late"
397397
// (e.g., "{ if (p3.new)... ; p3 = sp1loop0(#r7:2, Rs) }").

llvm/test/MC/Hexagon/c4_newval.s

Lines changed: 19 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,19 @@
1+
# RUN: not llvm-mc -arch=hexagon %s 2>%t; FileCheck --implicit-check-not=error %s <%t
2+
3+
.Lfoo:
4+
{ p3:0 = r0
5+
if (!p0.new) jump:t .Lfoo }
6+
7+
# CHECK: error: register `P0' used with `.new' but not validly modified in the same packet
8+
9+
{ c4 = r0
10+
if (!p0.new) jump:t .Lfoo }
11+
12+
# CHECK: error: register `P0' used with `.new' but not validly modified in the same packet
13+
14+
{ c4 = r0
15+
p0 = r0
16+
if (!p0.new) jump:t .Lfoo }
17+
18+
# CHECK: error: register `P0' used with `.new' but not validly modified in the same packet
19+
# CHECK: error: register `P3_0' modified more than once

llvm/test/MC/Hexagon/multiple-pc4.s

Lines changed: 17 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,17 @@
1+
# RUN: llvm-mc -arch=hexagon -filetype=asm %s 2>%t; FileCheck --implicit-check-not=error %s <%t
2+
3+
# Check that multiple changes to a predicate in a packet are caught.
4+
5+
{ p0 = cmp.eq (r0, r0); p3:0 = r0 }
6+
# CHECK: rror: register {{.+}} modified more than once
7+
8+
{ p0 = cmp.eq (r0, r0); c4 = r0 }
9+
# CHECK: rror: register {{.+}} modified more than once
10+
11+
p3:0 = r9
12+
# CHECK-NOT: rror: register {{.+}} modified more than once
13+
14+
# Multiple writes to the same predicate register are permitted:
15+
16+
{ p0 = cmp.eq (r0, r0); p0 = and(p1, p2) }
17+
# CHECK-NOT: rror: register {{.+}} modified more than once

0 commit comments

Comments
 (0)