[PATCH] D80073: [Hexagon] pX.new cannot be used with p3:0 as producer

Brian Cain via Phabricator via llvm-commits llvm-commits at lists.llvm.org
Sat May 16 19:37:12 PDT 2020


bcain created this revision.
bcain added a reviewer: sidneym.
Herald added a subscriber: hiraditya.
Herald added a project: LLVM.

Writes to p3:0 do not produce new values, we should bar any .new
consumer trying to use it as a producer.


Repository:
  rG LLVM Github Monorepo

https://reviews.llvm.org/D80073

Files:
  llvm/lib/Target/Hexagon/MCTargetDesc/HexagonMCChecker.cpp
  llvm/test/MC/Hexagon/c4_newval.s
  llvm/test/MC/Hexagon/multiple-pc4.s


Index: llvm/test/MC/Hexagon/multiple-pc4.s
===================================================================
--- /dev/null
+++ llvm/test/MC/Hexagon/multiple-pc4.s
@@ -0,0 +1,17 @@
+# RUN: llvm-mc -arch=hexagon -filetype=asm %s 2>%t; FileCheck --implicit-check-not=error %s <%t
+
+# Check that multiple changes to a predicate in a packet are caught.
+
+	{ p0 = cmp.eq (r0, r0); p3:0 = r0 }
+# CHECK: rror: register {{.+}} modified more than once
+
+	{ p0 = cmp.eq (r0, r0); c4 = r0 }
+# CHECK: rror: register {{.+}} modified more than once
+
+	p3:0 = r9
+# CHECK-NOT: rror: register {{.+}} modified more than once
+
+# Multiple writes to the same predicate register are permitted:
+
+	{ p0 = cmp.eq (r0, r0); p0 = and(p1, p2) }
+# CHECK-NOT: rror: register {{.+}} modified more than once
Index: llvm/test/MC/Hexagon/c4_newval.s
===================================================================
--- /dev/null
+++ llvm/test/MC/Hexagon/c4_newval.s
@@ -0,0 +1,19 @@
+# RUN: not llvm-mc -arch=hexagon %s 2>%t; FileCheck --implicit-check-not=error %s <%t
+
+.Lfoo:
+{ p3:0 = r0
+  if (!p0.new) jump:t .Lfoo }
+
+# CHECK: error: register `P0' used with `.new' but not validly modified in the same packet
+
+{ c4 = r0
+  if (!p0.new) jump:t .Lfoo }
+
+# CHECK: error: register `P0' used with `.new' but not validly modified in the same packet
+
+{ c4 = r0
+  p0 = r0
+  if (!p0.new) jump:t .Lfoo }
+
+# CHECK: error: register `P0' used with `.new' but not validly modified in the same packet
+# CHECK: error: register `P3_0' modified more than once
Index: llvm/lib/Target/Hexagon/MCTargetDesc/HexagonMCChecker.cpp
===================================================================
--- llvm/lib/Target/Hexagon/MCTargetDesc/HexagonMCChecker.cpp
+++ llvm/lib/Target/Hexagon/MCTargetDesc/HexagonMCChecker.cpp
@@ -391,7 +391,7 @@
   for (const auto &I : NewPreds) {
     unsigned P = I;
 
-    if (!Defs.count(P) || LatePreds.count(P)) {
+    if (!Defs.count(P) || LatePreds.count(P) || Defs.count(Hexagon::P3_0)) {
       // Error out if the new predicate register is not defined,
       // or defined "late"
       // (e.g., "{ if (p3.new)... ; p3 = sp1loop0(#r7:2, Rs) }").


-------------- next part --------------
A non-text attachment was scrubbed...
Name: D80073.264465.patch
Type: text/x-patch
Size: 2168 bytes
Desc: not available
URL: <http://lists.llvm.org/pipermail/llvm-commits/attachments/20200517/0b552f0f/attachment.bin>


More information about the llvm-commits mailing list