aboutsummaryrefslogtreecommitdiff
path: root/gas
diff options
context:
space:
mode:
authorClaudiu Zissulescu <claziss@synopsys.com>2017-02-15 11:57:51 +0100
committerClaudiu Zissulescu <claziss@synopsys.com>2017-02-15 12:02:28 +0100
commitcc07cda69e26ef28895086e1f214ddd1d3cb939d (patch)
treec221de4efbefdc22bec9a4178caa306784847d40 /gas
parent7c723eecec713e1de9a95017aac29a40f3b9853a (diff)
downloadgdb-cc07cda69e26ef28895086e1f214ddd1d3cb939d.zip
gdb-cc07cda69e26ef28895086e1f214ddd1d3cb939d.tar.gz
gdb-cc07cda69e26ef28895086e1f214ddd1d3cb939d.tar.bz2
[ARC] Fix assembler relaxation.
Fix assembler relaxation step for add, ld, mov, mpy and sub instructions. Add tests to it. gas/ 2017-02-15 Claudiu Zissulescu <claziss@synopsys.com> * config/tc-arc.c (md_convert_frag): Remove @pcl relocation information from input expression. (assemble_insn): Make sure pcrel is correctly set. (arc_pcrel_adjust): Compensate for PCL rounding. * testsuite/gas/arc/relax-add01.d: New file. * testsuite/gas/arc/relax-add01.s: Likewise. * testsuite/gas/arc/relax-add02.d: Likewise. * testsuite/gas/arc/relax-add02.s: Likewise. * testsuite/gas/arc/relax-add03.d: Likewise. * testsuite/gas/arc/relax-add03.s: Likewise. * testsuite/gas/arc/relax-add04.d: Likewise. * testsuite/gas/arc/relax-add04.s: Likewise. * testsuite/gas/arc/relax-ld01.d: Likewise. * testsuite/gas/arc/relax-ld01.s: Likewise. * testsuite/gas/arc/relax-ld02.d: Likewise. * testsuite/gas/arc/relax-ld02.s: Likewise. * testsuite/gas/arc/relax-mov01.d: Likewise. * testsuite/gas/arc/relax-mov01.s: Likewise. * testsuite/gas/arc/relax-mov02.d: Likewise. * testsuite/gas/arc/relax-mov02.s: Likewise. * testsuite/gas/arc/relax-mpy01.d: Likewise. * testsuite/gas/arc/relax-mpy01.s: Likewise. * testsuite/gas/arc/relax-sub01.d: Likewise. * testsuite/gas/arc/relax-sub01.s: Likewise. * testsuite/gas/arc/relax-sub02.d: Likewise. * testsuite/gas/arc/relax-sub02.s: Likewise. * testsuite/gas/arc/relax-sub03.d: Likewise. * testsuite/gas/arc/relax-sub03.s: Likewise. * testsuite/gas/arc/relax-sub04.d: Likewise. * testsuite/gas/arc/relax-sub04.s: Likewise. opcodes/ 2017-02-15 Claudiu Zissulescu <claziss@synopsys.com> * arc-opc.c (UIMM6_20R): Define. (SIMM12_20): Use above. (SIMM12_20R): Define. (SIMM3_5_S): Use above. (UIMM7_A32_11R_S): Define. (UIMM7_9_S): Use above. (UIMM3_13R_S): Define. (SIMM11_A32_7_S): Use above. (SIMM9_8R): Define. (UIMM10_A32_8_S): Use above. (UIMM8_8R_S): Define. (W6): Use above. (arc_relax_opcodes): Use all above defines.
Diffstat (limited to 'gas')
-rw-r--r--gas/ChangeLog33
-rw-r--r--gas/config/tc-arc.c41
-rw-r--r--gas/testsuite/gas/arc/relax-add01.d14
-rw-r--r--gas/testsuite/gas/arc/relax-add01.s9
-rw-r--r--gas/testsuite/gas/arc/relax-add02.d14
-rw-r--r--gas/testsuite/gas/arc/relax-add02.s8
-rw-r--r--gas/testsuite/gas/arc/relax-add03.d13
-rw-r--r--gas/testsuite/gas/arc/relax-add03.s8
-rw-r--r--gas/testsuite/gas/arc/relax-add04.d14
-rw-r--r--gas/testsuite/gas/arc/relax-add04.s8
-rw-r--r--gas/testsuite/gas/arc/relax-ld01.d15
-rw-r--r--gas/testsuite/gas/arc/relax-ld01.s9
-rw-r--r--gas/testsuite/gas/arc/relax-ld02.d14
-rw-r--r--gas/testsuite/gas/arc/relax-ld02.s9
-rw-r--r--gas/testsuite/gas/arc/relax-mov01.d14
-rw-r--r--gas/testsuite/gas/arc/relax-mov01.s8
-rw-r--r--gas/testsuite/gas/arc/relax-mov02.d14
-rw-r--r--gas/testsuite/gas/arc/relax-mov02.s8
-rw-r--r--gas/testsuite/gas/arc/relax-mpy01.d14
-rw-r--r--gas/testsuite/gas/arc/relax-mpy01.s8
-rw-r--r--gas/testsuite/gas/arc/relax-sub01.d14
-rw-r--r--gas/testsuite/gas/arc/relax-sub01.s9
-rw-r--r--gas/testsuite/gas/arc/relax-sub02.d14
-rw-r--r--gas/testsuite/gas/arc/relax-sub02.s9
-rw-r--r--gas/testsuite/gas/arc/relax-sub03.d13
-rw-r--r--gas/testsuite/gas/arc/relax-sub03.s8
-rw-r--r--gas/testsuite/gas/arc/relax-sub04.d14
-rw-r--r--gas/testsuite/gas/arc/relax-sub04.s8
28 files changed, 355 insertions, 9 deletions
diff --git a/gas/ChangeLog b/gas/ChangeLog
index 2f17687..1844085 100644
--- a/gas/ChangeLog
+++ b/gas/ChangeLog
@@ -1,3 +1,36 @@
+2017-02-15 Claudiu Zissulescu <claziss@synopsys.com>
+
+ * config/tc-arc.c (md_convert_frag): Remove @pcl relocation
+ information from input expression.
+ (assemble_insn): Make sure pcrel is correctly set.
+ (arc_pcrel_adjust): Compensate for PCL rounding.
+ * testsuite/gas/arc/relax-add01.d: New file.
+ * testsuite/gas/arc/relax-add01.s: Likewise.
+ * testsuite/gas/arc/relax-add02.d: Likewise.
+ * testsuite/gas/arc/relax-add02.s: Likewise.
+ * testsuite/gas/arc/relax-add03.d: Likewise.
+ * testsuite/gas/arc/relax-add03.s: Likewise.
+ * testsuite/gas/arc/relax-add04.d: Likewise.
+ * testsuite/gas/arc/relax-add04.s: Likewise.
+ * testsuite/gas/arc/relax-ld01.d: Likewise.
+ * testsuite/gas/arc/relax-ld01.s: Likewise.
+ * testsuite/gas/arc/relax-ld02.d: Likewise.
+ * testsuite/gas/arc/relax-ld02.s: Likewise.
+ * testsuite/gas/arc/relax-mov01.d: Likewise.
+ * testsuite/gas/arc/relax-mov01.s: Likewise.
+ * testsuite/gas/arc/relax-mov02.d: Likewise.
+ * testsuite/gas/arc/relax-mov02.s: Likewise.
+ * testsuite/gas/arc/relax-mpy01.d: Likewise.
+ * testsuite/gas/arc/relax-mpy01.s: Likewise.
+ * testsuite/gas/arc/relax-sub01.d: Likewise.
+ * testsuite/gas/arc/relax-sub01.s: Likewise.
+ * testsuite/gas/arc/relax-sub02.d: Likewise.
+ * testsuite/gas/arc/relax-sub02.s: Likewise.
+ * testsuite/gas/arc/relax-sub03.d: Likewise.
+ * testsuite/gas/arc/relax-sub03.s: Likewise.
+ * testsuite/gas/arc/relax-sub04.d: Likewise.
+ * testsuite/gas/arc/relax-sub04.s: Likewise.
+
2017-02-09 Vineet Gupta <vgupta@synopsys.com>
* testsuite/gas/arc/st.d: Update for 0xe having a name now
diff --git a/gas/config/tc-arc.c b/gas/config/tc-arc.c
index 9a3b26b..a1fd71d 100644
--- a/gas/config/tc-arc.c
+++ b/gas/config/tc-arc.c
@@ -2773,7 +2773,7 @@ insert_operand (unsigned long long insn,
val, min, max, file, line);
}
- pr_debug ("insert field: %ld <= %ld <= %ld in 0x%08llx\n",
+ pr_debug ("insert field: %ld <= %lld <= %ld in 0x%08llx\n",
min, val, max, insn);
if ((operand->flags & ARC_OPERAND_ALIGNED32)
@@ -3910,12 +3910,22 @@ assemble_insn (const struct arc_opcode *opcode,
reloc = ARC_RELOC_TABLE (t->X_md)->reloc;
break;
case O_pcl:
- reloc = ARC_RELOC_TABLE (t->X_md)->reloc;
- if (arc_opcode_len (opcode) == 2
- || opcode->insn_class == JUMP)
- as_bad_where (frag_now->fr_file, frag_now->fr_line,
- _("Unable to use @pcl relocation for insn %s"),
- opcode->name);
+ if (operand->flags & ARC_OPERAND_LIMM)
+ {
+ reloc = ARC_RELOC_TABLE (t->X_md)->reloc;
+ if (arc_opcode_len (opcode) == 2
+ || opcode->insn_class == JUMP)
+ as_bad_where (frag_now->fr_file, frag_now->fr_line,
+ _("Unable to use @pcl relocation for insn %s"),
+ opcode->name);
+ }
+ else
+ {
+ /* This is a relaxed operand which initially was
+ limm, choose whatever we have defined in the
+ opcode as reloc. */
+ reloc = operand->default_reloc;
+ }
break;
case O_sda:
reloc = find_reloc ("sda", opcode->name,
@@ -3975,7 +3985,15 @@ assemble_insn (const struct arc_opcode *opcode,
fixup = &insn->fixups[insn->nfixups++];
fixup->exp = *t;
fixup->reloc = reloc;
- pcrel = (operand->flags & ARC_OPERAND_PCREL) ? 1 : 0;
+ if ((int) reloc < 0)
+ pcrel = (operand->flags & ARC_OPERAND_PCREL) ? 1 : 0;
+ else
+ {
+ reloc_howto_type *reloc_howto =
+ bfd_reloc_type_lookup (stdoutput,
+ (bfd_reloc_code_real_type) fixup->reloc);
+ pcrel = reloc_howto->pc_relative;
+ }
fixup->pcrel = pcrel;
fixup->islong = (operand->flags & ARC_OPERAND_LIMM) ?
TRUE : FALSE;
@@ -4234,10 +4252,15 @@ arc_frob_label (symbolS * sym)
int
arc_pcrel_adjust (fragS *fragP)
{
+ pr_debug ("arc_pcrel_adjust: address=%ld, fix=%ld, PCrel %s\n",
+ fragP->fr_address, fragP->fr_fix,
+ fragP->tc_frag_data.pcrel ? "Y" : "N");
+
if (!fragP->tc_frag_data.pcrel)
return fragP->fr_address + fragP->fr_fix;
- return 0;
+ /* Take into account the PCL rounding. */
+ return (fragP->fr_address + fragP->fr_fix) & 0x03;
}
/* Initialize the DWARF-2 unwind information for this procedure. */
diff --git a/gas/testsuite/gas/arc/relax-add01.d b/gas/testsuite/gas/arc/relax-add01.d
new file mode 100644
index 0000000..13f3390
--- /dev/null
+++ b/gas/testsuite/gas/arc/relax-add01.d
@@ -0,0 +1,14 @@
+#as: -mrelax
+#objdump: -dr
+
+.*: +file format .*arc.*
+
+
+Disassembly of section .text:
+
+00000000 <.text>:
+ 0: 2740 7401 add r1,pcl,0x10
+ 4: 264a 7000\s+.*
+ 8: 264a 7000\s+.*
+ c: 264a 7000\s+.*
+ 10: 2000 0000 add r0,r0,r0
diff --git a/gas/testsuite/gas/arc/relax-add01.s b/gas/testsuite/gas/arc/relax-add01.s
new file mode 100644
index 0000000..d27ee6a
--- /dev/null
+++ b/gas/testsuite/gas/arc/relax-add01.s
@@ -0,0 +1,9 @@
+;;; Check relaxation from add rA,rB,limm@pcl -> add rA,rB, uimm6@pcl
+ .cpu EM
+ add r1,pcl,@.L1@pcl
+ nop
+ nop
+ nop
+ .align 4
+.L1:
+ add r0,r0,r0
diff --git a/gas/testsuite/gas/arc/relax-add02.d b/gas/testsuite/gas/arc/relax-add02.d
new file mode 100644
index 0000000..b2e419d
--- /dev/null
+++ b/gas/testsuite/gas/arc/relax-add02.d
@@ -0,0 +1,14 @@
+#as: -mrelax
+#objdump: -dr
+
+.*: +file format .*arc.*
+
+
+Disassembly of section .text:
+
+00000000 <.text>:
+ 0: 2540 0401 add r1,r5,0x10
+ 4: 264a 7000\s+.*
+ 8: 264a 7000\s+.*
+ c: 264a 7000\s+.*
+ 10: 2000 0000 add r0,r0,r0
diff --git a/gas/testsuite/gas/arc/relax-add02.s b/gas/testsuite/gas/arc/relax-add02.s
new file mode 100644
index 0000000..552c55f
--- /dev/null
+++ b/gas/testsuite/gas/arc/relax-add02.s
@@ -0,0 +1,8 @@
+;;; Check relaxation from add rA,rB,limm (PCL) -> add rA,rB, uimm6@pcl
+ .cpu EM
+ add r1,r5,@.L1 - .
+ nop
+ nop
+ nop
+.L1:
+ add r0,r0,r0
diff --git a/gas/testsuite/gas/arc/relax-add03.d b/gas/testsuite/gas/arc/relax-add03.d
new file mode 100644
index 0000000..35e0bca
--- /dev/null
+++ b/gas/testsuite/gas/arc/relax-add03.d
@@ -0,0 +1,13 @@
+#as: -mrelax
+#objdump: -dr
+
+.*: +file format .*arc.*
+
+
+Disassembly of section .text:
+
+00000000 <.text>:
+ 0: 264a 7000\s+.*
+ 4: 2240 0201 add r1,r2,0x8
+ 8: 264a 7000\s+.*
+ c: 2000 0000 add r0,r0,r0
diff --git a/gas/testsuite/gas/arc/relax-add03.s b/gas/testsuite/gas/arc/relax-add03.s
new file mode 100644
index 0000000..279fa4f
--- /dev/null
+++ b/gas/testsuite/gas/arc/relax-add03.s
@@ -0,0 +1,8 @@
+;;; Check relaxation from add rA,rB,limm@pcl -> add_s rC,B, uimm3@pcl
+ .cpu EM
+ nop
+ add r1,r2,@.L1@pcl
+ nop
+ .align 4
+.L1:
+ add r0,r0,r0
diff --git a/gas/testsuite/gas/arc/relax-add04.d b/gas/testsuite/gas/arc/relax-add04.d
new file mode 100644
index 0000000..bb1697c
--- /dev/null
+++ b/gas/testsuite/gas/arc/relax-add04.d
@@ -0,0 +1,14 @@
+#as: -mrelax
+#objdump: -dr
+
+.*: +file format .*arc.*
+
+
+Disassembly of section .text:
+
+00000000 <.text>:
+ 0: 78e0 nop_s
+ 2: 2740 7281 add r1,pcl,0xa
+ 6: 264a 7000\s+.*
+ a: 78e0 nop_s
+ c: 2000 0000 add r0,r0,r0
diff --git a/gas/testsuite/gas/arc/relax-add04.s b/gas/testsuite/gas/arc/relax-add04.s
new file mode 100644
index 0000000..3af1f08
--- /dev/null
+++ b/gas/testsuite/gas/arc/relax-add04.s
@@ -0,0 +1,8 @@
+;;; Check relaxation from add rA,rB,limm (PCL) -> add rA,rB, uimm6@pcl
+ .cpu EM
+ nop_s
+ add r1,pcl,@.L1 - .
+ nop
+ .align 4
+.L1:
+ add r0,r0,r0
diff --git a/gas/testsuite/gas/arc/relax-ld01.d b/gas/testsuite/gas/arc/relax-ld01.d
new file mode 100644
index 0000000..ce58995
--- /dev/null
+++ b/gas/testsuite/gas/arc/relax-ld01.d
@@ -0,0 +1,15 @@
+#as: -mrelax
+#objdump: -dr
+
+.*: +file format .*arc.*
+
+
+Disassembly of section .text:
+
+00000000 <.text>:
+ 0: 78e0 nop_s
+ 2: 1710 7001 ld r1,\[pcl,16\]
+ 6: 264a 7000\s+.*
+ a: 264a 7000\s+.*
+ e: 78e0 nop_s
+ 10: 2000 0000 add r0,r0,r0
diff --git a/gas/testsuite/gas/arc/relax-ld01.s b/gas/testsuite/gas/arc/relax-ld01.s
new file mode 100644
index 0000000..199536c
--- /dev/null
+++ b/gas/testsuite/gas/arc/relax-ld01.s
@@ -0,0 +1,9 @@
+;;; Check relaxation from ld rA,[rB,limm@pcl] -> ld rA,[rB, imm9@pcl]
+ .cpu EM
+ nop_s
+ ld r1,[pcl,@.L1@pcl]
+ nop
+ nop
+ .align 4
+.L1:
+ add r0,r0,r0
diff --git a/gas/testsuite/gas/arc/relax-ld02.d b/gas/testsuite/gas/arc/relax-ld02.d
new file mode 100644
index 0000000..48e71b1
--- /dev/null
+++ b/gas/testsuite/gas/arc/relax-ld02.d
@@ -0,0 +1,14 @@
+#as: -mrelax
+#objdump: -dr
+
+.*: +file format .*arc.*
+
+
+Disassembly of section .text:
+
+00000000 <.text>:
+ 0: 78e0 nop_s
+ 2: 8223 ld_s r1,\[r2,0xc\]
+ 4: 264a 7000\s+.*
+ 8: 264a 7000\s+.*
+ c: 2000 0000 add r0,r0,r0
diff --git a/gas/testsuite/gas/arc/relax-ld02.s b/gas/testsuite/gas/arc/relax-ld02.s
new file mode 100644
index 0000000..37ec66c
--- /dev/null
+++ b/gas/testsuite/gas/arc/relax-ld02.s
@@ -0,0 +1,9 @@
+;;; Check relaxation from ld rA,[rB,limm@pcl] -> ld_s rC,[rB, imm9@pcl]
+ .cpu EM
+ nop_s
+ ld r1,[r2,@.L1@pcl]
+ nop
+ nop
+ .align 4
+.L1:
+ add r0,r0,r0
diff --git a/gas/testsuite/gas/arc/relax-mov01.d b/gas/testsuite/gas/arc/relax-mov01.d
new file mode 100644
index 0000000..373814e
--- /dev/null
+++ b/gas/testsuite/gas/arc/relax-mov01.d
@@ -0,0 +1,14 @@
+#as: -mrelax
+#objdump: -dr
+
+.*: +file format .*arc.*
+
+
+Disassembly of section .text:
+
+00000000 <.text>:
+ 0: 78e0 nop_s
+ 2: 258a 0300 mov r5,12
+ 6: 264a 7000\s+.*
+ a: 264a 7000\s+.*
+ e: 2000 0000 add r0,r0,r0
diff --git a/gas/testsuite/gas/arc/relax-mov01.s b/gas/testsuite/gas/arc/relax-mov01.s
new file mode 100644
index 0000000..4433356
--- /dev/null
+++ b/gas/testsuite/gas/arc/relax-mov01.s
@@ -0,0 +1,8 @@
+;;; Check relaxation from mov rA,limm -> mov rA, s12
+ .cpu EM
+ nop_s
+ mov r5, @.L1 - .
+ nop
+ nop
+.L1:
+ add r0,r0,r0
diff --git a/gas/testsuite/gas/arc/relax-mov02.d b/gas/testsuite/gas/arc/relax-mov02.d
new file mode 100644
index 0000000..b776595
--- /dev/null
+++ b/gas/testsuite/gas/arc/relax-mov02.d
@@ -0,0 +1,14 @@
+#as: -mrelax
+#objdump: -dr
+
+.*: +file format .*arc.*
+
+
+Disassembly of section .text:
+
+00000000 <.text>:
+ 0: 78e0 nop_s
+ 2: d90a mov_s r1,0xa
+ 4: 264a 7000\s+.*
+ 8: 264a 7000\s+.*
+ c: 2000 0000 add r0,r0,r0
diff --git a/gas/testsuite/gas/arc/relax-mov02.s b/gas/testsuite/gas/arc/relax-mov02.s
new file mode 100644
index 0000000..89ff619
--- /dev/null
+++ b/gas/testsuite/gas/arc/relax-mov02.s
@@ -0,0 +1,8 @@
+;;; Check relaxation from mov rA,limm -> mov_s rA, u8
+ .cpu EM
+ nop_s
+ mov r1, @.L1 - .
+ nop
+ nop
+.L1:
+ add r0,r0,r0
diff --git a/gas/testsuite/gas/arc/relax-mpy01.d b/gas/testsuite/gas/arc/relax-mpy01.d
new file mode 100644
index 0000000..40debac
--- /dev/null
+++ b/gas/testsuite/gas/arc/relax-mpy01.d
@@ -0,0 +1,14 @@
+#as: -mrelax
+#objdump: -dr
+
+.*: +file format .*arc.*
+
+
+Disassembly of section .text:
+
+00000000 <.text>:
+ 0: 255a 0401 mpy r1,r5,0x10
+ 4: 264a 7000\s+.*
+ 8: 264a 7000\s+.*
+ c: 264a 7000\s+.*
+ 10: 2000 0000 add r0,r0,r0
diff --git a/gas/testsuite/gas/arc/relax-mpy01.s b/gas/testsuite/gas/arc/relax-mpy01.s
new file mode 100644
index 0000000..fa64bd7
--- /dev/null
+++ b/gas/testsuite/gas/arc/relax-mpy01.s
@@ -0,0 +1,8 @@
+;;; Check relaxation from mpy rA,rB,limm -> mpy rA,rB, uimm6@pcl
+ .cpu EM
+ mpy r1,r5,@.L1 - .
+ nop
+ nop
+ nop
+.L1:
+ add r0,r0,r0
diff --git a/gas/testsuite/gas/arc/relax-sub01.d b/gas/testsuite/gas/arc/relax-sub01.d
new file mode 100644
index 0000000..604a993
--- /dev/null
+++ b/gas/testsuite/gas/arc/relax-sub01.d
@@ -0,0 +1,14 @@
+#as: -mrelax
+#objdump: -dr
+
+.*: +file format .*arc.*
+
+
+Disassembly of section .text:
+
+00000000 <.text>:
+ 0: 2742 7401 sub r1,pcl,0x10
+ 4: 264a 7000\s+.*
+ 8: 264a 7000\s+.*
+ c: 264a 7000\s+.*
+ 10: 2000 0000 add r0,r0,r0
diff --git a/gas/testsuite/gas/arc/relax-sub01.s b/gas/testsuite/gas/arc/relax-sub01.s
new file mode 100644
index 0000000..fde4a69
--- /dev/null
+++ b/gas/testsuite/gas/arc/relax-sub01.s
@@ -0,0 +1,9 @@
+;;; Check relaxation from sub rA,rB,limm@pcl -> sub rA,rB, uimm6@pcl
+ .cpu EM
+ sub r1,pcl,@.L1@pcl
+ nop
+ nop
+ nop
+ .align 4
+.L1:
+ add r0,r0,r0
diff --git a/gas/testsuite/gas/arc/relax-sub02.d b/gas/testsuite/gas/arc/relax-sub02.d
new file mode 100644
index 0000000..604a993
--- /dev/null
+++ b/gas/testsuite/gas/arc/relax-sub02.d
@@ -0,0 +1,14 @@
+#as: -mrelax
+#objdump: -dr
+
+.*: +file format .*arc.*
+
+
+Disassembly of section .text:
+
+00000000 <.text>:
+ 0: 2742 7401 sub r1,pcl,0x10
+ 4: 264a 7000\s+.*
+ 8: 264a 7000\s+.*
+ c: 264a 7000\s+.*
+ 10: 2000 0000 add r0,r0,r0
diff --git a/gas/testsuite/gas/arc/relax-sub02.s b/gas/testsuite/gas/arc/relax-sub02.s
new file mode 100644
index 0000000..d273e03
--- /dev/null
+++ b/gas/testsuite/gas/arc/relax-sub02.s
@@ -0,0 +1,9 @@
+;;; Check relaxation from sub rA,rB,limm (PCL) -> sub rA,rB, uimm6@pcl
+ .cpu EM
+ sub r1,pcl,@.L1 - .
+ nop
+ nop
+ nop
+ .align 4
+.L1:
+ add r0,r0,r0
diff --git a/gas/testsuite/gas/arc/relax-sub03.d b/gas/testsuite/gas/arc/relax-sub03.d
new file mode 100644
index 0000000..b41eda6
--- /dev/null
+++ b/gas/testsuite/gas/arc/relax-sub03.d
@@ -0,0 +1,13 @@
+#as: -mrelax
+#objdump: -dr
+
+.*: +file format .*arc.*
+
+
+Disassembly of section .text:
+
+00000000 <.text>:
+ 0: 264a 7000\s+.*
+ 4: 2242 0201 sub r1,r2,0x8
+ 8: 264a 7000\s+.*
+ c: 2000 0000 add r0,r0,r0
diff --git a/gas/testsuite/gas/arc/relax-sub03.s b/gas/testsuite/gas/arc/relax-sub03.s
new file mode 100644
index 0000000..4c5bd9d
--- /dev/null
+++ b/gas/testsuite/gas/arc/relax-sub03.s
@@ -0,0 +1,8 @@
+;;; Check relaxation from sub rA,rB,limm@pcl -> sub_s rC,rB, uimm3@pcl
+ .cpu EM
+ nop
+ sub r1,r2,@.L1@pcl
+ nop
+ .align 4
+.L1:
+ add r0,r0,r0
diff --git a/gas/testsuite/gas/arc/relax-sub04.d b/gas/testsuite/gas/arc/relax-sub04.d
new file mode 100644
index 0000000..07fd7fa
--- /dev/null
+++ b/gas/testsuite/gas/arc/relax-sub04.d
@@ -0,0 +1,14 @@
+#as: -mrelax
+#objdump: -dr
+
+.*: +file format .*arc.*
+
+
+Disassembly of section .text:
+
+00000000 <.text>:
+ 0: 78e0 nop_s
+ 2: 2742 7281 sub r1,pcl,0xa
+ 6: 264a 7000\s+.*
+ a: 78e0 nop_s
+ c: 2000 0000 add r0,r0,r0
diff --git a/gas/testsuite/gas/arc/relax-sub04.s b/gas/testsuite/gas/arc/relax-sub04.s
new file mode 100644
index 0000000..ecf10f1
--- /dev/null
+++ b/gas/testsuite/gas/arc/relax-sub04.s
@@ -0,0 +1,8 @@
+;;; Check relaxation from sub rA,rB,limm (PCL) -> sub rA,rB, uimm6@pcl
+ .cpu EM
+ nop_s
+ sub r1,pcl,@.L1 - .
+ nop
+ .align 4
+.L1:
+ add r0,r0,r0