1# RUN: llvm-mc -triple=hexagon < %s 2>%t ; \
2# RUN:     FileCheck %s < %t --check-prefix=CHECK-STRICT
3# RUN: llvm-mc -triple=hexagon -relax-nv-checks < %s 2>%t ; \
4# RUN:     FileCheck %s < %t --check-prefix=CHECK-RELAXED
5
6# CHECK-STRICT: :12:1: error: register `R0' used with `.new' but not validly modified in the same packet
7# CHECK-RELAXED: :12:1: error: register `R0' used with `.new' but not validly modified in the same packet
8{
9  # invalid: r0 definition predicated on the opposite condition
10  if (p3) r0 = add(r1, r2)
11  if (!p3) memb(r20) = r0.new
12}
13
14# CHECK-STRICT: :20:1: error: register `R0' used with `.new' but not validly modified in the same packet
15# CHECK-RELAXED: :20:1: error: register `R0' used with `.new' but not validly modified in the same packet
16{
17  # invalid: new-value compare-and-jump cannot use floating point value
18  r0 = sfadd(r1, r2)
19  if (cmp.eq(r0.new, #0)) jump:nt .
20}
21
22# CHECK-STRICT: :29:1: error: register `R0' used with `.new' but not validly modified in the same packet
23# CHECK-RELAXED: :29:1: error: register `R0' used with `.new' but not validly modified in the same packet
24{
25  # invalid: definition of r0 should be unconditional (not explicitly docu-
26  # mented)
27  if (p0) r0 = r1
28  if (cmp.eq(r0.new, #0)) jump:nt .
29}
30
31
32# No errors from this point on with the relaxed checks.
33# CHECK-RELAXED-NOT: error
34
35# CHECK-STRICT: :41:1: error: register `R0' used with `.new' but not validly modified in the same packet
36{
37  # valid (relaxed): p2 and p3 cannot be proven to violate the new-value
38  # requirements
39  if (p3) r0 = add(r1, r2)
40  if (p2) memb(r20) = r0.new
41}
42
43# CHECK-STRICT: :48:1: error: register `R0' used with `.new' but not validly modified in the same packet
44{
45  # valid (relaxed): p3 could be always true
46  if (p3) r0 = add(r1, r2)
47  memb(r20) = r0.new
48}
49
50
51# No errors from this point on with the strict checks.
52# CHECK-RELAXED-NOT: error
53
54{
55  # valid: r0 defined unconditionally
56  r0 = add(r1, r2)
57  if (p2) memb(r20) = r0.new
58}
59
60{
61  # valid: r0 definition and use identically predicated
62  if (p3) r0 = add(r1, r2)
63  if (p3) memb(r20) = r0.new
64}
65
66{
67  # valid: r0 defined regardless of p0
68  if (p0) r0 = #0
69  if (!p0) r0 = #1
70  if (p0) memb(r20) = r0.new
71}
72
73