This is the mail archive of the binutils@sourceware.org mailing list for the binutils project.


Index Nav: [Date Index] [Subject Index] [Author Index] [Thread Index]
Message Nav: [Date Prev] [Date Next] [Thread Prev] [Thread Next]
Other format: [Raw text]

V4 [PATCH 4/4] i386: Add tests for -malign-branch-boundary and -malign-branch


Add tests for -malign-branch-boundary, -malign-branch and
-mbranches-within-32B-boundaries.

gas/

	* testsuite/gas/i386/align-branch-1.s: New file.
	* testsuite/gas/i386/align-branch-1a.d: Likewise.
	* testsuite/gas/i386/align-branch-1b.d: Likewise.
	* testsuite/gas/i386/align-branch-1c.d: Likewise.
	* testsuite/gas/i386/align-branch-1d.d: Likewise.
	* testsuite/gas/i386/align-branch-1e.d: Likewise.
	* testsuite/gas/i386/align-branch-1f.d: Likewise.
	* testsuite/gas/i386/align-branch-1g.d: Likewise.
	* testsuite/gas/i386/align-branch-1h.d: Likewise.
	* testsuite/gas/i386/align-branch-2.s: Likewise.
	* testsuite/gas/i386/align-branch-2a.d: Likewise.
	* testsuite/gas/i386/align-branch-2b.d: Likewise.
	* testsuite/gas/i386/align-branch-2c.d: Likewise.
	* testsuite/gas/i386/align-branch-3.d: Likewise.
	* testsuite/gas/i386/align-branch-3.s: Likewise.
	* testsuite/gas/i386/align-branch-4.s: Likewise.
	* testsuite/gas/i386/align-branch-4a.d: Likewise.
	* testsuite/gas/i386/align-branch-4b.d: Likewise.
	* testsuite/gas/i386/align-branch-5.d: Likewise.
	* testsuite/gas/i386/align-branch-5.s: Likewise.
	* testsuite/gas/i386/align-branch-6.d: Likewise.
	* testsuite/gas/i386/align-branch-6.s: Likewise.
	* testsuite/gas/i386/align-branch-7.d: Likewise.
	* testsuite/gas/i386/align-branch-7.s: Likewise.
	* testsuite/gas/i386/align-branch-8.d: Likewise.
	* testsuite/gas/i386/align-branch-8.s: Likewise.
	* testsuite/gas/i386/x86-64-align-branch-1.s: Likewise.
	* testsuite/gas/i386/x86-64-align-branch-1a.d: Likewise.
	* testsuite/gas/i386/x86-64-align-branch-1b.d: Likewise.
	* testsuite/gas/i386/x86-64-align-branch-1c.d: Likewise.
	* testsuite/gas/i386/x86-64-align-branch-1d.d: Likewise.
	* testsuite/gas/i386/x86-64-align-branch-1e.d: Likewise.
	* testsuite/gas/i386/x86-64-align-branch-1f.d: Likewise.
	* testsuite/gas/i386/x86-64-align-branch-1g.d: Likewise.
	* testsuite/gas/i386/x86-64-align-branch-1h.d: Likewise.
	* testsuite/gas/i386/x86-64-align-branch-2.s: Likewise.
	* testsuite/gas/i386/x86-64-align-branch-2a.d: Likewise.
	* testsuite/gas/i386/x86-64-align-branch-2b.d: Likewise.
	* testsuite/gas/i386/x86-64-align-branch-2c.d: Likewise.
	* testsuite/gas/i386/x86-64-align-branch-3.d: Likewise.
	* testsuite/gas/i386/x86-64-align-branch-3.s: Likewise.
	* testsuite/gas/i386/x86-64-align-branch-4.s: Likewise.
	* testsuite/gas/i386/x86-64-align-branch-4a.d: Likewise.
	* testsuite/gas/i386/x86-64-align-branch-4b.d: Likewise.
	* testsuite/gas/i386/x86-64-align-branch-5.d: Likewise.
	* testsuite/gas/i386/x86-64-align-branch-6.d: Likewise.
	* testsuite/gas/i386/x86-64-align-branch-7.d: Likewise.
	* testsuite/gas/i386/x86-64-align-branch-7.s: Likewise.
	* testsuite/gas/i386/x86-64-align-branch-8.d: Likewise.
	* testsuite/gas/i386/x86-64-align-branch-8.s: Likewise.
	* testsuite/gas/i386/i386.exp: Run new tests.

ld/

	* testsuite/ld-i386/align-branch-1.d: New file.
	* testsuite/ld-i386/align-branch-1.s: Likewise.
	* testsuite/ld-x86-64/align-branch-1.d: Likewise.
	* testsuite/ld-x86-64/align-branch-1.3: Likewise.
	* testsuite/ld-i386/i386.exp: Run the new test.
	* testsuite/ld-x86-64/x86-64.exp: Likewise.
---
 gas/testsuite/gas/i386/align-branch-1.s       | 72 +++++++++++++++++
 gas/testsuite/gas/i386/align-branch-1a.d      | 77 ++++++++++++++++++
 gas/testsuite/gas/i386/align-branch-1b.d      | 77 ++++++++++++++++++
 gas/testsuite/gas/i386/align-branch-1c.d      | 77 ++++++++++++++++++
 gas/testsuite/gas/i386/align-branch-1d.d      | 76 ++++++++++++++++++
 gas/testsuite/gas/i386/align-branch-1e.d      | 77 ++++++++++++++++++
 gas/testsuite/gas/i386/align-branch-1f.d      | 77 ++++++++++++++++++
 gas/testsuite/gas/i386/align-branch-1g.d      | 77 ++++++++++++++++++
 gas/testsuite/gas/i386/align-branch-1h.d      | 76 ++++++++++++++++++
 gas/testsuite/gas/i386/align-branch-1i.d      | 80 +++++++++++++++++++
 gas/testsuite/gas/i386/align-branch-2.s       | 49 ++++++++++++
 gas/testsuite/gas/i386/align-branch-2a.d      | 55 +++++++++++++
 gas/testsuite/gas/i386/align-branch-2b.d      | 55 +++++++++++++
 gas/testsuite/gas/i386/align-branch-2c.d      | 55 +++++++++++++
 gas/testsuite/gas/i386/align-branch-3.d       | 33 ++++++++
 gas/testsuite/gas/i386/align-branch-3.s       | 28 +++++++
 gas/testsuite/gas/i386/align-branch-4.s       | 30 +++++++
 gas/testsuite/gas/i386/align-branch-4a.d      | 36 +++++++++
 gas/testsuite/gas/i386/align-branch-4b.d      | 36 +++++++++
 gas/testsuite/gas/i386/align-branch-5.d       | 36 +++++++++
 gas/testsuite/gas/i386/align-branch-5.s       | 32 ++++++++
 gas/testsuite/gas/i386/align-branch-6.d       | 22 +++++
 gas/testsuite/gas/i386/align-branch-6.e       |  2 +
 gas/testsuite/gas/i386/align-branch-6.s       |  7 ++
 gas/testsuite/gas/i386/align-branch-7.d       | 18 +++++
 gas/testsuite/gas/i386/align-branch-7.s       | 14 ++++
 gas/testsuite/gas/i386/align-branch-8.d       | 18 +++++
 gas/testsuite/gas/i386/align-branch-8.s       | 14 ++++
 gas/testsuite/gas/i386/i386.exp               | 45 +++++++++++
 .../gas/i386/x86-64-align-branch-1.s          | 70 ++++++++++++++++
 .../gas/i386/x86-64-align-branch-1a.d         | 75 +++++++++++++++++
 .../gas/i386/x86-64-align-branch-1b.d         | 75 +++++++++++++++++
 .../gas/i386/x86-64-align-branch-1c.d         | 75 +++++++++++++++++
 .../gas/i386/x86-64-align-branch-1d.d         | 74 +++++++++++++++++
 .../gas/i386/x86-64-align-branch-1e.d         | 74 +++++++++++++++++
 .../gas/i386/x86-64-align-branch-1f.d         | 75 +++++++++++++++++
 .../gas/i386/x86-64-align-branch-1g.d         | 75 +++++++++++++++++
 .../gas/i386/x86-64-align-branch-1h.d         | 74 +++++++++++++++++
 .../gas/i386/x86-64-align-branch-1i.d         | 78 ++++++++++++++++++
 .../gas/i386/x86-64-align-branch-2.s          | 44 ++++++++++
 .../gas/i386/x86-64-align-branch-2a.d         | 50 ++++++++++++
 .../gas/i386/x86-64-align-branch-2b.d         | 50 ++++++++++++
 .../gas/i386/x86-64-align-branch-2c.d         | 50 ++++++++++++
 .../gas/i386/x86-64-align-branch-3.d          | 32 ++++++++
 .../gas/i386/x86-64-align-branch-3.s          | 27 +++++++
 .../gas/i386/x86-64-align-branch-4.s          | 27 +++++++
 .../gas/i386/x86-64-align-branch-4a.d         | 33 ++++++++
 .../gas/i386/x86-64-align-branch-4b.d         | 33 ++++++++
 .../gas/i386/x86-64-align-branch-5.d          | 37 +++++++++
 .../gas/i386/x86-64-align-branch-6.d          | 19 +++++
 .../gas/i386/x86-64-align-branch-7.d          | 18 +++++
 .../gas/i386/x86-64-align-branch-7.s          | 14 ++++
 .../gas/i386/x86-64-align-branch-8.d          | 18 +++++
 .../gas/i386/x86-64-align-branch-8.s          | 14 ++++
 ld/testsuite/ld-i386/align-branch-1.d         | 25 ++++++
 ld/testsuite/ld-i386/align-branch-1.s         | 19 +++++
 ld/testsuite/ld-i386/i386.exp                 |  1 +
 ld/testsuite/ld-x86-64/align-branch-1.d       | 21 +++++
 ld/testsuite/ld-x86-64/align-branch-1.s       | 17 ++++
 ld/testsuite/ld-x86-64/x86-64.exp             |  1 +
 60 files changed, 2646 insertions(+)
 create mode 100644 gas/testsuite/gas/i386/align-branch-1.s
 create mode 100644 gas/testsuite/gas/i386/align-branch-1a.d
 create mode 100644 gas/testsuite/gas/i386/align-branch-1b.d
 create mode 100644 gas/testsuite/gas/i386/align-branch-1c.d
 create mode 100644 gas/testsuite/gas/i386/align-branch-1d.d
 create mode 100644 gas/testsuite/gas/i386/align-branch-1e.d
 create mode 100644 gas/testsuite/gas/i386/align-branch-1f.d
 create mode 100644 gas/testsuite/gas/i386/align-branch-1g.d
 create mode 100644 gas/testsuite/gas/i386/align-branch-1h.d
 create mode 100644 gas/testsuite/gas/i386/align-branch-1i.d
 create mode 100644 gas/testsuite/gas/i386/align-branch-2.s
 create mode 100644 gas/testsuite/gas/i386/align-branch-2a.d
 create mode 100644 gas/testsuite/gas/i386/align-branch-2b.d
 create mode 100644 gas/testsuite/gas/i386/align-branch-2c.d
 create mode 100644 gas/testsuite/gas/i386/align-branch-3.d
 create mode 100644 gas/testsuite/gas/i386/align-branch-3.s
 create mode 100644 gas/testsuite/gas/i386/align-branch-4.s
 create mode 100644 gas/testsuite/gas/i386/align-branch-4a.d
 create mode 100644 gas/testsuite/gas/i386/align-branch-4b.d
 create mode 100644 gas/testsuite/gas/i386/align-branch-5.d
 create mode 100644 gas/testsuite/gas/i386/align-branch-5.s
 create mode 100644 gas/testsuite/gas/i386/align-branch-6.d
 create mode 100644 gas/testsuite/gas/i386/align-branch-6.e
 create mode 100644 gas/testsuite/gas/i386/align-branch-6.s
 create mode 100644 gas/testsuite/gas/i386/align-branch-7.d
 create mode 100644 gas/testsuite/gas/i386/align-branch-7.s
 create mode 100644 gas/testsuite/gas/i386/align-branch-8.d
 create mode 100644 gas/testsuite/gas/i386/align-branch-8.s
 create mode 100644 gas/testsuite/gas/i386/x86-64-align-branch-1.s
 create mode 100644 gas/testsuite/gas/i386/x86-64-align-branch-1a.d
 create mode 100644 gas/testsuite/gas/i386/x86-64-align-branch-1b.d
 create mode 100644 gas/testsuite/gas/i386/x86-64-align-branch-1c.d
 create mode 100644 gas/testsuite/gas/i386/x86-64-align-branch-1d.d
 create mode 100644 gas/testsuite/gas/i386/x86-64-align-branch-1e.d
 create mode 100644 gas/testsuite/gas/i386/x86-64-align-branch-1f.d
 create mode 100644 gas/testsuite/gas/i386/x86-64-align-branch-1g.d
 create mode 100644 gas/testsuite/gas/i386/x86-64-align-branch-1h.d
 create mode 100644 gas/testsuite/gas/i386/x86-64-align-branch-1i.d
 create mode 100644 gas/testsuite/gas/i386/x86-64-align-branch-2.s
 create mode 100644 gas/testsuite/gas/i386/x86-64-align-branch-2a.d
 create mode 100644 gas/testsuite/gas/i386/x86-64-align-branch-2b.d
 create mode 100644 gas/testsuite/gas/i386/x86-64-align-branch-2c.d
 create mode 100644 gas/testsuite/gas/i386/x86-64-align-branch-3.d
 create mode 100644 gas/testsuite/gas/i386/x86-64-align-branch-3.s
 create mode 100644 gas/testsuite/gas/i386/x86-64-align-branch-4.s
 create mode 100644 gas/testsuite/gas/i386/x86-64-align-branch-4a.d
 create mode 100644 gas/testsuite/gas/i386/x86-64-align-branch-4b.d
 create mode 100644 gas/testsuite/gas/i386/x86-64-align-branch-5.d
 create mode 100644 gas/testsuite/gas/i386/x86-64-align-branch-6.d
 create mode 100644 gas/testsuite/gas/i386/x86-64-align-branch-7.d
 create mode 100644 gas/testsuite/gas/i386/x86-64-align-branch-7.s
 create mode 100644 gas/testsuite/gas/i386/x86-64-align-branch-8.d
 create mode 100644 gas/testsuite/gas/i386/x86-64-align-branch-8.s
 create mode 100644 ld/testsuite/ld-i386/align-branch-1.d
 create mode 100644 ld/testsuite/ld-i386/align-branch-1.s
 create mode 100644 ld/testsuite/ld-x86-64/align-branch-1.d
 create mode 100644 ld/testsuite/ld-x86-64/align-branch-1.s

diff --git a/gas/testsuite/gas/i386/align-branch-1.s b/gas/testsuite/gas/i386/align-branch-1.s
new file mode 100644
index 0000000000..06bf98a98d
--- /dev/null
+++ b/gas/testsuite/gas/i386/align-branch-1.s
@@ -0,0 +1,72 @@
+  .text
+  .globl  foo
+  .p2align  4
+foo:
+  movl	%eax, %gs:0x1
+  pushl  %ebp
+  pushl  %ebp
+  pushl  %ebp
+  pushl  %ebp
+  movl  %esp, %ebp
+  movl  %edi, -8(%ebp)
+  movl  %esi, -12(%ebp)
+  movl  %esi, -12(%ebp)
+  movl  %esi, -12(%ebp)
+  movl  %esi, -12(%ebp)
+  movl  %esi, -12(%ebp)
+  cmp  %eax, %ebp
+  je  .L_2
+  movl  %esi, -12(%ebx)
+  movl  %esi, -12(%ebp)
+  movl  %edi, -8(%ebp)
+  movl  %esi, -12(%ebp)
+  movl  %esi, -12(%ebp)
+  movl  %esi, -12(%ebp)
+  movl  %esi, -12(%ebp)
+  movl  %esi, -12(%ebp)
+  popl  %ebp
+  popl  %ebp
+  popl  %ebp
+  je  .L_2
+  popl  %ebp
+  je  .L_2
+  movl  %eax, -4(%esp)
+  movl  %esi, -12(%ebp)
+  movl  %edi, -8(%ebp)
+  movl  %esi, -12(%ebp)
+  movl  %esi, -12(%ebp)
+  movl  %esi, -12(%ebp)
+  movl  %esi, -12(%ebp)
+  movl  %esi, -12(%ebp)
+  popl  %ebp
+  jmp  .L_3
+  jmp  .L_3
+  jmp  .L_3
+  movl  %eax, -4(%ebp)
+  movl  %esi, -12(%ebp)
+  movl  %edi, -8(%ebp)
+  movl  %esi, -12(%ebp)
+  movl  %esi, -12(%ebp)
+  movl  %esi, -12(%ebp)
+  popl  %ebp
+  popl  %ebp
+  cmp  %eax, %ebp
+  je  .L_2
+  jmp  .L_3
+.L_2:
+  movl  -12(%ebp), %eax
+  movl  %eax, -4(%ebp)
+.L_3:
+  movl  %esi, -1200(%ebp)
+  movl  %esi, -1200(%ebp)
+  movl  %esi, -1200(%ebp)
+  movl  %esi, -1200(%ebp)
+  movl  %esi, 12(%ebp)
+  jmp  bar
+  movl  %esi, -1200(%ebp)
+  movl  %esi, -1200(%ebp)
+  movl  %esi, -1200(%ebp)
+  movl  %esi, -1200(%ebp)
+  movl  %esi, (%ebp)
+  je .L_3
+  je .L_3
diff --git a/gas/testsuite/gas/i386/align-branch-1a.d b/gas/testsuite/gas/i386/align-branch-1a.d
new file mode 100644
index 0000000000..46b79216ec
--- /dev/null
+++ b/gas/testsuite/gas/i386/align-branch-1a.d
@@ -0,0 +1,77 @@
+#source: align-branch-1.s
+#as: -malign-branch-boundary=32
+#objdump: -dw
+
+.*: +file format .*
+
+Disassembly of section .text:
+
+0+ <foo>:
+   0:	65 65 65 a3 01 00 00 00 	gs gs mov %eax,%gs:0x1
+   8:	55                   	push   %ebp
+   9:	55                   	push   %ebp
+   a:	55                   	push   %ebp
+   b:	55                   	push   %ebp
+   c:	89 e5                	mov    %esp,%ebp
+   e:	89 7d f8             	mov    %edi,-0x8\(%ebp\)
+  11:	89 75 f4             	mov    %esi,-0xc\(%ebp\)
+  14:	89 75 f4             	mov    %esi,-0xc\(%ebp\)
+  17:	89 75 f4             	mov    %esi,-0xc\(%ebp\)
+  1a:	89 75 f4             	mov    %esi,-0xc\(%ebp\)
+  1d:	89 75 f4             	mov    %esi,-0xc\(%ebp\)
+  20:	39 c5                	cmp    %eax,%ebp
+  22:	74 5e                	je     82 <foo\+0x82>
+  24:	3e 89 73 f4          	mov    %esi,%ds:-0xc\(%ebx\)
+  28:	89 75 f4             	mov    %esi,-0xc\(%ebp\)
+  2b:	89 7d f8             	mov    %edi,-0x8\(%ebp\)
+  2e:	89 75 f4             	mov    %esi,-0xc\(%ebp\)
+  31:	89 75 f4             	mov    %esi,-0xc\(%ebp\)
+  34:	89 75 f4             	mov    %esi,-0xc\(%ebp\)
+  37:	89 75 f4             	mov    %esi,-0xc\(%ebp\)
+  3a:	89 75 f4             	mov    %esi,-0xc\(%ebp\)
+  3d:	5d                   	pop    %ebp
+  3e:	5d                   	pop    %ebp
+  3f:	5d                   	pop    %ebp
+  40:	74 40                	je     82 <foo\+0x82>
+  42:	5d                   	pop    %ebp
+  43:	74 3d                	je     82 <foo\+0x82>
+  45:	36 89 44 24 fc       	mov    %eax,%ss:-0x4\(%esp\)
+  4a:	89 75 f4             	mov    %esi,-0xc\(%ebp\)
+  4d:	89 7d f8             	mov    %edi,-0x8\(%ebp\)
+  50:	89 75 f4             	mov    %esi,-0xc\(%ebp\)
+  53:	89 75 f4             	mov    %esi,-0xc\(%ebp\)
+  56:	89 75 f4             	mov    %esi,-0xc\(%ebp\)
+  59:	89 75 f4             	mov    %esi,-0xc\(%ebp\)
+  5c:	89 75 f4             	mov    %esi,-0xc\(%ebp\)
+  5f:	5d                   	pop    %ebp
+  60:	eb 26                	jmp    88 <foo\+0x88>
+  62:	eb 24                	jmp    88 <foo\+0x88>
+  64:	eb 22                	jmp    88 <foo\+0x88>
+  66:	89 45 fc             	mov    %eax,-0x4\(%ebp\)
+  69:	89 75 f4             	mov    %esi,-0xc\(%ebp\)
+  6c:	89 7d f8             	mov    %edi,-0x8\(%ebp\)
+  6f:	89 75 f4             	mov    %esi,-0xc\(%ebp\)
+  72:	89 75 f4             	mov    %esi,-0xc\(%ebp\)
+  75:	89 75 f4             	mov    %esi,-0xc\(%ebp\)
+  78:	5d                   	pop    %ebp
+  79:	5d                   	pop    %ebp
+  7a:	39 c5                	cmp    %eax,%ebp
+  7c:	74 04                	je     82 <foo\+0x82>
+  7e:	66 90                	xchg   %ax,%ax
+  80:	eb 06                	jmp    88 <foo\+0x88>
+  82:	8b 45 f4             	mov    -0xc\(%ebp\),%eax
+  85:	89 45 fc             	mov    %eax,-0x4\(%ebp\)
+  88:	89 b5 50 fb ff ff    	mov    %esi,-0x4b0\(%ebp\)
+  8e:	89 b5 50 fb ff ff    	mov    %esi,-0x4b0\(%ebp\)
+  94:	89 b5 50 fb ff ff    	mov    %esi,-0x4b0\(%ebp\)
+  9a:	89 b5 50 fb ff ff    	mov    %esi,-0x4b0\(%ebp\)
+  a0:	89 75 0c             	mov    %esi,0xc\(%ebp\)
+  a3:	e9 [0-9a-f ]+       	jmp    .*
+  a8:	89 b5 50 fb ff ff    	mov    %esi,-0x4b0\(%ebp\)
+  ae:	89 b5 50 fb ff ff    	mov    %esi,-0x4b0\(%ebp\)
+  b4:	89 b5 50 fb ff ff    	mov    %esi,-0x4b0\(%ebp\)
+  ba:	89 b5 50 fb ff ff    	mov    %esi,-0x4b0\(%ebp\)
+  c0:	89 75 00             	mov    %esi,0x0\(%ebp\)
+  c3:	74 c3                	je     88 <foo\+0x88>
+  c5:	74 c1                	je     88 <foo\+0x88>
+#pass
diff --git a/gas/testsuite/gas/i386/align-branch-1b.d b/gas/testsuite/gas/i386/align-branch-1b.d
new file mode 100644
index 0000000000..b3f0e727bc
--- /dev/null
+++ b/gas/testsuite/gas/i386/align-branch-1b.d
@@ -0,0 +1,77 @@
+#source: align-branch-1.s
+#as: -malign-branch-boundary=32 -malign-branch=fused+jcc+jmp
+#objdump: -dw
+
+.*: +file format .*
+
+Disassembly of section .text:
+
+0+ <foo>:
+   0:	65 65 65 a3 01 00 00 00 	gs gs mov %eax,%gs:0x1
+   8:	55                   	push   %ebp
+   9:	55                   	push   %ebp
+   a:	55                   	push   %ebp
+   b:	55                   	push   %ebp
+   c:	89 e5                	mov    %esp,%ebp
+   e:	89 7d f8             	mov    %edi,-0x8\(%ebp\)
+  11:	89 75 f4             	mov    %esi,-0xc\(%ebp\)
+  14:	89 75 f4             	mov    %esi,-0xc\(%ebp\)
+  17:	89 75 f4             	mov    %esi,-0xc\(%ebp\)
+  1a:	89 75 f4             	mov    %esi,-0xc\(%ebp\)
+  1d:	89 75 f4             	mov    %esi,-0xc\(%ebp\)
+  20:	39 c5                	cmp    %eax,%ebp
+  22:	74 5e                	je     82 <foo\+0x82>
+  24:	3e 89 73 f4          	mov    %esi,%ds:-0xc\(%ebx\)
+  28:	89 75 f4             	mov    %esi,-0xc\(%ebp\)
+  2b:	89 7d f8             	mov    %edi,-0x8\(%ebp\)
+  2e:	89 75 f4             	mov    %esi,-0xc\(%ebp\)
+  31:	89 75 f4             	mov    %esi,-0xc\(%ebp\)
+  34:	89 75 f4             	mov    %esi,-0xc\(%ebp\)
+  37:	89 75 f4             	mov    %esi,-0xc\(%ebp\)
+  3a:	89 75 f4             	mov    %esi,-0xc\(%ebp\)
+  3d:	5d                   	pop    %ebp
+  3e:	5d                   	pop    %ebp
+  3f:	5d                   	pop    %ebp
+  40:	74 40                	je     82 <foo\+0x82>
+  42:	5d                   	pop    %ebp
+  43:	74 3d                	je     82 <foo\+0x82>
+  45:	36 89 44 24 fc       	mov    %eax,%ss:-0x4\(%esp\)
+  4a:	89 75 f4             	mov    %esi,-0xc\(%ebp\)
+  4d:	89 7d f8             	mov    %edi,-0x8\(%ebp\)
+  50:	89 75 f4             	mov    %esi,-0xc\(%ebp\)
+  53:	89 75 f4             	mov    %esi,-0xc\(%ebp\)
+  56:	89 75 f4             	mov    %esi,-0xc\(%ebp\)
+  59:	89 75 f4             	mov    %esi,-0xc\(%ebp\)
+  5c:	89 75 f4             	mov    %esi,-0xc\(%ebp\)
+  5f:	5d                   	pop    %ebp
+  60:	eb 26                	jmp    88 <foo\+0x88>
+  62:	eb 24                	jmp    88 <foo\+0x88>
+  64:	eb 22                	jmp    88 <foo\+0x88>
+  66:	89 45 fc             	mov    %eax,-0x4\(%ebp\)
+  69:	89 75 f4             	mov    %esi,-0xc\(%ebp\)
+  6c:	89 7d f8             	mov    %edi,-0x8\(%ebp\)
+  6f:	89 75 f4             	mov    %esi,-0xc\(%ebp\)
+  72:	89 75 f4             	mov    %esi,-0xc\(%ebp\)
+  75:	89 75 f4             	mov    %esi,-0xc\(%ebp\)
+  78:	5d                   	pop    %ebp
+  79:	5d                   	pop    %ebp
+  7a:	39 c5                	cmp    %eax,%ebp
+  7c:	74 04                	je     82 <foo\+0x82>
+  7e:	66 90                	xchg   %ax,%ax
+  80:	eb 06                	jmp    88 <foo\+0x88>
+  82:	8b 45 f4             	mov    -0xc\(%ebp\),%eax
+  85:	89 45 fc             	mov    %eax,-0x4\(%ebp\)
+  88:	89 b5 50 fb ff ff    	mov    %esi,-0x4b0\(%ebp\)
+  8e:	89 b5 50 fb ff ff    	mov    %esi,-0x4b0\(%ebp\)
+  94:	89 b5 50 fb ff ff    	mov    %esi,-0x4b0\(%ebp\)
+  9a:	89 b5 50 fb ff ff    	mov    %esi,-0x4b0\(%ebp\)
+  a0:	89 75 0c             	mov    %esi,0xc\(%ebp\)
+  a3:	e9 [0-9a-f ]+       	jmp    .*
+  a8:	89 b5 50 fb ff ff    	mov    %esi,-0x4b0\(%ebp\)
+  ae:	89 b5 50 fb ff ff    	mov    %esi,-0x4b0\(%ebp\)
+  b4:	89 b5 50 fb ff ff    	mov    %esi,-0x4b0\(%ebp\)
+  ba:	89 b5 50 fb ff ff    	mov    %esi,-0x4b0\(%ebp\)
+  c0:	89 75 00             	mov    %esi,0x0\(%ebp\)
+  c3:	74 c3                	je     88 <foo\+0x88>
+  c5:	74 c1                	je     88 <foo\+0x88>
+#pass
diff --git a/gas/testsuite/gas/i386/align-branch-1c.d b/gas/testsuite/gas/i386/align-branch-1c.d
new file mode 100644
index 0000000000..947dcc8785
--- /dev/null
+++ b/gas/testsuite/gas/i386/align-branch-1c.d
@@ -0,0 +1,77 @@
+#source: align-branch-1.s
+#as: -malign-branch-boundary=32 -malign-branch-prefix-size=1
+#objdump: -dw
+
+.*: +file format .*
+
+Disassembly of section .text:
+
+0+ <foo>:
+   0:	65 a3 01 00 00 00    	mov    %eax,%gs:0x1
+   6:	3e 55                	ds push %ebp
+   8:	3e 55                	ds push %ebp
+   a:	55                   	push   %ebp
+   b:	55                   	push   %ebp
+   c:	89 e5                	mov    %esp,%ebp
+   e:	89 7d f8             	mov    %edi,-0x8\(%ebp\)
+  11:	89 75 f4             	mov    %esi,-0xc\(%ebp\)
+  14:	89 75 f4             	mov    %esi,-0xc\(%ebp\)
+  17:	89 75 f4             	mov    %esi,-0xc\(%ebp\)
+  1a:	89 75 f4             	mov    %esi,-0xc\(%ebp\)
+  1d:	89 75 f4             	mov    %esi,-0xc\(%ebp\)
+  20:	39 c5                	cmp    %eax,%ebp
+  22:	74 5e                	je     82 <foo\+0x82>
+  24:	3e 89 73 f4          	mov    %esi,%ds:-0xc\(%ebx\)
+  28:	89 75 f4             	mov    %esi,-0xc\(%ebp\)
+  2b:	89 7d f8             	mov    %edi,-0x8\(%ebp\)
+  2e:	89 75 f4             	mov    %esi,-0xc\(%ebp\)
+  31:	89 75 f4             	mov    %esi,-0xc\(%ebp\)
+  34:	89 75 f4             	mov    %esi,-0xc\(%ebp\)
+  37:	89 75 f4             	mov    %esi,-0xc\(%ebp\)
+  3a:	89 75 f4             	mov    %esi,-0xc\(%ebp\)
+  3d:	5d                   	pop    %ebp
+  3e:	5d                   	pop    %ebp
+  3f:	5d                   	pop    %ebp
+  40:	74 40                	je     82 <foo\+0x82>
+  42:	5d                   	pop    %ebp
+  43:	74 3d                	je     82 <foo\+0x82>
+  45:	36 89 44 24 fc       	mov    %eax,%ss:-0x4\(%esp\)
+  4a:	89 75 f4             	mov    %esi,-0xc\(%ebp\)
+  4d:	89 7d f8             	mov    %edi,-0x8\(%ebp\)
+  50:	89 75 f4             	mov    %esi,-0xc\(%ebp\)
+  53:	89 75 f4             	mov    %esi,-0xc\(%ebp\)
+  56:	89 75 f4             	mov    %esi,-0xc\(%ebp\)
+  59:	89 75 f4             	mov    %esi,-0xc\(%ebp\)
+  5c:	89 75 f4             	mov    %esi,-0xc\(%ebp\)
+  5f:	5d                   	pop    %ebp
+  60:	eb 26                	jmp    88 <foo\+0x88>
+  62:	eb 24                	jmp    88 <foo\+0x88>
+  64:	eb 22                	jmp    88 <foo\+0x88>
+  66:	89 45 fc             	mov    %eax,-0x4\(%ebp\)
+  69:	89 75 f4             	mov    %esi,-0xc\(%ebp\)
+  6c:	89 7d f8             	mov    %edi,-0x8\(%ebp\)
+  6f:	89 75 f4             	mov    %esi,-0xc\(%ebp\)
+  72:	89 75 f4             	mov    %esi,-0xc\(%ebp\)
+  75:	89 75 f4             	mov    %esi,-0xc\(%ebp\)
+  78:	5d                   	pop    %ebp
+  79:	5d                   	pop    %ebp
+  7a:	39 c5                	cmp    %eax,%ebp
+  7c:	74 04                	je     82 <foo\+0x82>
+  7e:	66 90                	xchg   %ax,%ax
+  80:	eb 06                	jmp    88 <foo\+0x88>
+  82:	8b 45 f4             	mov    -0xc\(%ebp\),%eax
+  85:	89 45 fc             	mov    %eax,-0x4\(%ebp\)
+  88:	89 b5 50 fb ff ff    	mov    %esi,-0x4b0\(%ebp\)
+  8e:	89 b5 50 fb ff ff    	mov    %esi,-0x4b0\(%ebp\)
+  94:	89 b5 50 fb ff ff    	mov    %esi,-0x4b0\(%ebp\)
+  9a:	89 b5 50 fb ff ff    	mov    %esi,-0x4b0\(%ebp\)
+  a0:	89 75 0c             	mov    %esi,0xc\(%ebp\)
+  a3:	e9 [0-9a-f ]+       	jmp    .*
+  a8:	89 b5 50 fb ff ff    	mov    %esi,-0x4b0\(%ebp\)
+  ae:	89 b5 50 fb ff ff    	mov    %esi,-0x4b0\(%ebp\)
+  b4:	89 b5 50 fb ff ff    	mov    %esi,-0x4b0\(%ebp\)
+  ba:	89 b5 50 fb ff ff    	mov    %esi,-0x4b0\(%ebp\)
+  c0:	89 75 00             	mov    %esi,0x0\(%ebp\)
+  c3:	74 c3                	je     88 <foo\+0x88>
+  c5:	74 c1                	je     88 <foo\+0x88>
+#pass
diff --git a/gas/testsuite/gas/i386/align-branch-1d.d b/gas/testsuite/gas/i386/align-branch-1d.d
new file mode 100644
index 0000000000..db62f0819d
--- /dev/null
+++ b/gas/testsuite/gas/i386/align-branch-1d.d
@@ -0,0 +1,76 @@
+#source: align-branch-1.s
+#as: -malign-branch-boundary=32 -malign-branch=fused+jcc
+#objdump: -dw
+
+.*: +file format .*
+
+Disassembly of section .text:
+
+0+ <foo>:
+   0:	65 65 65 a3 01 00 00 00 	gs gs mov %eax,%gs:0x1
+   8:	55                   	push   %ebp
+   9:	55                   	push   %ebp
+   a:	55                   	push   %ebp
+   b:	55                   	push   %ebp
+   c:	89 e5                	mov    %esp,%ebp
+   e:	89 7d f8             	mov    %edi,-0x8\(%ebp\)
+  11:	89 75 f4             	mov    %esi,-0xc\(%ebp\)
+  14:	89 75 f4             	mov    %esi,-0xc\(%ebp\)
+  17:	89 75 f4             	mov    %esi,-0xc\(%ebp\)
+  1a:	89 75 f4             	mov    %esi,-0xc\(%ebp\)
+  1d:	89 75 f4             	mov    %esi,-0xc\(%ebp\)
+  20:	39 c5                	cmp    %eax,%ebp
+  22:	74 5b                	je     7f <foo\+0x7f>
+  24:	3e 89 73 f4          	mov    %esi,%ds:-0xc\(%ebx\)
+  28:	89 75 f4             	mov    %esi,-0xc\(%ebp\)
+  2b:	89 7d f8             	mov    %edi,-0x8\(%ebp\)
+  2e:	89 75 f4             	mov    %esi,-0xc\(%ebp\)
+  31:	89 75 f4             	mov    %esi,-0xc\(%ebp\)
+  34:	89 75 f4             	mov    %esi,-0xc\(%ebp\)
+  37:	89 75 f4             	mov    %esi,-0xc\(%ebp\)
+  3a:	89 75 f4             	mov    %esi,-0xc\(%ebp\)
+  3d:	5d                   	pop    %ebp
+  3e:	5d                   	pop    %ebp
+  3f:	5d                   	pop    %ebp
+  40:	74 3d                	je     7f <foo\+0x7f>
+  42:	5d                   	pop    %ebp
+  43:	74 3a                	je     7f <foo\+0x7f>
+  45:	89 44 24 fc          	mov    %eax,-0x4\(%esp\)
+  49:	89 75 f4             	mov    %esi,-0xc\(%ebp\)
+  4c:	89 7d f8             	mov    %edi,-0x8\(%ebp\)
+  4f:	89 75 f4             	mov    %esi,-0xc\(%ebp\)
+  52:	89 75 f4             	mov    %esi,-0xc\(%ebp\)
+  55:	89 75 f4             	mov    %esi,-0xc\(%ebp\)
+  58:	89 75 f4             	mov    %esi,-0xc\(%ebp\)
+  5b:	89 75 f4             	mov    %esi,-0xc\(%ebp\)
+  5e:	5d                   	pop    %ebp
+  5f:	eb 24                	jmp    85 <foo\+0x85>
+  61:	eb 22                	jmp    85 <foo\+0x85>
+  63:	eb 20                	jmp    85 <foo\+0x85>
+  65:	89 45 fc             	mov    %eax,-0x4\(%ebp\)
+  68:	89 75 f4             	mov    %esi,-0xc\(%ebp\)
+  6b:	89 7d f8             	mov    %edi,-0x8\(%ebp\)
+  6e:	89 75 f4             	mov    %esi,-0xc\(%ebp\)
+  71:	89 75 f4             	mov    %esi,-0xc\(%ebp\)
+  74:	89 75 f4             	mov    %esi,-0xc\(%ebp\)
+  77:	5d                   	pop    %ebp
+  78:	5d                   	pop    %ebp
+  79:	39 c5                	cmp    %eax,%ebp
+  7b:	74 02                	je     7f <foo\+0x7f>
+  7d:	eb 06                	jmp    85 <foo\+0x85>
+  7f:	8b 45 f4             	mov    -0xc\(%ebp\),%eax
+  82:	89 45 fc             	mov    %eax,-0x4\(%ebp\)
+  85:	89 b5 50 fb ff ff    	mov    %esi,-0x4b0\(%ebp\)
+  8b:	89 b5 50 fb ff ff    	mov    %esi,-0x4b0\(%ebp\)
+  91:	89 b5 50 fb ff ff    	mov    %esi,-0x4b0\(%ebp\)
+  97:	89 b5 50 fb ff ff    	mov    %esi,-0x4b0\(%ebp\)
+  9d:	89 75 0c             	mov    %esi,0xc\(%ebp\)
+  a0:	e9 [0-9a-f ]+       	jmp    .*
+  a5:	89 b5 50 fb ff ff    	mov    %esi,-0x4b0\(%ebp\)
+  ab:	89 b5 50 fb ff ff    	mov    %esi,-0x4b0\(%ebp\)
+  b1:	89 b5 50 fb ff ff    	mov    %esi,-0x4b0\(%ebp\)
+  b7:	89 b5 50 fb ff ff    	mov    %esi,-0x4b0\(%ebp\)
+  bd:	89 75 00             	mov    %esi,0x0\(%ebp\)
+  c0:	74 c3                	je     85 <foo\+0x85>
+  c2:	74 c1                	je     85 <foo\+0x85>
+#pass
diff --git a/gas/testsuite/gas/i386/align-branch-1e.d b/gas/testsuite/gas/i386/align-branch-1e.d
new file mode 100644
index 0000000000..dafbee13f1
--- /dev/null
+++ b/gas/testsuite/gas/i386/align-branch-1e.d
@@ -0,0 +1,77 @@
+#source: align-branch-1.s
+#as: -malign-branch-boundary=32 -malign-branch=jcc
+#objdump: -dw
+
+.*: +file format .*
+
+Disassembly of section .text:
+
+0+ <foo>:
+   0:	65 a3 01 00 00 00    	mov    %eax,%gs:0x1
+   6:	55                   	push   %ebp
+   7:	55                   	push   %ebp
+   8:	55                   	push   %ebp
+   9:	55                   	push   %ebp
+   a:	89 e5                	mov    %esp,%ebp
+   c:	89 7d f8             	mov    %edi,-0x8\(%ebp\)
+   f:	89 75 f4             	mov    %esi,-0xc\(%ebp\)
+  12:	89 75 f4             	mov    %esi,-0xc\(%ebp\)
+  15:	89 75 f4             	mov    %esi,-0xc\(%ebp\)
+  18:	89 75 f4             	mov    %esi,-0xc\(%ebp\)
+  1b:	89 75 f4             	mov    %esi,-0xc\(%ebp\)
+  1e:	39 c5                	cmp    %eax,%ebp
+  20:	74 5a                	je     7c <foo\+0x7c>
+  22:	89 73 f4             	mov    %esi,-0xc\(%ebx\)
+  25:	89 75 f4             	mov    %esi,-0xc\(%ebp\)
+  28:	89 7d f8             	mov    %edi,-0x8\(%ebp\)
+  2b:	89 75 f4             	mov    %esi,-0xc\(%ebp\)
+  2e:	89 75 f4             	mov    %esi,-0xc\(%ebp\)
+  31:	89 75 f4             	mov    %esi,-0xc\(%ebp\)
+  34:	89 75 f4             	mov    %esi,-0xc\(%ebp\)
+  37:	89 75 f4             	mov    %esi,-0xc\(%ebp\)
+  3a:	5d                   	pop    %ebp
+  3b:	5d                   	pop    %ebp
+  3c:	5d                   	pop    %ebp
+  3d:	74 3d                	je     7c <foo\+0x7c>
+  3f:	5d                   	pop    %ebp
+  40:	74 3a                	je     7c <foo\+0x7c>
+  42:	89 44 24 fc          	mov    %eax,-0x4\(%esp\)
+  46:	89 75 f4             	mov    %esi,-0xc\(%ebp\)
+  49:	89 7d f8             	mov    %edi,-0x8\(%ebp\)
+  4c:	89 75 f4             	mov    %esi,-0xc\(%ebp\)
+  4f:	89 75 f4             	mov    %esi,-0xc\(%ebp\)
+  52:	89 75 f4             	mov    %esi,-0xc\(%ebp\)
+  55:	89 75 f4             	mov    %esi,-0xc\(%ebp\)
+  58:	89 75 f4             	mov    %esi,-0xc\(%ebp\)
+  5b:	5d                   	pop    %ebp
+  5c:	eb 24                	jmp    82 <foo\+0x82>
+  5e:	eb 22                	jmp    82 <foo\+0x82>
+  60:	eb 20                	jmp    82 <foo\+0x82>
+  62:	89 45 fc             	mov    %eax,-0x4\(%ebp\)
+  65:	89 75 f4             	mov    %esi,-0xc\(%ebp\)
+  68:	89 7d f8             	mov    %edi,-0x8\(%ebp\)
+  6b:	89 75 f4             	mov    %esi,-0xc\(%ebp\)
+  6e:	89 75 f4             	mov    %esi,-0xc\(%ebp\)
+  71:	89 75 f4             	mov    %esi,-0xc\(%ebp\)
+  74:	5d                   	pop    %ebp
+  75:	5d                   	pop    %ebp
+  76:	39 c5                	cmp    %eax,%ebp
+  78:	74 02                	je     7c <foo\+0x7c>
+  7a:	eb 06                	jmp    82 <foo\+0x82>
+  7c:	8b 45 f4             	mov    -0xc\(%ebp\),%eax
+  7f:	89 45 fc             	mov    %eax,-0x4\(%ebp\)
+  82:	89 b5 50 fb ff ff    	mov    %esi,-0x4b0\(%ebp\)
+  88:	89 b5 50 fb ff ff    	mov    %esi,-0x4b0\(%ebp\)
+  8e:	89 b5 50 fb ff ff    	mov    %esi,-0x4b0\(%ebp\)
+  94:	89 b5 50 fb ff ff    	mov    %esi,-0x4b0\(%ebp\)
+  9a:	89 75 0c             	mov    %esi,0xc\(%ebp\)
+  9d:	e9 [0-9a-f ]+       	jmp    .*
+  a2:	89 b5 50 fb ff ff    	mov    %esi,-0x4b0\(%ebp\)
+  a8:	89 b5 50 fb ff ff    	mov    %esi,-0x4b0\(%ebp\)
+  ae:	89 b5 50 fb ff ff    	mov    %esi,-0x4b0\(%ebp\)
+  b4:	89 b5 50 fb ff ff    	mov    %esi,-0x4b0\(%ebp\)
+  ba:	89 75 00             	mov    %esi,0x0\(%ebp\)
+  bd:	74 c3                	je     82 <foo\+0x82>
+  bf:	90                   	nop
+  c0:	74 c0                	je     82 <foo\+0x82>
+#pass
diff --git a/gas/testsuite/gas/i386/align-branch-1f.d b/gas/testsuite/gas/i386/align-branch-1f.d
new file mode 100644
index 0000000000..bf197c979b
--- /dev/null
+++ b/gas/testsuite/gas/i386/align-branch-1f.d
@@ -0,0 +1,77 @@
+#source: align-branch-1.s
+#as: -malign-branch-boundary=32 -malign-branch=jcc+jmp
+#objdump: -dw
+
+.*: +file format .*
+
+Disassembly of section .text:
+
+0+ <foo>:
+   0:	65 a3 01 00 00 00    	mov    %eax,%gs:0x1
+   6:	55                   	push   %ebp
+   7:	55                   	push   %ebp
+   8:	55                   	push   %ebp
+   9:	55                   	push   %ebp
+   a:	89 e5                	mov    %esp,%ebp
+   c:	89 7d f8             	mov    %edi,-0x8\(%ebp\)
+   f:	89 75 f4             	mov    %esi,-0xc\(%ebp\)
+  12:	89 75 f4             	mov    %esi,-0xc\(%ebp\)
+  15:	89 75 f4             	mov    %esi,-0xc\(%ebp\)
+  18:	89 75 f4             	mov    %esi,-0xc\(%ebp\)
+  1b:	89 75 f4             	mov    %esi,-0xc\(%ebp\)
+  1e:	39 c5                	cmp    %eax,%ebp
+  20:	74 5c                	je     7e <foo\+0x7e>
+  22:	89 73 f4             	mov    %esi,-0xc\(%ebx\)
+  25:	89 75 f4             	mov    %esi,-0xc\(%ebp\)
+  28:	89 7d f8             	mov    %edi,-0x8\(%ebp\)
+  2b:	89 75 f4             	mov    %esi,-0xc\(%ebp\)
+  2e:	89 75 f4             	mov    %esi,-0xc\(%ebp\)
+  31:	89 75 f4             	mov    %esi,-0xc\(%ebp\)
+  34:	89 75 f4             	mov    %esi,-0xc\(%ebp\)
+  37:	89 75 f4             	mov    %esi,-0xc\(%ebp\)
+  3a:	5d                   	pop    %ebp
+  3b:	5d                   	pop    %ebp
+  3c:	5d                   	pop    %ebp
+  3d:	74 3f                	je     7e <foo\+0x7e>
+  3f:	5d                   	pop    %ebp
+  40:	74 3c                	je     7e <foo\+0x7e>
+  42:	89 44 24 fc          	mov    %eax,-0x4\(%esp\)
+  46:	89 75 f4             	mov    %esi,-0xc\(%ebp\)
+  49:	89 7d f8             	mov    %edi,-0x8\(%ebp\)
+  4c:	89 75 f4             	mov    %esi,-0xc\(%ebp\)
+  4f:	89 75 f4             	mov    %esi,-0xc\(%ebp\)
+  52:	89 75 f4             	mov    %esi,-0xc\(%ebp\)
+  55:	89 75 f4             	mov    %esi,-0xc\(%ebp\)
+  58:	89 75 f4             	mov    %esi,-0xc\(%ebp\)
+  5b:	5d                   	pop    %ebp
+  5c:	eb 27                	jmp    85 <foo\+0x85>
+  5e:	66 90                	xchg   %ax,%ax
+  60:	eb 23                	jmp    85 <foo\+0x85>
+  62:	eb 21                	jmp    85 <foo\+0x85>
+  64:	89 45 fc             	mov    %eax,-0x4\(%ebp\)
+  67:	89 75 f4             	mov    %esi,-0xc\(%ebp\)
+  6a:	89 7d f8             	mov    %edi,-0x8\(%ebp\)
+  6d:	89 75 f4             	mov    %esi,-0xc\(%ebp\)
+  70:	89 75 f4             	mov    %esi,-0xc\(%ebp\)
+  73:	89 75 f4             	mov    %esi,-0xc\(%ebp\)
+  76:	5d                   	pop    %ebp
+  77:	5d                   	pop    %ebp
+  78:	39 c5                	cmp    %eax,%ebp
+  7a:	74 02                	je     7e <foo\+0x7e>
+  7c:	eb 07                	jmp    85 <foo\+0x85>
+  7e:	36 8b 45 f4          	mov    %ss:-0xc\(%ebp\),%eax
+  82:	89 45 fc             	mov    %eax,-0x4\(%ebp\)
+  85:	89 b5 50 fb ff ff    	mov    %esi,-0x4b0\(%ebp\)
+  8b:	89 b5 50 fb ff ff    	mov    %esi,-0x4b0\(%ebp\)
+  91:	89 b5 50 fb ff ff    	mov    %esi,-0x4b0\(%ebp\)
+  97:	89 b5 50 fb ff ff    	mov    %esi,-0x4b0\(%ebp\)
+  9d:	89 75 0c             	mov    %esi,0xc\(%ebp\)
+  a0:	e9 [0-9a-f ]+       	jmp    .*
+  a5:	89 b5 50 fb ff ff    	mov    %esi,-0x4b0\(%ebp\)
+  ab:	89 b5 50 fb ff ff    	mov    %esi,-0x4b0\(%ebp\)
+  b1:	89 b5 50 fb ff ff    	mov    %esi,-0x4b0\(%ebp\)
+  b7:	89 b5 50 fb ff ff    	mov    %esi,-0x4b0\(%ebp\)
+  bd:	89 75 00             	mov    %esi,0x0\(%ebp\)
+  c0:	74 c3                	je     85 <foo\+0x85>
+  c2:	74 c1                	je     85 <foo\+0x85>
+#pass
diff --git a/gas/testsuite/gas/i386/align-branch-1g.d b/gas/testsuite/gas/i386/align-branch-1g.d
new file mode 100644
index 0000000000..6cae2cd5f4
--- /dev/null
+++ b/gas/testsuite/gas/i386/align-branch-1g.d
@@ -0,0 +1,77 @@
+#source: align-branch-1.s
+#as: -mbranches-within-32B-boundaries
+#objdump: -dw
+
+.*: +file format .*
+
+Disassembly of section .text:
+
+0+ <foo>:
+   0:	65 65 65 a3 01 00 00 00 	gs gs mov %eax,%gs:0x1
+   8:	55                   	push   %ebp
+   9:	55                   	push   %ebp
+   a:	55                   	push   %ebp
+   b:	55                   	push   %ebp
+   c:	89 e5                	mov    %esp,%ebp
+   e:	89 7d f8             	mov    %edi,-0x8\(%ebp\)
+  11:	89 75 f4             	mov    %esi,-0xc\(%ebp\)
+  14:	89 75 f4             	mov    %esi,-0xc\(%ebp\)
+  17:	89 75 f4             	mov    %esi,-0xc\(%ebp\)
+  1a:	89 75 f4             	mov    %esi,-0xc\(%ebp\)
+  1d:	89 75 f4             	mov    %esi,-0xc\(%ebp\)
+  20:	39 c5                	cmp    %eax,%ebp
+  22:	74 5e                	je     82 <foo\+0x82>
+  24:	3e 89 73 f4          	mov    %esi,%ds:-0xc\(%ebx\)
+  28:	89 75 f4             	mov    %esi,-0xc\(%ebp\)
+  2b:	89 7d f8             	mov    %edi,-0x8\(%ebp\)
+  2e:	89 75 f4             	mov    %esi,-0xc\(%ebp\)
+  31:	89 75 f4             	mov    %esi,-0xc\(%ebp\)
+  34:	89 75 f4             	mov    %esi,-0xc\(%ebp\)
+  37:	89 75 f4             	mov    %esi,-0xc\(%ebp\)
+  3a:	89 75 f4             	mov    %esi,-0xc\(%ebp\)
+  3d:	5d                   	pop    %ebp
+  3e:	5d                   	pop    %ebp
+  3f:	5d                   	pop    %ebp
+  40:	74 40                	je     82 <foo\+0x82>
+  42:	5d                   	pop    %ebp
+  43:	74 3d                	je     82 <foo\+0x82>
+  45:	36 89 44 24 fc       	mov    %eax,%ss:-0x4\(%esp\)
+  4a:	89 75 f4             	mov    %esi,-0xc\(%ebp\)
+  4d:	89 7d f8             	mov    %edi,-0x8\(%ebp\)
+  50:	89 75 f4             	mov    %esi,-0xc\(%ebp\)
+  53:	89 75 f4             	mov    %esi,-0xc\(%ebp\)
+  56:	89 75 f4             	mov    %esi,-0xc\(%ebp\)
+  59:	89 75 f4             	mov    %esi,-0xc\(%ebp\)
+  5c:	89 75 f4             	mov    %esi,-0xc\(%ebp\)
+  5f:	5d                   	pop    %ebp
+  60:	eb 26                	jmp    88 <foo\+0x88>
+  62:	eb 24                	jmp    88 <foo\+0x88>
+  64:	eb 22                	jmp    88 <foo\+0x88>
+  66:	89 45 fc             	mov    %eax,-0x4\(%ebp\)
+  69:	89 75 f4             	mov    %esi,-0xc\(%ebp\)
+  6c:	89 7d f8             	mov    %edi,-0x8\(%ebp\)
+  6f:	89 75 f4             	mov    %esi,-0xc\(%ebp\)
+  72:	89 75 f4             	mov    %esi,-0xc\(%ebp\)
+  75:	89 75 f4             	mov    %esi,-0xc\(%ebp\)
+  78:	5d                   	pop    %ebp
+  79:	5d                   	pop    %ebp
+  7a:	39 c5                	cmp    %eax,%ebp
+  7c:	74 04                	je     82 <foo\+0x82>
+  7e:	66 90                	xchg   %ax,%ax
+  80:	eb 06                	jmp    88 <foo\+0x88>
+  82:	8b 45 f4             	mov    -0xc\(%ebp\),%eax
+  85:	89 45 fc             	mov    %eax,-0x4\(%ebp\)
+  88:	89 b5 50 fb ff ff    	mov    %esi,-0x4b0\(%ebp\)
+  8e:	89 b5 50 fb ff ff    	mov    %esi,-0x4b0\(%ebp\)
+  94:	89 b5 50 fb ff ff    	mov    %esi,-0x4b0\(%ebp\)
+  9a:	89 b5 50 fb ff ff    	mov    %esi,-0x4b0\(%ebp\)
+  a0:	89 75 0c             	mov    %esi,0xc\(%ebp\)
+  a3:	e9 [0-9a-f ]+       	jmp    .*
+  a8:	89 b5 50 fb ff ff    	mov    %esi,-0x4b0\(%ebp\)
+  ae:	89 b5 50 fb ff ff    	mov    %esi,-0x4b0\(%ebp\)
+  b4:	89 b5 50 fb ff ff    	mov    %esi,-0x4b0\(%ebp\)
+  ba:	89 b5 50 fb ff ff    	mov    %esi,-0x4b0\(%ebp\)
+  c0:	89 75 00             	mov    %esi,0x0\(%ebp\)
+  c3:	74 c3                	je     88 <foo\+0x88>
+  c5:	74 c1                	je     88 <foo\+0x88>
+#pass
diff --git a/gas/testsuite/gas/i386/align-branch-1h.d b/gas/testsuite/gas/i386/align-branch-1h.d
new file mode 100644
index 0000000000..01871ee98f
--- /dev/null
+++ b/gas/testsuite/gas/i386/align-branch-1h.d
@@ -0,0 +1,76 @@
+#source: align-branch-1.s
+#as: -mbranches-within-32B-boundaries -malign-branch-boundary=0
+#objdump: -dw
+
+.*: +file format .*
+
+Disassembly of section .text:
+
+0+ <foo>:
+   0:	65 a3 01 00 00 00    	mov    %eax,%gs:0x1
+   6:	55                   	push   %ebp
+   7:	55                   	push   %ebp
+   8:	55                   	push   %ebp
+   9:	55                   	push   %ebp
+   a:	89 e5                	mov    %esp,%ebp
+   c:	89 7d f8             	mov    %edi,-0x8\(%ebp\)
+   f:	89 75 f4             	mov    %esi,-0xc\(%ebp\)
+  12:	89 75 f4             	mov    %esi,-0xc\(%ebp\)
+  15:	89 75 f4             	mov    %esi,-0xc\(%ebp\)
+  18:	89 75 f4             	mov    %esi,-0xc\(%ebp\)
+  1b:	89 75 f4             	mov    %esi,-0xc\(%ebp\)
+  1e:	39 c5                	cmp    %eax,%ebp
+  20:	74 5a                	je     7c <foo\+0x7c>
+  22:	89 73 f4             	mov    %esi,-0xc\(%ebx\)
+  25:	89 75 f4             	mov    %esi,-0xc\(%ebp\)
+  28:	89 7d f8             	mov    %edi,-0x8\(%ebp\)
+  2b:	89 75 f4             	mov    %esi,-0xc\(%ebp\)
+  2e:	89 75 f4             	mov    %esi,-0xc\(%ebp\)
+  31:	89 75 f4             	mov    %esi,-0xc\(%ebp\)
+  34:	89 75 f4             	mov    %esi,-0xc\(%ebp\)
+  37:	89 75 f4             	mov    %esi,-0xc\(%ebp\)
+  3a:	5d                   	pop    %ebp
+  3b:	5d                   	pop    %ebp
+  3c:	5d                   	pop    %ebp
+  3d:	74 3d                	je     7c <foo\+0x7c>
+  3f:	5d                   	pop    %ebp
+  40:	74 3a                	je     7c <foo\+0x7c>
+  42:	89 44 24 fc          	mov    %eax,-0x4\(%esp\)
+  46:	89 75 f4             	mov    %esi,-0xc\(%ebp\)
+  49:	89 7d f8             	mov    %edi,-0x8\(%ebp\)
+  4c:	89 75 f4             	mov    %esi,-0xc\(%ebp\)
+  4f:	89 75 f4             	mov    %esi,-0xc\(%ebp\)
+  52:	89 75 f4             	mov    %esi,-0xc\(%ebp\)
+  55:	89 75 f4             	mov    %esi,-0xc\(%ebp\)
+  58:	89 75 f4             	mov    %esi,-0xc\(%ebp\)
+  5b:	5d                   	pop    %ebp
+  5c:	eb 24                	jmp    82 <foo\+0x82>
+  5e:	eb 22                	jmp    82 <foo\+0x82>
+  60:	eb 20                	jmp    82 <foo\+0x82>
+  62:	89 45 fc             	mov    %eax,-0x4\(%ebp\)
+  65:	89 75 f4             	mov    %esi,-0xc\(%ebp\)
+  68:	89 7d f8             	mov    %edi,-0x8\(%ebp\)
+  6b:	89 75 f4             	mov    %esi,-0xc\(%ebp\)
+  6e:	89 75 f4             	mov    %esi,-0xc\(%ebp\)
+  71:	89 75 f4             	mov    %esi,-0xc\(%ebp\)
+  74:	5d                   	pop    %ebp
+  75:	5d                   	pop    %ebp
+  76:	39 c5                	cmp    %eax,%ebp
+  78:	74 02                	je     7c <foo\+0x7c>
+  7a:	eb 06                	jmp    82 <foo\+0x82>
+  7c:	8b 45 f4             	mov    -0xc\(%ebp\),%eax
+  7f:	89 45 fc             	mov    %eax,-0x4\(%ebp\)
+  82:	89 b5 50 fb ff ff    	mov    %esi,-0x4b0\(%ebp\)
+  88:	89 b5 50 fb ff ff    	mov    %esi,-0x4b0\(%ebp\)
+  8e:	89 b5 50 fb ff ff    	mov    %esi,-0x4b0\(%ebp\)
+  94:	89 b5 50 fb ff ff    	mov    %esi,-0x4b0\(%ebp\)
+  9a:	89 75 0c             	mov    %esi,0xc\(%ebp\)
+  9d:	e9 [0-9a-f ]+       	jmp    .*
+  a2:	89 b5 50 fb ff ff    	mov    %esi,-0x4b0\(%ebp\)
+  a8:	89 b5 50 fb ff ff    	mov    %esi,-0x4b0\(%ebp\)
+  ae:	89 b5 50 fb ff ff    	mov    %esi,-0x4b0\(%ebp\)
+  b4:	89 b5 50 fb ff ff    	mov    %esi,-0x4b0\(%ebp\)
+  ba:	89 75 00             	mov    %esi,0x0\(%ebp\)
+  bd:	74 c3                	je     82 <foo\+0x82>
+  bf:	74 c1                	je     82 <foo\+0x82>
+#pass
diff --git a/gas/testsuite/gas/i386/align-branch-1i.d b/gas/testsuite/gas/i386/align-branch-1i.d
new file mode 100644
index 0000000000..e2cbc28cde
--- /dev/null
+++ b/gas/testsuite/gas/i386/align-branch-1i.d
@@ -0,0 +1,80 @@
+#source: align-branch-1.s
+#as: -malign-branch-boundary=32 -malign-branch-prefix-size=0
+#objdump: -dw
+
+.*: +file format .*
+
+Disassembly of section .text:
+
+0+ <foo>:
+   0:	65 a3 01 00 00 00    	mov    %eax,%gs:0x1
+   6:	55                   	push   %ebp
+   7:	55                   	push   %ebp
+   8:	55                   	push   %ebp
+   9:	55                   	push   %ebp
+   a:	89 e5                	mov    %esp,%ebp
+   c:	89 7d f8             	mov    %edi,-0x8\(%ebp\)
+   f:	89 75 f4             	mov    %esi,-0xc\(%ebp\)
+  12:	89 75 f4             	mov    %esi,-0xc\(%ebp\)
+  15:	89 75 f4             	mov    %esi,-0xc\(%ebp\)
+  18:	89 75 f4             	mov    %esi,-0xc\(%ebp\)
+  1b:	89 75 f4             	mov    %esi,-0xc\(%ebp\)
+  1e:	66 90                	xchg   %ax,%ax
+  20:	39 c5                	cmp    %eax,%ebp
+  22:	74 5e                	je     82 <foo\+0x82>
+  24:	89 73 f4             	mov    %esi,-0xc\(%ebx\)
+  27:	89 75 f4             	mov    %esi,-0xc\(%ebp\)
+  2a:	89 7d f8             	mov    %edi,-0x8\(%ebp\)
+  2d:	89 75 f4             	mov    %esi,-0xc\(%ebp\)
+  30:	89 75 f4             	mov    %esi,-0xc\(%ebp\)
+  33:	89 75 f4             	mov    %esi,-0xc\(%ebp\)
+  36:	89 75 f4             	mov    %esi,-0xc\(%ebp\)
+  39:	89 75 f4             	mov    %esi,-0xc\(%ebp\)
+  3c:	5d                   	pop    %ebp
+  3d:	5d                   	pop    %ebp
+  3e:	5d                   	pop    %ebp
+  3f:	90                   	nop
+  40:	74 40                	je     82 <foo\+0x82>
+  42:	5d                   	pop    %ebp
+  43:	74 3d                	je     82 <foo\+0x82>
+  45:	89 44 24 fc          	mov    %eax,-0x4\(%esp\)
+  49:	89 75 f4             	mov    %esi,-0xc\(%ebp\)
+  4c:	89 7d f8             	mov    %edi,-0x8\(%ebp\)
+  4f:	89 75 f4             	mov    %esi,-0xc\(%ebp\)
+  52:	89 75 f4             	mov    %esi,-0xc\(%ebp\)
+  55:	89 75 f4             	mov    %esi,-0xc\(%ebp\)
+  58:	89 75 f4             	mov    %esi,-0xc\(%ebp\)
+  5b:	89 75 f4             	mov    %esi,-0xc\(%ebp\)
+  5e:	5d                   	pop    %ebp
+  5f:	90                   	nop
+  60:	eb 26                	jmp    88 <foo\+0x88>
+  62:	eb 24                	jmp    88 <foo\+0x88>
+  64:	eb 22                	jmp    88 <foo\+0x88>
+  66:	89 45 fc             	mov    %eax,-0x4\(%ebp\)
+  69:	89 75 f4             	mov    %esi,-0xc\(%ebp\)
+  6c:	89 7d f8             	mov    %edi,-0x8\(%ebp\)
+  6f:	89 75 f4             	mov    %esi,-0xc\(%ebp\)
+  72:	89 75 f4             	mov    %esi,-0xc\(%ebp\)
+  75:	89 75 f4             	mov    %esi,-0xc\(%ebp\)
+  78:	5d                   	pop    %ebp
+  79:	5d                   	pop    %ebp
+  7a:	39 c5                	cmp    %eax,%ebp
+  7c:	74 04                	je     82 <foo\+0x82>
+  7e:	66 90                	xchg   %ax,%ax
+  80:	eb 06                	jmp    88 <foo\+0x88>
+  82:	8b 45 f4             	mov    -0xc\(%ebp\),%eax
+  85:	89 45 fc             	mov    %eax,-0x4\(%ebp\)
+  88:	89 b5 50 fb ff ff    	mov    %esi,-0x4b0\(%ebp\)
+  8e:	89 b5 50 fb ff ff    	mov    %esi,-0x4b0\(%ebp\)
+  94:	89 b5 50 fb ff ff    	mov    %esi,-0x4b0\(%ebp\)
+  9a:	89 b5 50 fb ff ff    	mov    %esi,-0x4b0\(%ebp\)
+  a0:	89 75 0c             	mov    %esi,0xc\(%ebp\)
+  a3:	e9 [0-9a-f ]+       	jmp    .*
+  a8:	89 b5 50 fb ff ff    	mov    %esi,-0x4b0\(%ebp\)
+  ae:	89 b5 50 fb ff ff    	mov    %esi,-0x4b0\(%ebp\)
+  b4:	89 b5 50 fb ff ff    	mov    %esi,-0x4b0\(%ebp\)
+  ba:	89 b5 50 fb ff ff    	mov    %esi,-0x4b0\(%ebp\)
+  c0:	89 75 00             	mov    %esi,0x0\(%ebp\)
+  c3:	74 c3                	je     88 <foo\+0x88>
+  c5:	74 c1                	je     88 <foo\+0x88>
+#pass
diff --git a/gas/testsuite/gas/i386/align-branch-2.s b/gas/testsuite/gas/i386/align-branch-2.s
new file mode 100644
index 0000000000..4a79bbb082
--- /dev/null
+++ b/gas/testsuite/gas/i386/align-branch-2.s
@@ -0,0 +1,49 @@
+  .text
+  .globl  foo
+  .p2align  4
+foo:
+  movl  %eax, %fs:0x1
+  pushl  %ebp
+  pushl  %ebp
+  pushl  %ebp
+  pushl  %ebp
+  movl  %esp, %ebp
+  movl  %esi, -12(%ebp)
+  movl  %esi, -12(%ebp)
+  movl  %esi, -12(%ebp)
+  movl  %esi, -12(%ebp)
+  movl  %esi, -12(%ebp)
+  movl  %esi, -12(%ebp)
+  jmp  *%eax
+  pushl  %ebp
+  pushl  %ebp
+  movl  %eax, %fs:0x1
+  movl  %esp, %ebp
+  movl  %esi, -12(%ebp)
+  movl  %esi, -12(%ebp)
+  movl  %esi, -12(%ebp)
+  movl  %esi, -12(%ebp)
+  movl  %esi, -12(%ebp)
+  movl  %esi, -12(%ebp)
+  call *%eax
+  movl  %esi, -12(%ebp)
+  pushl  %ebp
+  pushl  %ebp
+  movl  %eax, %fs:0x1
+  movl  %esp, %ebp
+  movl  %esi, -12(%ebp)
+  movl  %esi, -12(%ebp)
+  movl  %esi, -12(%ebp)
+  movl  %esi, -12(%ebp)
+  call  foo
+  movl  %esi, -12(%ebp)
+  pushl  %ebp
+  pushl  %ebp
+  pushl  %ebp
+  pushl  %ebp
+  movl  %eax, %fs:0x1
+  movl  %esp, %ebp
+  movl  %esi, -12(%ebp)
+  movl  %esi, -12(%ebp)
+  call  *foo
+  pushl  %ebp
diff --git a/gas/testsuite/gas/i386/align-branch-2a.d b/gas/testsuite/gas/i386/align-branch-2a.d
new file mode 100644
index 0000000000..cba0560d9c
--- /dev/null
+++ b/gas/testsuite/gas/i386/align-branch-2a.d
@@ -0,0 +1,55 @@
+#source: align-branch-2.s
+#as: -malign-branch-boundary=32 -malign-branch=fused+jcc+jmp
+#objdump: -dw
+
+.*: +file format .*
+
+Disassembly of section .text:
+
+0+ <foo>:
+   0:	64 a3 01 00 00 00    	mov    %eax,%fs:0x1
+   6:	55                   	push   %ebp
+   7:	55                   	push   %ebp
+   8:	55                   	push   %ebp
+   9:	55                   	push   %ebp
+   a:	89 e5                	mov    %esp,%ebp
+   c:	89 75 f4             	mov    %esi,-0xc\(%ebp\)
+   f:	89 75 f4             	mov    %esi,-0xc\(%ebp\)
+  12:	89 75 f4             	mov    %esi,-0xc\(%ebp\)
+  15:	89 75 f4             	mov    %esi,-0xc\(%ebp\)
+  18:	89 75 f4             	mov    %esi,-0xc\(%ebp\)
+  1b:	89 75 f4             	mov    %esi,-0xc\(%ebp\)
+  1e:	ff e0                	jmp    \*%eax
+  20:	55                   	push   %ebp
+  21:	55                   	push   %ebp
+  22:	64 a3 01 00 00 00    	mov    %eax,%fs:0x1
+  28:	89 e5                	mov    %esp,%ebp
+  2a:	89 75 f4             	mov    %esi,-0xc\(%ebp\)
+  2d:	89 75 f4             	mov    %esi,-0xc\(%ebp\)
+  30:	89 75 f4             	mov    %esi,-0xc\(%ebp\)
+  33:	89 75 f4             	mov    %esi,-0xc\(%ebp\)
+  36:	89 75 f4             	mov    %esi,-0xc\(%ebp\)
+  39:	89 75 f4             	mov    %esi,-0xc\(%ebp\)
+  3c:	ff d0                	call   \*%eax
+  3e:	89 75 f4             	mov    %esi,-0xc\(%ebp\)
+  41:	55                   	push   %ebp
+  42:	55                   	push   %ebp
+  43:	64 a3 01 00 00 00    	mov    %eax,%fs:0x1
+  49:	89 e5                	mov    %esp,%ebp
+  4b:	89 75 f4             	mov    %esi,-0xc\(%ebp\)
+  4e:	89 75 f4             	mov    %esi,-0xc\(%ebp\)
+  51:	89 75 f4             	mov    %esi,-0xc\(%ebp\)
+  54:	89 75 f4             	mov    %esi,-0xc\(%ebp\)
+  57:	e8 [0-9a-f ]+       	call   .*
+  5c:	89 75 f4             	mov    %esi,-0xc\(%ebp\)
+  5f:	55                   	push   %ebp
+  60:	55                   	push   %ebp
+  61:	55                   	push   %ebp
+  62:	55                   	push   %ebp
+  63:	64 a3 01 00 00 00    	mov    %eax,%fs:0x1
+  69:	89 e5                	mov    %esp,%ebp
+  6b:	89 75 f4             	mov    %esi,-0xc\(%ebp\)
+  6e:	89 75 f4             	mov    %esi,-0xc\(%ebp\)
+  71:	ff 15 00 00 00 00    	call   \*0x0
+  77:	55                   	push   %ebp
+#pass
diff --git a/gas/testsuite/gas/i386/align-branch-2b.d b/gas/testsuite/gas/i386/align-branch-2b.d
new file mode 100644
index 0000000000..7d879b6ba5
--- /dev/null
+++ b/gas/testsuite/gas/i386/align-branch-2b.d
@@ -0,0 +1,55 @@
+#source: align-branch-2.s
+#as: -malign-branch-boundary=32 -malign-branch=indirect
+#objdump: -dw
+
+.*: +file format .*
+
+Disassembly of section .text:
+
+0+ <foo>:
+   0:	64 64 64 a3 01 00 00 00 	fs fs mov %eax,%fs:0x1
+   8:	55                   	push   %ebp
+   9:	55                   	push   %ebp
+   a:	55                   	push   %ebp
+   b:	55                   	push   %ebp
+   c:	89 e5                	mov    %esp,%ebp
+   e:	89 75 f4             	mov    %esi,-0xc\(%ebp\)
+  11:	89 75 f4             	mov    %esi,-0xc\(%ebp\)
+  14:	89 75 f4             	mov    %esi,-0xc\(%ebp\)
+  17:	89 75 f4             	mov    %esi,-0xc\(%ebp\)
+  1a:	89 75 f4             	mov    %esi,-0xc\(%ebp\)
+  1d:	89 75 f4             	mov    %esi,-0xc\(%ebp\)
+  20:	ff e0                	jmp    \*%eax
+  22:	3e 3e 55             	ds ds push %ebp
+  25:	55                   	push   %ebp
+  26:	64 a3 01 00 00 00    	mov    %eax,%fs:0x1
+  2c:	89 e5                	mov    %esp,%ebp
+  2e:	89 75 f4             	mov    %esi,-0xc\(%ebp\)
+  31:	89 75 f4             	mov    %esi,-0xc\(%ebp\)
+  34:	89 75 f4             	mov    %esi,-0xc\(%ebp\)
+  37:	89 75 f4             	mov    %esi,-0xc\(%ebp\)
+  3a:	89 75 f4             	mov    %esi,-0xc\(%ebp\)
+  3d:	89 75 f4             	mov    %esi,-0xc\(%ebp\)
+  40:	ff d0                	call   \*%eax
+  42:	89 75 f4             	mov    %esi,-0xc\(%ebp\)
+  45:	55                   	push   %ebp
+  46:	55                   	push   %ebp
+  47:	64 a3 01 00 00 00    	mov    %eax,%fs:0x1
+  4d:	89 e5                	mov    %esp,%ebp
+  4f:	89 75 f4             	mov    %esi,-0xc\(%ebp\)
+  52:	89 75 f4             	mov    %esi,-0xc\(%ebp\)
+  55:	89 75 f4             	mov    %esi,-0xc\(%ebp\)
+  58:	89 75 f4             	mov    %esi,-0xc\(%ebp\)
+  5b:	e8 [0-9a-f ]+       	call   .*
+  60:	89 75 f4             	mov    %esi,-0xc\(%ebp\)
+  63:	55                   	push   %ebp
+  64:	55                   	push   %ebp
+  65:	55                   	push   %ebp
+  66:	55                   	push   %ebp
+  67:	64 a3 01 00 00 00    	mov    %eax,%fs:0x1
+  6d:	89 e5                	mov    %esp,%ebp
+  6f:	89 75 f4             	mov    %esi,-0xc\(%ebp\)
+  72:	89 75 f4             	mov    %esi,-0xc\(%ebp\)
+  75:	ff 15 00 00 00 00    	call   \*0x0
+  7b:	55                   	push   %ebp
+#pass
diff --git a/gas/testsuite/gas/i386/align-branch-2c.d b/gas/testsuite/gas/i386/align-branch-2c.d
new file mode 100644
index 0000000000..2fc6339975
--- /dev/null
+++ b/gas/testsuite/gas/i386/align-branch-2c.d
@@ -0,0 +1,55 @@
+#source: align-branch-2.s
+#as: -malign-branch-boundary=32 -malign-branch=indirect+call
+#objdump: -dw
+
+.*: +file format .*
+
+Disassembly of section .text:
+
+0+ <foo>:
+   0:	64 64 64 a3 01 00 00 00 	fs fs mov %eax,%fs:0x1
+   8:	55                   	push   %ebp
+   9:	55                   	push   %ebp
+   a:	55                   	push   %ebp
+   b:	55                   	push   %ebp
+   c:	89 e5                	mov    %esp,%ebp
+   e:	89 75 f4             	mov    %esi,-0xc\(%ebp\)
+  11:	89 75 f4             	mov    %esi,-0xc\(%ebp\)
+  14:	89 75 f4             	mov    %esi,-0xc\(%ebp\)
+  17:	89 75 f4             	mov    %esi,-0xc\(%ebp\)
+  1a:	89 75 f4             	mov    %esi,-0xc\(%ebp\)
+  1d:	89 75 f4             	mov    %esi,-0xc\(%ebp\)
+  20:	ff e0                	jmp    \*%eax
+  22:	3e 3e 55             	ds ds push %ebp
+  25:	55                   	push   %ebp
+  26:	64 a3 01 00 00 00    	mov    %eax,%fs:0x1
+  2c:	89 e5                	mov    %esp,%ebp
+  2e:	89 75 f4             	mov    %esi,-0xc\(%ebp\)
+  31:	89 75 f4             	mov    %esi,-0xc\(%ebp\)
+  34:	89 75 f4             	mov    %esi,-0xc\(%ebp\)
+  37:	89 75 f4             	mov    %esi,-0xc\(%ebp\)
+  3a:	89 75 f4             	mov    %esi,-0xc\(%ebp\)
+  3d:	89 75 f4             	mov    %esi,-0xc\(%ebp\)
+  40:	ff d0                	call   \*%eax
+  42:	36 36 36 36 36 89 75 f4 	ss ss ss ss mov %esi,%ss:-0xc\(%ebp\)
+  4a:	55                   	push   %ebp
+  4b:	55                   	push   %ebp
+  4c:	64 a3 01 00 00 00    	mov    %eax,%fs:0x1
+  52:	89 e5                	mov    %esp,%ebp
+  54:	89 75 f4             	mov    %esi,-0xc\(%ebp\)
+  57:	89 75 f4             	mov    %esi,-0xc\(%ebp\)
+  5a:	89 75 f4             	mov    %esi,-0xc\(%ebp\)
+  5d:	89 75 f4             	mov    %esi,-0xc\(%ebp\)
+  60:	e8 [0-9a-f ]+       	call   .*
+  65:	36 36 36 36 36 89 75 f4 	ss ss ss ss mov %esi,%ss:-0xc\(%ebp\)
+  6d:	3e 55                	ds push %ebp
+  6f:	55                   	push   %ebp
+  70:	55                   	push   %ebp
+  71:	55                   	push   %ebp
+  72:	64 a3 01 00 00 00    	mov    %eax,%fs:0x1
+  78:	89 e5                	mov    %esp,%ebp
+  7a:	89 75 f4             	mov    %esi,-0xc\(%ebp\)
+  7d:	89 75 f4             	mov    %esi,-0xc\(%ebp\)
+  80:	ff 15 00 00 00 00    	call   \*0x0
+  86:	55                   	push   %ebp
+#pass
diff --git a/gas/testsuite/gas/i386/align-branch-3.d b/gas/testsuite/gas/i386/align-branch-3.d
new file mode 100644
index 0000000000..da31b6f503
--- /dev/null
+++ b/gas/testsuite/gas/i386/align-branch-3.d
@@ -0,0 +1,33 @@
+#as: -malign-branch-boundary=32 -malign-branch=indirect+call
+#objdump: -dw
+
+.*: +file format .*
+
+Disassembly of section .text:
+
+0+ <foo>:
+   0:	64 a3 01 00 00 00    	mov    %eax,%fs:0x1
+   6:	55                   	push   %ebp
+   7:	55                   	push   %ebp
+   8:	55                   	push   %ebp
+   9:	55                   	push   %ebp
+   a:	89 e5                	mov    %esp,%ebp
+   c:	89 75 f4             	mov    %esi,-0xc\(%ebp\)
+   f:	89 75 f4             	mov    %esi,-0xc\(%ebp\)
+  12:	89 75 f4             	mov    %esi,-0xc\(%ebp\)
+  15:	89 75 f4             	mov    %esi,-0xc\(%ebp\)
+  18:	89 75 f4             	mov    %esi,-0xc\(%ebp\)
+  1b:	89 75 f4             	mov    %esi,-0xc\(%ebp\)
+  1e:	e8 fc ff ff ff       	call   1f <foo\+0x1f>
+  23:	55                   	push   %ebp
+  24:	55                   	push   %ebp
+  25:	64 a3 01 00 00 00    	mov    %eax,%fs:0x1
+  2b:	89 e5                	mov    %esp,%ebp
+  2d:	89 75 f4             	mov    %esi,-0xc\(%ebp\)
+  30:	89 75 f4             	mov    %esi,-0xc\(%ebp\)
+  33:	89 75 f4             	mov    %esi,-0xc\(%ebp\)
+  36:	89 75 f4             	mov    %esi,-0xc\(%ebp\)
+  39:	89 75 f4             	mov    %esi,-0xc\(%ebp\)
+  3c:	ff 91 00 00 00 00    	call   \*0x0\(%ecx\)
+  42:	89 75 f4             	mov    %esi,-0xc\(%ebp\)
+#pass
diff --git a/gas/testsuite/gas/i386/align-branch-3.s b/gas/testsuite/gas/i386/align-branch-3.s
new file mode 100644
index 0000000000..e3e6c447c4
--- /dev/null
+++ b/gas/testsuite/gas/i386/align-branch-3.s
@@ -0,0 +1,28 @@
+  .text
+  .globl  foo
+  .p2align  4
+foo:
+  movl  %eax, %fs:0x1
+  pushl  %ebp
+  pushl  %ebp
+  pushl  %ebp
+  pushl  %ebp
+  movl  %esp, %ebp
+  movl  %esi, -12(%ebp)
+  movl  %esi, -12(%ebp)
+  movl  %esi, -12(%ebp)
+  movl  %esi, -12(%ebp)
+  movl  %esi, -12(%ebp)
+  movl  %esi, -12(%ebp)
+  call	___tls_get_addr
+  pushl  %ebp
+  pushl  %ebp
+  movl  %eax, %fs:0x1
+  movl  %esp, %ebp
+  movl  %esi, -12(%ebp)
+  movl  %esi, -12(%ebp)
+  movl  %esi, -12(%ebp)
+  movl  %esi, -12(%ebp)
+  movl  %esi, -12(%ebp)
+  call *___tls_get_addr@GOT(%ecx)
+  movl  %esi, -12(%ebp)
diff --git a/gas/testsuite/gas/i386/align-branch-4.s b/gas/testsuite/gas/i386/align-branch-4.s
new file mode 100644
index 0000000000..34ff361a7e
--- /dev/null
+++ b/gas/testsuite/gas/i386/align-branch-4.s
@@ -0,0 +1,30 @@
+  .text
+  .globl  foo
+  .p2align  4
+foo:
+  movl  %eax, %fs:0x1
+  pushl  %ebp
+  pushl  %ebp
+  pushl  %ebp
+  pushl  %ebp
+  pushl  %ebp
+  movl  %esp, %ebp
+  movl  %esi, -12(%ebp)
+  movl  %esi, -12(%ebp)
+  movl  %esi, -12(%ebp)
+  movl  %esi, -12(%ebp)
+  movl  %esi, -12(%ebp)
+  movl  %esi, -12(%ebp)
+  ret
+  pushl  %ebp
+  pushl  %ebp
+  movl  %eax, %fs:0x1
+  movl  %esp, %ebp
+  movl  %esi, -12(%ebp)
+  movl  %esi, -12(%ebp)
+  movl  %esi, -12(%ebp)
+  movl  %esi, -12(%ebp)
+  movl  %esi, -12(%ebp)
+  movl  %esi, -12(%ebp)
+  ret	$30
+  movl  %esi, -12(%ebp)
diff --git a/gas/testsuite/gas/i386/align-branch-4a.d b/gas/testsuite/gas/i386/align-branch-4a.d
new file mode 100644
index 0000000000..2b1e0b1f45
--- /dev/null
+++ b/gas/testsuite/gas/i386/align-branch-4a.d
@@ -0,0 +1,36 @@
+#source: align-branch-4.s
+#as: -malign-branch-boundary=32 -malign-branch=fused+jcc+jmp
+#objdump: -dw
+
+.*: +file format .*
+
+Disassembly of section .text:
+
+0+ <foo>:
+   0:	64 a3 01 00 00 00    	mov    %eax,%fs:0x1
+   6:	55                   	push   %ebp
+   7:	55                   	push   %ebp
+   8:	55                   	push   %ebp
+   9:	55                   	push   %ebp
+   a:	55                   	push   %ebp
+   b:	89 e5                	mov    %esp,%ebp
+   d:	89 75 f4             	mov    %esi,-0xc\(%ebp\)
+  10:	89 75 f4             	mov    %esi,-0xc\(%ebp\)
+  13:	89 75 f4             	mov    %esi,-0xc\(%ebp\)
+  16:	89 75 f4             	mov    %esi,-0xc\(%ebp\)
+  19:	89 75 f4             	mov    %esi,-0xc\(%ebp\)
+  1c:	89 75 f4             	mov    %esi,-0xc\(%ebp\)
+  1f:	c3                   	ret    
+  20:	55                   	push   %ebp
+  21:	55                   	push   %ebp
+  22:	64 a3 01 00 00 00    	mov    %eax,%fs:0x1
+  28:	89 e5                	mov    %esp,%ebp
+  2a:	89 75 f4             	mov    %esi,-0xc\(%ebp\)
+  2d:	89 75 f4             	mov    %esi,-0xc\(%ebp\)
+  30:	89 75 f4             	mov    %esi,-0xc\(%ebp\)
+  33:	89 75 f4             	mov    %esi,-0xc\(%ebp\)
+  36:	89 75 f4             	mov    %esi,-0xc\(%ebp\)
+  39:	89 75 f4             	mov    %esi,-0xc\(%ebp\)
+  3c:	c2 1e 00             	ret    \$0x1e
+  3f:	89 75 f4             	mov    %esi,-0xc\(%ebp\)
+#pass
diff --git a/gas/testsuite/gas/i386/align-branch-4b.d b/gas/testsuite/gas/i386/align-branch-4b.d
new file mode 100644
index 0000000000..c7690d36aa
--- /dev/null
+++ b/gas/testsuite/gas/i386/align-branch-4b.d
@@ -0,0 +1,36 @@
+#source: align-branch-4.s
+#as: -malign-branch-boundary=32 -malign-branch=ret
+#objdump: -dw
+
+.*: +file format .*
+
+Disassembly of section .text:
+
+0+ <foo>:
+   0:	64 64 a3 01 00 00 00 	fs mov %eax,%fs:0x1
+   7:	55                   	push   %ebp
+   8:	55                   	push   %ebp
+   9:	55                   	push   %ebp
+   a:	55                   	push   %ebp
+   b:	55                   	push   %ebp
+   c:	89 e5                	mov    %esp,%ebp
+   e:	89 75 f4             	mov    %esi,-0xc\(%ebp\)
+  11:	89 75 f4             	mov    %esi,-0xc\(%ebp\)
+  14:	89 75 f4             	mov    %esi,-0xc\(%ebp\)
+  17:	89 75 f4             	mov    %esi,-0xc\(%ebp\)
+  1a:	89 75 f4             	mov    %esi,-0xc\(%ebp\)
+  1d:	89 75 f4             	mov    %esi,-0xc\(%ebp\)
+  20:	c3                   	ret    
+  21:	3e 3e 3e 55          	ds ds ds push %ebp
+  25:	55                   	push   %ebp
+  26:	64 a3 01 00 00 00    	mov    %eax,%fs:0x1
+  2c:	89 e5                	mov    %esp,%ebp
+  2e:	89 75 f4             	mov    %esi,-0xc\(%ebp\)
+  31:	89 75 f4             	mov    %esi,-0xc\(%ebp\)
+  34:	89 75 f4             	mov    %esi,-0xc\(%ebp\)
+  37:	89 75 f4             	mov    %esi,-0xc\(%ebp\)
+  3a:	89 75 f4             	mov    %esi,-0xc\(%ebp\)
+  3d:	89 75 f4             	mov    %esi,-0xc\(%ebp\)
+  40:	c2 1e 00             	ret    \$0x1e
+  43:	89 75 f4             	mov    %esi,-0xc\(%ebp\)
+#pass
diff --git a/gas/testsuite/gas/i386/align-branch-5.d b/gas/testsuite/gas/i386/align-branch-5.d
new file mode 100644
index 0000000000..1f114272ec
--- /dev/null
+++ b/gas/testsuite/gas/i386/align-branch-5.d
@@ -0,0 +1,36 @@
+#as: -malign-branch-boundary=32 -malign-branch=jcc+fused+jmp
+#objdump: -dw
+
+.*: +file format .*
+
+Disassembly of section .text:
+
+0+ <foo>:
+   0:	c1 e9 02             	shr    \$0x2,%ecx
+   3:	c1 e9 02             	shr    \$0x2,%ecx
+   6:	c1 e9 02             	shr    \$0x2,%ecx
+   9:	89 d1                	mov    %edx,%ecx
+   b:	31 c0                	xor    %eax,%eax
+   d:	c1 e9 02             	shr    \$0x2,%ecx
+  10:	c1 e9 02             	shr    \$0x2,%ecx
+  13:	c1 e9 02             	shr    \$0x2,%ecx
+  16:	c1 e9 02             	shr    \$0x2,%ecx
+  19:	c1 e9 02             	shr    \$0x2,%ecx
+  1c:	c1 e9 02             	shr    \$0x2,%ecx
+  1f:	f6 c2 02             	test   \$0x2,%dl
+  22:	f3 ab                	rep stos %eax,%es:\(%edi\)
+  24:	75 dd                	jne    3 <foo\+0x3>
+  26:	31 c0                	xor    %eax,%eax
+  28:	c1 e9 02             	shr    \$0x2,%ecx
+  2b:	c1 e9 02             	shr    \$0x2,%ecx
+  2e:	c1 e9 02             	shr    \$0x2,%ecx
+  31:	89 d1                	mov    %edx,%ecx
+  33:	31 c0                	xor    %eax,%eax
+  35:	c1 e9 02             	shr    \$0x2,%ecx
+  38:	c1 e9 02             	shr    \$0x2,%ecx
+  3b:	c1 e9 02             	shr    \$0x2,%ecx
+  3e:	f6 c2 02             	test   \$0x2,%dl
+  41:	e8 [0-9a-f ]+       	call   .*
+  46:	75 e3                	jne    2b <foo\+0x2b>
+  48:	31 c0                	xor    %eax,%eax
+#pass
diff --git a/gas/testsuite/gas/i386/align-branch-5.s b/gas/testsuite/gas/i386/align-branch-5.s
new file mode 100644
index 0000000000..58e3b91691
--- /dev/null
+++ b/gas/testsuite/gas/i386/align-branch-5.s
@@ -0,0 +1,32 @@
+	.text
+	.p2align 4,,15
+foo:
+	shrl	$2, %ecx
+.L1:
+	shrl	$2, %ecx
+	shrl	$2, %ecx
+	movl	%edx, %ecx
+	xorl	%eax, %eax
+	shrl	$2, %ecx
+	shrl	$2, %ecx
+	shrl	$2, %ecx
+	shrl	$2, %ecx
+	shrl	$2, %ecx
+	shrl	$2, %ecx
+	testb	$2, %dl
+	rep stosl
+	jne	.L1
+	xorl	%eax, %eax
+	shrl	$2, %ecx
+.L2:
+	shrl	$2, %ecx
+	shrl	$2, %ecx
+	movl	%edx, %ecx
+	xorl	%eax, %eax
+	shrl	$2, %ecx
+	shrl	$2, %ecx
+	shrl	$2, %ecx
+	testb	$2, %dl
+	call	bar
+	jne	.L2
+	xorl	%eax, %eax
diff --git a/gas/testsuite/gas/i386/align-branch-6.d b/gas/testsuite/gas/i386/align-branch-6.d
new file mode 100644
index 0000000000..29e27878f4
--- /dev/null
+++ b/gas/testsuite/gas/i386/align-branch-6.d
@@ -0,0 +1,22 @@
+#as: -malign-branch-boundary=32 -D
+#objdump: -dw
+#warning_output: align-branch-6.e
+
+.*: +file format .*
+
+Disassembly of section .text:
+
+0+ <_start>:
+ +[a-f0-9]+:	eb 3c                	jmp    3e <_start\+0x3e>
+ +[a-f0-9]+:	8d b4 26 00 00 00 00 	lea    0x0\(%esi,%eiz,1\),%esi
+ +[a-f0-9]+:	8d b4 26 00 00 00 00 	lea    0x0\(%esi,%eiz,1\),%esi
+ +[a-f0-9]+:	8d b4 26 00 00 00 00 	lea    0x0\(%esi,%eiz,1\),%esi
+ +[a-f0-9]+:	8d b4 26 00 00 00 00 	lea    0x0\(%esi,%eiz,1\),%esi
+ +[a-f0-9]+:	8d b4 26 00 00 00 00 	lea    0x0\(%esi,%eiz,1\),%esi
+ +[a-f0-9]+:	8d b4 26 00 00 00 00 	lea    0x0\(%esi,%eiz,1\),%esi
+ +[a-f0-9]+:	8d b4 26 00 00 00 00 	lea    0x0\(%esi,%eiz,1\),%esi
+ +[a-f0-9]+:	8d b4 26 00 00 00 00 	lea    0x0\(%esi,%eiz,1\),%esi
+ +[a-f0-9]+:	8d 74 26 00          	lea    0x0\(%esi,%eiz,1\),%esi
+ +[a-f0-9]+:	f2 73 bf             	bnd jae 0 <_start>
+ +[a-f0-9]+:	c3                   	ret    
+#pass
diff --git a/gas/testsuite/gas/i386/align-branch-6.e b/gas/testsuite/gas/i386/align-branch-6.e
new file mode 100644
index 0000000000..c3378353ef
--- /dev/null
+++ b/gas/testsuite/gas/i386/align-branch-6.e
@@ -0,0 +1,2 @@
+.*: Assembler messages:
+.*:4: Warning: `constant directive` skips -malign-branch-boundary on `jnc`
diff --git a/gas/testsuite/gas/i386/align-branch-6.s b/gas/testsuite/gas/i386/align-branch-6.s
new file mode 100644
index 0000000000..41a92771a2
--- /dev/null
+++ b/gas/testsuite/gas/i386/align-branch-6.s
@@ -0,0 +1,7 @@
+	.text
+_start:
+.L0:
+	.nops 62
+	.byte 0xf2
+	jnc	.L0
+	ret
diff --git a/gas/testsuite/gas/i386/align-branch-7.d b/gas/testsuite/gas/i386/align-branch-7.d
new file mode 100644
index 0000000000..7f8c338f16
--- /dev/null
+++ b/gas/testsuite/gas/i386/align-branch-7.d
@@ -0,0 +1,18 @@
+#as: -malign-branch-boundary=32 -malign-branch-prefix-size=4
+#objdump: -dw
+
+.*: +file format .*
+
+Disassembly of section .text:
+
+0+ <foo>:
+ +[a-f0-9]+:	3e 66 0f 3a 60 00 03 	pcmpestrm \$0x3,%ds:\(%eax\),%xmm0
+ +[a-f0-9]+:	3e 3e 89 e5          	ds ds mov %esp,%ebp
+ +[a-f0-9]+:	89 bd 1c ff ff ff    	mov    %edi,-0xe4\(%ebp\)
+ +[a-f0-9]+:	89 75 f4             	mov    %esi,-0xc\(%ebp\)
+ +[a-f0-9]+:	89 75 f4             	mov    %esi,-0xc\(%ebp\)
+ +[a-f0-9]+:	89 75 f4             	mov    %esi,-0xc\(%ebp\)
+ +[a-f0-9]+:	65 a3 01 00 00 00    	mov    %eax,%gs:0x1
+ +[a-f0-9]+:	a8 04                	test   \$0x4,%al
+ +[a-f0-9]+:	70 dc                	jo     0 <foo>
+#pass
diff --git a/gas/testsuite/gas/i386/align-branch-7.s b/gas/testsuite/gas/i386/align-branch-7.s
new file mode 100644
index 0000000000..370eedb376
--- /dev/null
+++ b/gas/testsuite/gas/i386/align-branch-7.s
@@ -0,0 +1,14 @@
+  .text
+  .globl  foo
+  .p2align  4
+foo:
+.L1:
+  pcmpestrm $3, (%eax), %xmm0
+  movl  %esp, %ebp
+  movl  %edi, -228(%ebp)
+  movl  %esi, -12(%ebp)
+  movl  %esi, -12(%ebp)
+  movl  %esi, -12(%ebp)
+  movl	%eax, %gs:0x1
+  testb $0x4,%al
+  jo  .L1
diff --git a/gas/testsuite/gas/i386/align-branch-8.d b/gas/testsuite/gas/i386/align-branch-8.d
new file mode 100644
index 0000000000..ee7ae717a3
--- /dev/null
+++ b/gas/testsuite/gas/i386/align-branch-8.d
@@ -0,0 +1,18 @@
+#as: -malign-branch-boundary=32 -malign-branch-prefix-size=4
+#objdump: -dw
+
+.*: +file format .*
+
+Disassembly of section .text:
+
+0+ <foo>:
+ +[a-f0-9]+:	3e c4 e3 79 60 00 03 	vpcmpestrm \$0x3,%ds:\(%eax\),%xmm0
+ +[a-f0-9]+:	3e 3e 89 e5          	ds ds mov %esp,%ebp
+ +[a-f0-9]+:	89 bd 1c ff ff ff    	mov    %edi,-0xe4\(%ebp\)
+ +[a-f0-9]+:	89 75 f4             	mov    %esi,-0xc\(%ebp\)
+ +[a-f0-9]+:	89 75 f4             	mov    %esi,-0xc\(%ebp\)
+ +[a-f0-9]+:	89 75 f4             	mov    %esi,-0xc\(%ebp\)
+ +[a-f0-9]+:	65 a3 01 00 00 00    	mov    %eax,%gs:0x1
+ +[a-f0-9]+:	a8 04                	test   \$0x4,%al
+ +[a-f0-9]+:	70 dc                	jo     0 <foo>
+#pass
diff --git a/gas/testsuite/gas/i386/align-branch-8.s b/gas/testsuite/gas/i386/align-branch-8.s
new file mode 100644
index 0000000000..85a7fb6e4b
--- /dev/null
+++ b/gas/testsuite/gas/i386/align-branch-8.s
@@ -0,0 +1,14 @@
+  .text
+  .globl  foo
+  .p2align  4
+foo:
+.L1:
+  vpcmpestrm $3, (%eax), %xmm0
+  movl  %esp, %ebp
+  movl  %edi, -228(%ebp)
+  movl  %esi, -12(%ebp)
+  movl  %esi, -12(%ebp)
+  movl  %esi, -12(%ebp)
+  movl	%eax, %gs:0x1
+  testb $0x4,%al
+  jo  .L1
diff --git a/gas/testsuite/gas/i386/i386.exp b/gas/testsuite/gas/i386/i386.exp
index f4c7ce75e9..c31ffab268 100644
--- a/gas/testsuite/gas/i386/i386.exp
+++ b/gas/testsuite/gas/i386/i386.exp
@@ -498,6 +498,24 @@ if [expr ([istarget "i*86-*-*"] ||  [istarget "x86_64-*-*"]) && [gas_32_check]]
     run_list_test "optimize-6a" "-I${srcdir}/$subdir -march=+noavx -al"
     run_dump_test "optimize-6b"
     run_list_test "optimize-7" "-I${srcdir}/$subdir -march=+noavx2 -al"
+    run_dump_test "align-branch-1a"
+    run_dump_test "align-branch-1b"
+    run_dump_test "align-branch-1c"
+    run_dump_test "align-branch-1d"
+    run_dump_test "align-branch-1e"
+    run_dump_test "align-branch-1f"
+    run_dump_test "align-branch-1g"
+    run_dump_test "align-branch-1h"
+    run_dump_test "align-branch-1i"
+    run_dump_test "align-branch-2a"
+    run_dump_test "align-branch-2b"
+    run_dump_test "align-branch-2c"
+    run_dump_test "align-branch-4a"
+    run_dump_test "align-branch-4b"
+    run_dump_test "align-branch-5"
+    run_dump_test "align-branch-6"
+    run_dump_test "align-branch-7"
+    run_dump_test "align-branch-8"
 
     # These tests require support for 8 and 16 bit relocs,
     # so we only run them for ELF and COFF targets.
@@ -573,6 +591,10 @@ if [expr ([istarget "i*86-*-*"] ||  [istarget "x86_64-*-*"]) && [gas_32_check]]
 	run_dump_test "property-1"
 	run_dump_test "property-2"
 
+	if {[istarget "*-*-linux*"]} then {
+	    run_dump_test "align-branch-3"
+	}
+
 	if { [gas_64_check] } then {
 	    run_dump_test "att-regs"
 	    run_dump_test "intel-regs"
@@ -1032,6 +1054,24 @@ if [expr ([istarget "i*86-*-*"] || [istarget "x86_64-*-*"]) && [gas_64_check]] t
     run_list_test "x86-64-optimize-7a" "-I${srcdir}/$subdir -march=+noavx -al"
     run_dump_test "x86-64-optimize-7b"
     run_list_test "x86-64-optimize-8" "-I${srcdir}/$subdir -march=+noavx2 -al"
+    run_dump_test "x86-64-align-branch-1a"
+    run_dump_test "x86-64-align-branch-1b"
+    run_dump_test "x86-64-align-branch-1c"
+    run_dump_test "x86-64-align-branch-1d"
+    run_dump_test "x86-64-align-branch-1e"
+    run_dump_test "x86-64-align-branch-1f"
+    run_dump_test "x86-64-align-branch-1g"
+    run_dump_test "x86-64-align-branch-1h"
+    run_dump_test "x86-64-align-branch-1i"
+    run_dump_test "x86-64-align-branch-2a"
+    run_dump_test "x86-64-align-branch-2b"
+    run_dump_test "x86-64-align-branch-2c"
+    run_dump_test "x86-64-align-branch-4a"
+    run_dump_test "x86-64-align-branch-4b"
+    run_dump_test "x86-64-align-branch-5"
+    run_dump_test "x86-64-align-branch-6"
+    run_dump_test "x86-64-align-branch-7"
+    run_dump_test "x86-64-align-branch-8"
 
     if { ![istarget "*-*-aix*"]
       && ![istarget "*-*-beos*"]
@@ -1096,6 +1136,11 @@ if [expr ([istarget "i*86-*-*"] || [istarget "x86_64-*-*"]) && [gas_64_check]] t
 	run_dump_test "evex-no-scale-64"
 	run_dump_test "x86-64-property-1"
 	run_dump_test "x86-64-property-2"
+
+	if {[istarget "*-*-linux*"]} then {
+	    run_dump_test "x86-64-align-branch-3"
+	}
+
     }
 
     set ASFLAGS "$old_ASFLAGS"
diff --git a/gas/testsuite/gas/i386/x86-64-align-branch-1.s b/gas/testsuite/gas/i386/x86-64-align-branch-1.s
new file mode 100644
index 0000000000..74b3e7a41a
--- /dev/null
+++ b/gas/testsuite/gas/i386/x86-64-align-branch-1.s
@@ -0,0 +1,70 @@
+  .text
+  .globl  foo
+  .p2align  4
+foo:
+  movl  %eax, %fs:0x1
+  pushq  %rbp
+  pushq  %rbp
+  pushq  %rbp
+  movq  %rsp, %rbp
+  movl  %esi, -12(%rbp)
+  movl  %esi, -12(%rbp)
+  movl  %esi, -12(%rbp)
+  movl  %esi, -12(%rbp)
+  movl  %esi, -12(%rbp)
+  cmp  %rax, %rbp
+  je  .L_2
+  movl  %esi, -12(%rbp)
+  movl  %esi, -12(%rbp)
+  movl  %edi, -8(%rbp)
+  movl  %esi, -12(%rbp)
+  movl  %esi, -12(%rbp)
+  movl  %esi, -12(%rbp)
+  movl  %esi, -12(%rbp)
+  movl  %esi, -12(%rbp)
+  popq  %rbp
+  popq  %rbp
+  je  .L_2
+  popq  %rbp
+  je  .L_2
+  movl  %eax, -4(%rbp)
+  movl  %esi, -12(%rbp)
+  movl  %edi, -8(%rbp)
+  movl  %esi, -12(%rbp)
+  movl  %esi, -12(%rbp)
+  movl  %esi, -12(%rbp)
+  movl  %esi, -12(%rbp)
+  movl  %esi, -12(%rbp)
+  popq  %rbp
+  popq  %rbp
+  jmp  .L_3
+  jmp  .L_3
+  jmp  .L_3
+  movl  %eax, -4(%rbp)
+  movl  %esi, -12(%rbp)
+  movl  %edi, -8(%rbp)
+  movl  %esi, -12(%rbp)
+  movl  %esi, -12(%rbp)
+  movl  %esi, -12(%rbp)
+  popq  %rbp
+  popq  %rbp
+  cmp  %rax, %rbp
+  je  .L_2
+  jmp  .L_3
+.L_2:
+  movl  -12(%rbp), %eax
+  movl  %eax, -4(%rbp)
+.L_3:
+  movl  %esi, -1200(%rbp)
+  movl  %esi, -1200(%rbp)
+  movl  %esi, -1200(%rbp)
+  movl  %esi, -1200(%rbp)
+  movl  %esi, -1200(%rbp)
+  movl  %esi, -1200(%rbp)
+  movl  %esi, -1200(%rbp)
+  movl  %esi, -1200(%rbp)
+  movl  %esi, -1200(%rbp)
+  movl  %esi, -1200(%rbp)
+  jmp  .L_3
+  popq  %rbp
+  retq
diff --git a/gas/testsuite/gas/i386/x86-64-align-branch-1a.d b/gas/testsuite/gas/i386/x86-64-align-branch-1a.d
new file mode 100644
index 0000000000..f96808ac21
--- /dev/null
+++ b/gas/testsuite/gas/i386/x86-64-align-branch-1a.d
@@ -0,0 +1,75 @@
+#source: x86-64-align-branch-1.s
+#as: -malign-branch-boundary=32
+#objdump: -dw
+
+.*: +file format .*
+
+Disassembly of section .text:
+
+0+ <foo>:
+   0:	64 64 64 64 89 04 25 01 00 00 00 	fs fs fs mov %eax,%fs:0x1
+   b:	55                   	push   %rbp
+   c:	55                   	push   %rbp
+   d:	55                   	push   %rbp
+   e:	48 89 e5             	mov    %rsp,%rbp
+  11:	89 75 f4             	mov    %esi,-0xc\(%rbp\)
+  14:	89 75 f4             	mov    %esi,-0xc\(%rbp\)
+  17:	89 75 f4             	mov    %esi,-0xc\(%rbp\)
+  1a:	89 75 f4             	mov    %esi,-0xc\(%rbp\)
+  1d:	89 75 f4             	mov    %esi,-0xc\(%rbp\)
+  20:	48 39 c5             	cmp    %rax,%rbp
+  23:	74 5d                	je     82 <foo\+0x82>
+  25:	2e 89 75 f4          	mov    %esi,%cs:-0xc\(%rbp\)
+  29:	89 75 f4             	mov    %esi,-0xc\(%rbp\)
+  2c:	89 7d f8             	mov    %edi,-0x8\(%rbp\)
+  2f:	89 75 f4             	mov    %esi,-0xc\(%rbp\)
+  32:	89 75 f4             	mov    %esi,-0xc\(%rbp\)
+  35:	89 75 f4             	mov    %esi,-0xc\(%rbp\)
+  38:	89 75 f4             	mov    %esi,-0xc\(%rbp\)
+  3b:	89 75 f4             	mov    %esi,-0xc\(%rbp\)
+  3e:	5d                   	pop    %rbp
+  3f:	5d                   	pop    %rbp
+  40:	74 40                	je     82 <foo\+0x82>
+  42:	5d                   	pop    %rbp
+  43:	74 3d                	je     82 <foo\+0x82>
+  45:	2e 89 45 fc          	mov    %eax,%cs:-0x4\(%rbp\)
+  49:	89 75 f4             	mov    %esi,-0xc\(%rbp\)
+  4c:	89 7d f8             	mov    %edi,-0x8\(%rbp\)
+  4f:	89 75 f4             	mov    %esi,-0xc\(%rbp\)
+  52:	89 75 f4             	mov    %esi,-0xc\(%rbp\)
+  55:	89 75 f4             	mov    %esi,-0xc\(%rbp\)
+  58:	89 75 f4             	mov    %esi,-0xc\(%rbp\)
+  5b:	89 75 f4             	mov    %esi,-0xc\(%rbp\)
+  5e:	5d                   	pop    %rbp
+  5f:	5d                   	pop    %rbp
+  60:	eb 26                	jmp    88 <foo\+0x88>
+  62:	eb 24                	jmp    88 <foo\+0x88>
+  64:	eb 22                	jmp    88 <foo\+0x88>
+  66:	89 45 fc             	mov    %eax,-0x4\(%rbp\)
+  69:	89 75 f4             	mov    %esi,-0xc\(%rbp\)
+  6c:	89 7d f8             	mov    %edi,-0x8\(%rbp\)
+  6f:	89 75 f4             	mov    %esi,-0xc\(%rbp\)
+  72:	89 75 f4             	mov    %esi,-0xc\(%rbp\)
+  75:	89 75 f4             	mov    %esi,-0xc\(%rbp\)
+  78:	5d                   	pop    %rbp
+  79:	5d                   	pop    %rbp
+  7a:	48 39 c5             	cmp    %rax,%rbp
+  7d:	74 03                	je     82 <foo\+0x82>
+  7f:	90                   	nop
+  80:	eb 06                	jmp    88 <foo\+0x88>
+  82:	8b 45 f4             	mov    -0xc\(%rbp\),%eax
+  85:	89 45 fc             	mov    %eax,-0x4\(%rbp\)
+  88:	89 b5 50 fb ff ff    	mov    %esi,-0x4b0\(%rbp\)
+  8e:	89 b5 50 fb ff ff    	mov    %esi,-0x4b0\(%rbp\)
+  94:	89 b5 50 fb ff ff    	mov    %esi,-0x4b0\(%rbp\)
+  9a:	89 b5 50 fb ff ff    	mov    %esi,-0x4b0\(%rbp\)
+  a0:	89 b5 50 fb ff ff    	mov    %esi,-0x4b0\(%rbp\)
+  a6:	89 b5 50 fb ff ff    	mov    %esi,-0x4b0\(%rbp\)
+  ac:	89 b5 50 fb ff ff    	mov    %esi,-0x4b0\(%rbp\)
+  b2:	89 b5 50 fb ff ff    	mov    %esi,-0x4b0\(%rbp\)
+  b8:	89 b5 50 fb ff ff    	mov    %esi,-0x4b0\(%rbp\)
+  be:	89 b5 50 fb ff ff    	mov    %esi,-0x4b0\(%rbp\)
+  c4:	eb c2                	jmp    88 <foo\+0x88>
+  c6:	5d                   	pop    %rbp
+  c7:	c3                   	retq   
+#pass
diff --git a/gas/testsuite/gas/i386/x86-64-align-branch-1b.d b/gas/testsuite/gas/i386/x86-64-align-branch-1b.d
new file mode 100644
index 0000000000..10b3476796
--- /dev/null
+++ b/gas/testsuite/gas/i386/x86-64-align-branch-1b.d
@@ -0,0 +1,75 @@
+#source: x86-64-align-branch-1.s
+#as: -malign-branch-boundary=32 -malign-branch=fused+jcc+jmp
+#objdump: -dw
+
+.*: +file format .*
+
+Disassembly of section .text:
+
+0+ <foo>:
+   0:	64 64 64 64 89 04 25 01 00 00 00 	fs fs fs mov %eax,%fs:0x1
+   b:	55                   	push   %rbp
+   c:	55                   	push   %rbp
+   d:	55                   	push   %rbp
+   e:	48 89 e5             	mov    %rsp,%rbp
+  11:	89 75 f4             	mov    %esi,-0xc\(%rbp\)
+  14:	89 75 f4             	mov    %esi,-0xc\(%rbp\)
+  17:	89 75 f4             	mov    %esi,-0xc\(%rbp\)
+  1a:	89 75 f4             	mov    %esi,-0xc\(%rbp\)
+  1d:	89 75 f4             	mov    %esi,-0xc\(%rbp\)
+  20:	48 39 c5             	cmp    %rax,%rbp
+  23:	74 5d                	je     82 <foo\+0x82>
+  25:	2e 89 75 f4          	mov    %esi,%cs:-0xc\(%rbp\)
+  29:	89 75 f4             	mov    %esi,-0xc\(%rbp\)
+  2c:	89 7d f8             	mov    %edi,-0x8\(%rbp\)
+  2f:	89 75 f4             	mov    %esi,-0xc\(%rbp\)
+  32:	89 75 f4             	mov    %esi,-0xc\(%rbp\)
+  35:	89 75 f4             	mov    %esi,-0xc\(%rbp\)
+  38:	89 75 f4             	mov    %esi,-0xc\(%rbp\)
+  3b:	89 75 f4             	mov    %esi,-0xc\(%rbp\)
+  3e:	5d                   	pop    %rbp
+  3f:	5d                   	pop    %rbp
+  40:	74 40                	je     82 <foo\+0x82>
+  42:	5d                   	pop    %rbp
+  43:	74 3d                	je     82 <foo\+0x82>
+  45:	2e 89 45 fc          	mov    %eax,%cs:-0x4\(%rbp\)
+  49:	89 75 f4             	mov    %esi,-0xc\(%rbp\)
+  4c:	89 7d f8             	mov    %edi,-0x8\(%rbp\)
+  4f:	89 75 f4             	mov    %esi,-0xc\(%rbp\)
+  52:	89 75 f4             	mov    %esi,-0xc\(%rbp\)
+  55:	89 75 f4             	mov    %esi,-0xc\(%rbp\)
+  58:	89 75 f4             	mov    %esi,-0xc\(%rbp\)
+  5b:	89 75 f4             	mov    %esi,-0xc\(%rbp\)
+  5e:	5d                   	pop    %rbp
+  5f:	5d                   	pop    %rbp
+  60:	eb 26                	jmp    88 <foo\+0x88>
+  62:	eb 24                	jmp    88 <foo\+0x88>
+  64:	eb 22                	jmp    88 <foo\+0x88>
+  66:	89 45 fc             	mov    %eax,-0x4\(%rbp\)
+  69:	89 75 f4             	mov    %esi,-0xc\(%rbp\)
+  6c:	89 7d f8             	mov    %edi,-0x8\(%rbp\)
+  6f:	89 75 f4             	mov    %esi,-0xc\(%rbp\)
+  72:	89 75 f4             	mov    %esi,-0xc\(%rbp\)
+  75:	89 75 f4             	mov    %esi,-0xc\(%rbp\)
+  78:	5d                   	pop    %rbp
+  79:	5d                   	pop    %rbp
+  7a:	48 39 c5             	cmp    %rax,%rbp
+  7d:	74 03                	je     82 <foo\+0x82>
+  7f:	90                   	nop
+  80:	eb 06                	jmp    88 <foo\+0x88>
+  82:	8b 45 f4             	mov    -0xc\(%rbp\),%eax
+  85:	89 45 fc             	mov    %eax,-0x4\(%rbp\)
+  88:	89 b5 50 fb ff ff    	mov    %esi,-0x4b0\(%rbp\)
+  8e:	89 b5 50 fb ff ff    	mov    %esi,-0x4b0\(%rbp\)
+  94:	89 b5 50 fb ff ff    	mov    %esi,-0x4b0\(%rbp\)
+  9a:	89 b5 50 fb ff ff    	mov    %esi,-0x4b0\(%rbp\)
+  a0:	89 b5 50 fb ff ff    	mov    %esi,-0x4b0\(%rbp\)
+  a6:	89 b5 50 fb ff ff    	mov    %esi,-0x4b0\(%rbp\)
+  ac:	89 b5 50 fb ff ff    	mov    %esi,-0x4b0\(%rbp\)
+  b2:	89 b5 50 fb ff ff    	mov    %esi,-0x4b0\(%rbp\)
+  b8:	89 b5 50 fb ff ff    	mov    %esi,-0x4b0\(%rbp\)
+  be:	89 b5 50 fb ff ff    	mov    %esi,-0x4b0\(%rbp\)
+  c4:	eb c2                	jmp    88 <foo\+0x88>
+  c6:	5d                   	pop    %rbp
+  c7:	c3                   	retq   
+#pass
diff --git a/gas/testsuite/gas/i386/x86-64-align-branch-1c.d b/gas/testsuite/gas/i386/x86-64-align-branch-1c.d
new file mode 100644
index 0000000000..53c848aed4
--- /dev/null
+++ b/gas/testsuite/gas/i386/x86-64-align-branch-1c.d
@@ -0,0 +1,75 @@
+#source: x86-64-align-branch-1.s
+#as: -malign-branch-boundary=32 -malign-branch-prefix-size=1
+#objdump: -dw
+
+.*: +file format .*
+
+Disassembly of section .text:
+
+0+ <foo>:
+   0:	64 89 04 25 01 00 00 00 	mov    %eax,%fs:0x1
+   8:	2e 55                	cs push %rbp
+   a:	2e 55                	cs push %rbp
+   c:	2e 55                	cs push %rbp
+   e:	48 89 e5             	mov    %rsp,%rbp
+  11:	89 75 f4             	mov    %esi,-0xc\(%rbp\)
+  14:	89 75 f4             	mov    %esi,-0xc\(%rbp\)
+  17:	89 75 f4             	mov    %esi,-0xc\(%rbp\)
+  1a:	89 75 f4             	mov    %esi,-0xc\(%rbp\)
+  1d:	89 75 f4             	mov    %esi,-0xc\(%rbp\)
+  20:	48 39 c5             	cmp    %rax,%rbp
+  23:	74 5d                	je     82 <foo\+0x82>
+  25:	2e 89 75 f4          	mov    %esi,%cs:-0xc\(%rbp\)
+  29:	89 75 f4             	mov    %esi,-0xc\(%rbp\)
+  2c:	89 7d f8             	mov    %edi,-0x8\(%rbp\)
+  2f:	89 75 f4             	mov    %esi,-0xc\(%rbp\)
+  32:	89 75 f4             	mov    %esi,-0xc\(%rbp\)
+  35:	89 75 f4             	mov    %esi,-0xc\(%rbp\)
+  38:	89 75 f4             	mov    %esi,-0xc\(%rbp\)
+  3b:	89 75 f4             	mov    %esi,-0xc\(%rbp\)
+  3e:	5d                   	pop    %rbp
+  3f:	5d                   	pop    %rbp
+  40:	74 40                	je     82 <foo\+0x82>
+  42:	5d                   	pop    %rbp
+  43:	74 3d                	je     82 <foo\+0x82>
+  45:	2e 89 45 fc          	mov    %eax,%cs:-0x4\(%rbp\)
+  49:	89 75 f4             	mov    %esi,-0xc\(%rbp\)
+  4c:	89 7d f8             	mov    %edi,-0x8\(%rbp\)
+  4f:	89 75 f4             	mov    %esi,-0xc\(%rbp\)
+  52:	89 75 f4             	mov    %esi,-0xc\(%rbp\)
+  55:	89 75 f4             	mov    %esi,-0xc\(%rbp\)
+  58:	89 75 f4             	mov    %esi,-0xc\(%rbp\)
+  5b:	89 75 f4             	mov    %esi,-0xc\(%rbp\)
+  5e:	5d                   	pop    %rbp
+  5f:	5d                   	pop    %rbp
+  60:	eb 26                	jmp    88 <foo\+0x88>
+  62:	eb 24                	jmp    88 <foo\+0x88>
+  64:	eb 22                	jmp    88 <foo\+0x88>
+  66:	89 45 fc             	mov    %eax,-0x4\(%rbp\)
+  69:	89 75 f4             	mov    %esi,-0xc\(%rbp\)
+  6c:	89 7d f8             	mov    %edi,-0x8\(%rbp\)
+  6f:	89 75 f4             	mov    %esi,-0xc\(%rbp\)
+  72:	89 75 f4             	mov    %esi,-0xc\(%rbp\)
+  75:	89 75 f4             	mov    %esi,-0xc\(%rbp\)
+  78:	5d                   	pop    %rbp
+  79:	5d                   	pop    %rbp
+  7a:	48 39 c5             	cmp    %rax,%rbp
+  7d:	74 03                	je     82 <foo\+0x82>
+  7f:	90                   	nop
+  80:	eb 06                	jmp    88 <foo\+0x88>
+  82:	8b 45 f4             	mov    -0xc\(%rbp\),%eax
+  85:	89 45 fc             	mov    %eax,-0x4\(%rbp\)
+  88:	89 b5 50 fb ff ff    	mov    %esi,-0x4b0\(%rbp\)
+  8e:	89 b5 50 fb ff ff    	mov    %esi,-0x4b0\(%rbp\)
+  94:	89 b5 50 fb ff ff    	mov    %esi,-0x4b0\(%rbp\)
+  9a:	89 b5 50 fb ff ff    	mov    %esi,-0x4b0\(%rbp\)
+  a0:	89 b5 50 fb ff ff    	mov    %esi,-0x4b0\(%rbp\)
+  a6:	89 b5 50 fb ff ff    	mov    %esi,-0x4b0\(%rbp\)
+  ac:	89 b5 50 fb ff ff    	mov    %esi,-0x4b0\(%rbp\)
+  b2:	89 b5 50 fb ff ff    	mov    %esi,-0x4b0\(%rbp\)
+  b8:	89 b5 50 fb ff ff    	mov    %esi,-0x4b0\(%rbp\)
+  be:	89 b5 50 fb ff ff    	mov    %esi,-0x4b0\(%rbp\)
+  c4:	eb c2                	jmp    88 <foo\+0x88>
+  c6:	5d                   	pop    %rbp
+  c7:	c3                   	retq   
+#pass
diff --git a/gas/testsuite/gas/i386/x86-64-align-branch-1d.d b/gas/testsuite/gas/i386/x86-64-align-branch-1d.d
new file mode 100644
index 0000000000..ae6445b29e
--- /dev/null
+++ b/gas/testsuite/gas/i386/x86-64-align-branch-1d.d
@@ -0,0 +1,74 @@
+#source: x86-64-align-branch-1.s
+#as: -malign-branch-boundary=32 -malign-branch=fused+jcc
+#objdump: -dw
+
+.*: +file format .*
+
+Disassembly of section .text:
+
+0+ <foo>:
+   0:	64 64 64 64 89 04 25 01 00 00 00 	fs fs fs mov %eax,%fs:0x1
+   b:	55                   	push   %rbp
+   c:	55                   	push   %rbp
+   d:	55                   	push   %rbp
+   e:	48 89 e5             	mov    %rsp,%rbp
+  11:	89 75 f4             	mov    %esi,-0xc\(%rbp\)
+  14:	89 75 f4             	mov    %esi,-0xc\(%rbp\)
+  17:	89 75 f4             	mov    %esi,-0xc\(%rbp\)
+  1a:	89 75 f4             	mov    %esi,-0xc\(%rbp\)
+  1d:	89 75 f4             	mov    %esi,-0xc\(%rbp\)
+  20:	48 39 c5             	cmp    %rax,%rbp
+  23:	74 5b                	je     80 <foo\+0x80>
+  25:	2e 89 75 f4          	mov    %esi,%cs:-0xc\(%rbp\)
+  29:	89 75 f4             	mov    %esi,-0xc\(%rbp\)
+  2c:	89 7d f8             	mov    %edi,-0x8\(%rbp\)
+  2f:	89 75 f4             	mov    %esi,-0xc\(%rbp\)
+  32:	89 75 f4             	mov    %esi,-0xc\(%rbp\)
+  35:	89 75 f4             	mov    %esi,-0xc\(%rbp\)
+  38:	89 75 f4             	mov    %esi,-0xc\(%rbp\)
+  3b:	89 75 f4             	mov    %esi,-0xc\(%rbp\)
+  3e:	5d                   	pop    %rbp
+  3f:	5d                   	pop    %rbp
+  40:	74 3e                	je     80 <foo\+0x80>
+  42:	5d                   	pop    %rbp
+  43:	74 3b                	je     80 <foo\+0x80>
+  45:	89 45 fc             	mov    %eax,-0x4\(%rbp\)
+  48:	89 75 f4             	mov    %esi,-0xc\(%rbp\)
+  4b:	89 7d f8             	mov    %edi,-0x8\(%rbp\)
+  4e:	89 75 f4             	mov    %esi,-0xc\(%rbp\)
+  51:	89 75 f4             	mov    %esi,-0xc\(%rbp\)
+  54:	89 75 f4             	mov    %esi,-0xc\(%rbp\)
+  57:	89 75 f4             	mov    %esi,-0xc\(%rbp\)
+  5a:	89 75 f4             	mov    %esi,-0xc\(%rbp\)
+  5d:	5d                   	pop    %rbp
+  5e:	5d                   	pop    %rbp
+  5f:	eb 25                	jmp    86 <foo\+0x86>
+  61:	eb 23                	jmp    86 <foo\+0x86>
+  63:	eb 21                	jmp    86 <foo\+0x86>
+  65:	89 45 fc             	mov    %eax,-0x4\(%rbp\)
+  68:	89 75 f4             	mov    %esi,-0xc\(%rbp\)
+  6b:	89 7d f8             	mov    %edi,-0x8\(%rbp\)
+  6e:	89 75 f4             	mov    %esi,-0xc\(%rbp\)
+  71:	89 75 f4             	mov    %esi,-0xc\(%rbp\)
+  74:	89 75 f4             	mov    %esi,-0xc\(%rbp\)
+  77:	5d                   	pop    %rbp
+  78:	5d                   	pop    %rbp
+  79:	48 39 c5             	cmp    %rax,%rbp
+  7c:	74 02                	je     80 <foo\+0x80>
+  7e:	eb 06                	jmp    86 <foo\+0x86>
+  80:	8b 45 f4             	mov    -0xc\(%rbp\),%eax
+  83:	89 45 fc             	mov    %eax,-0x4\(%rbp\)
+  86:	89 b5 50 fb ff ff    	mov    %esi,-0x4b0\(%rbp\)
+  8c:	89 b5 50 fb ff ff    	mov    %esi,-0x4b0\(%rbp\)
+  92:	89 b5 50 fb ff ff    	mov    %esi,-0x4b0\(%rbp\)
+  98:	89 b5 50 fb ff ff    	mov    %esi,-0x4b0\(%rbp\)
+  9e:	89 b5 50 fb ff ff    	mov    %esi,-0x4b0\(%rbp\)
+  a4:	89 b5 50 fb ff ff    	mov    %esi,-0x4b0\(%rbp\)
+  aa:	89 b5 50 fb ff ff    	mov    %esi,-0x4b0\(%rbp\)
+  b0:	89 b5 50 fb ff ff    	mov    %esi,-0x4b0\(%rbp\)
+  b6:	89 b5 50 fb ff ff    	mov    %esi,-0x4b0\(%rbp\)
+  bc:	89 b5 50 fb ff ff    	mov    %esi,-0x4b0\(%rbp\)
+  c2:	eb c2                	jmp    86 <foo\+0x86>
+  c4:	5d                   	pop    %rbp
+  c5:	c3                   	retq   
+#pass
diff --git a/gas/testsuite/gas/i386/x86-64-align-branch-1e.d b/gas/testsuite/gas/i386/x86-64-align-branch-1e.d
new file mode 100644
index 0000000000..beb7744f65
--- /dev/null
+++ b/gas/testsuite/gas/i386/x86-64-align-branch-1e.d
@@ -0,0 +1,74 @@
+#source: x86-64-align-branch-1.s
+#as: -malign-branch-boundary=32 -malign-branch=jcc
+#objdump: -dw
+
+.*: +file format .*
+
+Disassembly of section .text:
+
+0+ <foo>:
+   0:	64 89 04 25 01 00 00 00 	mov    %eax,%fs:0x1
+   8:	55                   	push   %rbp
+   9:	55                   	push   %rbp
+   a:	55                   	push   %rbp
+   b:	48 89 e5             	mov    %rsp,%rbp
+   e:	89 75 f4             	mov    %esi,-0xc\(%rbp\)
+  11:	89 75 f4             	mov    %esi,-0xc\(%rbp\)
+  14:	89 75 f4             	mov    %esi,-0xc\(%rbp\)
+  17:	89 75 f4             	mov    %esi,-0xc\(%rbp\)
+  1a:	89 75 f4             	mov    %esi,-0xc\(%rbp\)
+  1d:	48 39 c5             	cmp    %rax,%rbp
+  20:	74 5b                	je     7d <foo\+0x7d>
+  22:	89 75 f4             	mov    %esi,-0xc\(%rbp\)
+  25:	89 75 f4             	mov    %esi,-0xc\(%rbp\)
+  28:	89 7d f8             	mov    %edi,-0x8\(%rbp\)
+  2b:	89 75 f4             	mov    %esi,-0xc\(%rbp\)
+  2e:	89 75 f4             	mov    %esi,-0xc\(%rbp\)
+  31:	89 75 f4             	mov    %esi,-0xc\(%rbp\)
+  34:	89 75 f4             	mov    %esi,-0xc\(%rbp\)
+  37:	89 75 f4             	mov    %esi,-0xc\(%rbp\)
+  3a:	5d                   	pop    %rbp
+  3b:	5d                   	pop    %rbp
+  3c:	74 3f                	je     7d <foo\+0x7d>
+  3e:	2e 5d                	cs pop %rbp
+  40:	74 3b                	je     7d <foo\+0x7d>
+  42:	89 45 fc             	mov    %eax,-0x4\(%rbp\)
+  45:	89 75 f4             	mov    %esi,-0xc\(%rbp\)
+  48:	89 7d f8             	mov    %edi,-0x8\(%rbp\)
+  4b:	89 75 f4             	mov    %esi,-0xc\(%rbp\)
+  4e:	89 75 f4             	mov    %esi,-0xc\(%rbp\)
+  51:	89 75 f4             	mov    %esi,-0xc\(%rbp\)
+  54:	89 75 f4             	mov    %esi,-0xc\(%rbp\)
+  57:	89 75 f4             	mov    %esi,-0xc\(%rbp\)
+  5a:	5d                   	pop    %rbp
+  5b:	5d                   	pop    %rbp
+  5c:	eb 25                	jmp    83 <foo\+0x83>
+  5e:	eb 23                	jmp    83 <foo\+0x83>
+  60:	eb 21                	jmp    83 <foo\+0x83>
+  62:	89 45 fc             	mov    %eax,-0x4\(%rbp\)
+  65:	89 75 f4             	mov    %esi,-0xc\(%rbp\)
+  68:	89 7d f8             	mov    %edi,-0x8\(%rbp\)
+  6b:	89 75 f4             	mov    %esi,-0xc\(%rbp\)
+  6e:	89 75 f4             	mov    %esi,-0xc\(%rbp\)
+  71:	89 75 f4             	mov    %esi,-0xc\(%rbp\)
+  74:	5d                   	pop    %rbp
+  75:	5d                   	pop    %rbp
+  76:	48 39 c5             	cmp    %rax,%rbp
+  79:	74 02                	je     7d <foo\+0x7d>
+  7b:	eb 06                	jmp    83 <foo\+0x83>
+  7d:	8b 45 f4             	mov    -0xc\(%rbp\),%eax
+  80:	89 45 fc             	mov    %eax,-0x4\(%rbp\)
+  83:	89 b5 50 fb ff ff    	mov    %esi,-0x4b0\(%rbp\)
+  89:	89 b5 50 fb ff ff    	mov    %esi,-0x4b0\(%rbp\)
+  8f:	89 b5 50 fb ff ff    	mov    %esi,-0x4b0\(%rbp\)
+  95:	89 b5 50 fb ff ff    	mov    %esi,-0x4b0\(%rbp\)
+  9b:	89 b5 50 fb ff ff    	mov    %esi,-0x4b0\(%rbp\)
+  a1:	89 b5 50 fb ff ff    	mov    %esi,-0x4b0\(%rbp\)
+  a7:	89 b5 50 fb ff ff    	mov    %esi,-0x4b0\(%rbp\)
+  ad:	89 b5 50 fb ff ff    	mov    %esi,-0x4b0\(%rbp\)
+  b3:	89 b5 50 fb ff ff    	mov    %esi,-0x4b0\(%rbp\)
+  b9:	89 b5 50 fb ff ff    	mov    %esi,-0x4b0\(%rbp\)
+  bf:	eb c2                	jmp    83 <foo\+0x83>
+  c1:	5d                   	pop    %rbp
+  c2:	c3                   	retq   
+#pass
diff --git a/gas/testsuite/gas/i386/x86-64-align-branch-1f.d b/gas/testsuite/gas/i386/x86-64-align-branch-1f.d
new file mode 100644
index 0000000000..24fbf45eec
--- /dev/null
+++ b/gas/testsuite/gas/i386/x86-64-align-branch-1f.d
@@ -0,0 +1,75 @@
+#source: x86-64-align-branch-1.s
+#as: -malign-branch-boundary=32 -malign-branch=jcc+jmp
+#objdump: -dw
+
+.*: +file format .*
+
+Disassembly of section .text:
+
+0+ <foo>:
+   0:	64 89 04 25 01 00 00 00 	mov    %eax,%fs:0x1
+   8:	55                   	push   %rbp
+   9:	55                   	push   %rbp
+   a:	55                   	push   %rbp
+   b:	48 89 e5             	mov    %rsp,%rbp
+   e:	89 75 f4             	mov    %esi,-0xc\(%rbp\)
+  11:	89 75 f4             	mov    %esi,-0xc\(%rbp\)
+  14:	89 75 f4             	mov    %esi,-0xc\(%rbp\)
+  17:	89 75 f4             	mov    %esi,-0xc\(%rbp\)
+  1a:	89 75 f4             	mov    %esi,-0xc\(%rbp\)
+  1d:	48 39 c5             	cmp    %rax,%rbp
+  20:	74 5d                	je     7f <foo\+0x7f>
+  22:	89 75 f4             	mov    %esi,-0xc\(%rbp\)
+  25:	89 75 f4             	mov    %esi,-0xc\(%rbp\)
+  28:	89 7d f8             	mov    %edi,-0x8\(%rbp\)
+  2b:	89 75 f4             	mov    %esi,-0xc\(%rbp\)
+  2e:	89 75 f4             	mov    %esi,-0xc\(%rbp\)
+  31:	89 75 f4             	mov    %esi,-0xc\(%rbp\)
+  34:	89 75 f4             	mov    %esi,-0xc\(%rbp\)
+  37:	89 75 f4             	mov    %esi,-0xc\(%rbp\)
+  3a:	5d                   	pop    %rbp
+  3b:	5d                   	pop    %rbp
+  3c:	74 41                	je     7f <foo\+0x7f>
+  3e:	2e 5d                	cs pop %rbp
+  40:	74 3d                	je     7f <foo\+0x7f>
+  42:	89 45 fc             	mov    %eax,-0x4\(%rbp\)
+  45:	89 75 f4             	mov    %esi,-0xc\(%rbp\)
+  48:	89 7d f8             	mov    %edi,-0x8\(%rbp\)
+  4b:	89 75 f4             	mov    %esi,-0xc\(%rbp\)
+  4e:	89 75 f4             	mov    %esi,-0xc\(%rbp\)
+  51:	89 75 f4             	mov    %esi,-0xc\(%rbp\)
+  54:	89 75 f4             	mov    %esi,-0xc\(%rbp\)
+  57:	89 75 f4             	mov    %esi,-0xc\(%rbp\)
+  5a:	5d                   	pop    %rbp
+  5b:	5d                   	pop    %rbp
+  5c:	eb 27                	jmp    85 <foo\+0x85>
+  5e:	66 90                	xchg   %ax,%ax
+  60:	eb 23                	jmp    85 <foo\+0x85>
+  62:	eb 21                	jmp    85 <foo\+0x85>
+  64:	89 45 fc             	mov    %eax,-0x4\(%rbp\)
+  67:	89 75 f4             	mov    %esi,-0xc\(%rbp\)
+  6a:	89 7d f8             	mov    %edi,-0x8\(%rbp\)
+  6d:	89 75 f4             	mov    %esi,-0xc\(%rbp\)
+  70:	89 75 f4             	mov    %esi,-0xc\(%rbp\)
+  73:	89 75 f4             	mov    %esi,-0xc\(%rbp\)
+  76:	5d                   	pop    %rbp
+  77:	5d                   	pop    %rbp
+  78:	48 39 c5             	cmp    %rax,%rbp
+  7b:	74 02                	je     7f <foo\+0x7f>
+  7d:	eb 06                	jmp    85 <foo\+0x85>
+  7f:	8b 45 f4             	mov    -0xc\(%rbp\),%eax
+  82:	89 45 fc             	mov    %eax,-0x4\(%rbp\)
+  85:	89 b5 50 fb ff ff    	mov    %esi,-0x4b0\(%rbp\)
+  8b:	89 b5 50 fb ff ff    	mov    %esi,-0x4b0\(%rbp\)
+  91:	89 b5 50 fb ff ff    	mov    %esi,-0x4b0\(%rbp\)
+  97:	89 b5 50 fb ff ff    	mov    %esi,-0x4b0\(%rbp\)
+  9d:	89 b5 50 fb ff ff    	mov    %esi,-0x4b0\(%rbp\)
+  a3:	89 b5 50 fb ff ff    	mov    %esi,-0x4b0\(%rbp\)
+  a9:	89 b5 50 fb ff ff    	mov    %esi,-0x4b0\(%rbp\)
+  af:	89 b5 50 fb ff ff    	mov    %esi,-0x4b0\(%rbp\)
+  b5:	89 b5 50 fb ff ff    	mov    %esi,-0x4b0\(%rbp\)
+  bb:	89 b5 50 fb ff ff    	mov    %esi,-0x4b0\(%rbp\)
+  c1:	eb c2                	jmp    85 <foo\+0x85>
+  c3:	5d                   	pop    %rbp
+  c4:	c3                   	retq   
+#pass
diff --git a/gas/testsuite/gas/i386/x86-64-align-branch-1g.d b/gas/testsuite/gas/i386/x86-64-align-branch-1g.d
new file mode 100644
index 0000000000..624494064b
--- /dev/null
+++ b/gas/testsuite/gas/i386/x86-64-align-branch-1g.d
@@ -0,0 +1,75 @@
+#source: x86-64-align-branch-1.s
+#as: -mbranches-within-32B-boundaries
+#objdump: -dw
+
+.*: +file format .*
+
+Disassembly of section .text:
+
+0+ <foo>:
+   0:	64 64 64 64 89 04 25 01 00 00 00 	fs fs fs mov %eax,%fs:0x1
+   b:	55                   	push   %rbp
+   c:	55                   	push   %rbp
+   d:	55                   	push   %rbp
+   e:	48 89 e5             	mov    %rsp,%rbp
+  11:	89 75 f4             	mov    %esi,-0xc\(%rbp\)
+  14:	89 75 f4             	mov    %esi,-0xc\(%rbp\)
+  17:	89 75 f4             	mov    %esi,-0xc\(%rbp\)
+  1a:	89 75 f4             	mov    %esi,-0xc\(%rbp\)
+  1d:	89 75 f4             	mov    %esi,-0xc\(%rbp\)
+  20:	48 39 c5             	cmp    %rax,%rbp
+  23:	74 5d                	je     82 <foo\+0x82>
+  25:	2e 89 75 f4          	mov    %esi,%cs:-0xc\(%rbp\)
+  29:	89 75 f4             	mov    %esi,-0xc\(%rbp\)
+  2c:	89 7d f8             	mov    %edi,-0x8\(%rbp\)
+  2f:	89 75 f4             	mov    %esi,-0xc\(%rbp\)
+  32:	89 75 f4             	mov    %esi,-0xc\(%rbp\)
+  35:	89 75 f4             	mov    %esi,-0xc\(%rbp\)
+  38:	89 75 f4             	mov    %esi,-0xc\(%rbp\)
+  3b:	89 75 f4             	mov    %esi,-0xc\(%rbp\)
+  3e:	5d                   	pop    %rbp
+  3f:	5d                   	pop    %rbp
+  40:	74 40                	je     82 <foo\+0x82>
+  42:	5d                   	pop    %rbp
+  43:	74 3d                	je     82 <foo\+0x82>
+  45:	2e 89 45 fc          	mov    %eax,%cs:-0x4\(%rbp\)
+  49:	89 75 f4             	mov    %esi,-0xc\(%rbp\)
+  4c:	89 7d f8             	mov    %edi,-0x8\(%rbp\)
+  4f:	89 75 f4             	mov    %esi,-0xc\(%rbp\)
+  52:	89 75 f4             	mov    %esi,-0xc\(%rbp\)
+  55:	89 75 f4             	mov    %esi,-0xc\(%rbp\)
+  58:	89 75 f4             	mov    %esi,-0xc\(%rbp\)
+  5b:	89 75 f4             	mov    %esi,-0xc\(%rbp\)
+  5e:	5d                   	pop    %rbp
+  5f:	5d                   	pop    %rbp
+  60:	eb 26                	jmp    88 <foo\+0x88>
+  62:	eb 24                	jmp    88 <foo\+0x88>
+  64:	eb 22                	jmp    88 <foo\+0x88>
+  66:	89 45 fc             	mov    %eax,-0x4\(%rbp\)
+  69:	89 75 f4             	mov    %esi,-0xc\(%rbp\)
+  6c:	89 7d f8             	mov    %edi,-0x8\(%rbp\)
+  6f:	89 75 f4             	mov    %esi,-0xc\(%rbp\)
+  72:	89 75 f4             	mov    %esi,-0xc\(%rbp\)
+  75:	89 75 f4             	mov    %esi,-0xc\(%rbp\)
+  78:	5d                   	pop    %rbp
+  79:	5d                   	pop    %rbp
+  7a:	48 39 c5             	cmp    %rax,%rbp
+  7d:	74 03                	je     82 <foo\+0x82>
+  7f:	90                   	nop
+  80:	eb 06                	jmp    88 <foo\+0x88>
+  82:	8b 45 f4             	mov    -0xc\(%rbp\),%eax
+  85:	89 45 fc             	mov    %eax,-0x4\(%rbp\)
+  88:	89 b5 50 fb ff ff    	mov    %esi,-0x4b0\(%rbp\)
+  8e:	89 b5 50 fb ff ff    	mov    %esi,-0x4b0\(%rbp\)
+  94:	89 b5 50 fb ff ff    	mov    %esi,-0x4b0\(%rbp\)
+  9a:	89 b5 50 fb ff ff    	mov    %esi,-0x4b0\(%rbp\)
+  a0:	89 b5 50 fb ff ff    	mov    %esi,-0x4b0\(%rbp\)
+  a6:	89 b5 50 fb ff ff    	mov    %esi,-0x4b0\(%rbp\)
+  ac:	89 b5 50 fb ff ff    	mov    %esi,-0x4b0\(%rbp\)
+  b2:	89 b5 50 fb ff ff    	mov    %esi,-0x4b0\(%rbp\)
+  b8:	89 b5 50 fb ff ff    	mov    %esi,-0x4b0\(%rbp\)
+  be:	89 b5 50 fb ff ff    	mov    %esi,-0x4b0\(%rbp\)
+  c4:	eb c2                	jmp    88 <foo\+0x88>
+  c6:	5d                   	pop    %rbp
+  c7:	c3                   	retq   
+#pass
diff --git a/gas/testsuite/gas/i386/x86-64-align-branch-1h.d b/gas/testsuite/gas/i386/x86-64-align-branch-1h.d
new file mode 100644
index 0000000000..a6022be821
--- /dev/null
+++ b/gas/testsuite/gas/i386/x86-64-align-branch-1h.d
@@ -0,0 +1,74 @@
+#source: x86-64-align-branch-1.s
+#as: -mbranches-within-32B-boundaries -malign-branch-boundary=0
+#objdump: -dw
+
+.*: +file format .*
+
+Disassembly of section .text:
+
+0+ <foo>:
+   0:	64 89 04 25 01 00 00 00 	mov    %eax,%fs:0x1
+   8:	55                   	push   %rbp
+   9:	55                   	push   %rbp
+   a:	55                   	push   %rbp
+   b:	48 89 e5             	mov    %rsp,%rbp
+   e:	89 75 f4             	mov    %esi,-0xc\(%rbp\)
+  11:	89 75 f4             	mov    %esi,-0xc\(%rbp\)
+  14:	89 75 f4             	mov    %esi,-0xc\(%rbp\)
+  17:	89 75 f4             	mov    %esi,-0xc\(%rbp\)
+  1a:	89 75 f4             	mov    %esi,-0xc\(%rbp\)
+  1d:	48 39 c5             	cmp    %rax,%rbp
+  20:	74 5a                	je     7c <foo\+0x7c>
+  22:	89 75 f4             	mov    %esi,-0xc\(%rbp\)
+  25:	89 75 f4             	mov    %esi,-0xc\(%rbp\)
+  28:	89 7d f8             	mov    %edi,-0x8\(%rbp\)
+  2b:	89 75 f4             	mov    %esi,-0xc\(%rbp\)
+  2e:	89 75 f4             	mov    %esi,-0xc\(%rbp\)
+  31:	89 75 f4             	mov    %esi,-0xc\(%rbp\)
+  34:	89 75 f4             	mov    %esi,-0xc\(%rbp\)
+  37:	89 75 f4             	mov    %esi,-0xc\(%rbp\)
+  3a:	5d                   	pop    %rbp
+  3b:	5d                   	pop    %rbp
+  3c:	74 3e                	je     7c <foo\+0x7c>
+  3e:	5d                   	pop    %rbp
+  3f:	74 3b                	je     7c <foo\+0x7c>
+  41:	89 45 fc             	mov    %eax,-0x4\(%rbp\)
+  44:	89 75 f4             	mov    %esi,-0xc\(%rbp\)
+  47:	89 7d f8             	mov    %edi,-0x8\(%rbp\)
+  4a:	89 75 f4             	mov    %esi,-0xc\(%rbp\)
+  4d:	89 75 f4             	mov    %esi,-0xc\(%rbp\)
+  50:	89 75 f4             	mov    %esi,-0xc\(%rbp\)
+  53:	89 75 f4             	mov    %esi,-0xc\(%rbp\)
+  56:	89 75 f4             	mov    %esi,-0xc\(%rbp\)
+  59:	5d                   	pop    %rbp
+  5a:	5d                   	pop    %rbp
+  5b:	eb 25                	jmp    82 <foo\+0x82>
+  5d:	eb 23                	jmp    82 <foo\+0x82>
+  5f:	eb 21                	jmp    82 <foo\+0x82>
+  61:	89 45 fc             	mov    %eax,-0x4\(%rbp\)
+  64:	89 75 f4             	mov    %esi,-0xc\(%rbp\)
+  67:	89 7d f8             	mov    %edi,-0x8\(%rbp\)
+  6a:	89 75 f4             	mov    %esi,-0xc\(%rbp\)
+  6d:	89 75 f4             	mov    %esi,-0xc\(%rbp\)
+  70:	89 75 f4             	mov    %esi,-0xc\(%rbp\)
+  73:	5d                   	pop    %rbp
+  74:	5d                   	pop    %rbp
+  75:	48 39 c5             	cmp    %rax,%rbp
+  78:	74 02                	je     7c <foo\+0x7c>
+  7a:	eb 06                	jmp    82 <foo\+0x82>
+  7c:	8b 45 f4             	mov    -0xc\(%rbp\),%eax
+  7f:	89 45 fc             	mov    %eax,-0x4\(%rbp\)
+  82:	89 b5 50 fb ff ff    	mov    %esi,-0x4b0\(%rbp\)
+  88:	89 b5 50 fb ff ff    	mov    %esi,-0x4b0\(%rbp\)
+  8e:	89 b5 50 fb ff ff    	mov    %esi,-0x4b0\(%rbp\)
+  94:	89 b5 50 fb ff ff    	mov    %esi,-0x4b0\(%rbp\)
+  9a:	89 b5 50 fb ff ff    	mov    %esi,-0x4b0\(%rbp\)
+  a0:	89 b5 50 fb ff ff    	mov    %esi,-0x4b0\(%rbp\)
+  a6:	89 b5 50 fb ff ff    	mov    %esi,-0x4b0\(%rbp\)
+  ac:	89 b5 50 fb ff ff    	mov    %esi,-0x4b0\(%rbp\)
+  b2:	89 b5 50 fb ff ff    	mov    %esi,-0x4b0\(%rbp\)
+  b8:	89 b5 50 fb ff ff    	mov    %esi,-0x4b0\(%rbp\)
+  be:	eb c2                	jmp    82 <foo\+0x82>
+  c0:	5d                   	pop    %rbp
+  c1:	c3                   	retq   
+#pass
diff --git a/gas/testsuite/gas/i386/x86-64-align-branch-1i.d b/gas/testsuite/gas/i386/x86-64-align-branch-1i.d
new file mode 100644
index 0000000000..2493626fde
--- /dev/null
+++ b/gas/testsuite/gas/i386/x86-64-align-branch-1i.d
@@ -0,0 +1,78 @@
+#source: x86-64-align-branch-1.s
+#as: -malign-branch-boundary=32 -malign-branch-prefix-size=0
+#objdump: -dw
+
+.*: +file format .*
+
+Disassembly of section .text:
+
+0+ <foo>:
+   0:	64 89 04 25 01 00 00 00 	mov    %eax,%fs:0x1
+   8:	55                   	push   %rbp
+   9:	55                   	push   %rbp
+   a:	55                   	push   %rbp
+   b:	48 89 e5             	mov    %rsp,%rbp
+   e:	89 75 f4             	mov    %esi,-0xc\(%rbp\)
+  11:	89 75 f4             	mov    %esi,-0xc\(%rbp\)
+  14:	89 75 f4             	mov    %esi,-0xc\(%rbp\)
+  17:	89 75 f4             	mov    %esi,-0xc\(%rbp\)
+  1a:	89 75 f4             	mov    %esi,-0xc\(%rbp\)
+  1d:	0f 1f 00             	nopl   \(%rax\)
+  20:	48 39 c5             	cmp    %rax,%rbp
+  23:	74 5d                	je     82 <foo\+0x82>
+  25:	89 75 f4             	mov    %esi,-0xc\(%rbp\)
+  28:	89 75 f4             	mov    %esi,-0xc\(%rbp\)
+  2b:	89 7d f8             	mov    %edi,-0x8\(%rbp\)
+  2e:	89 75 f4             	mov    %esi,-0xc\(%rbp\)
+  31:	89 75 f4             	mov    %esi,-0xc\(%rbp\)
+  34:	89 75 f4             	mov    %esi,-0xc\(%rbp\)
+  37:	89 75 f4             	mov    %esi,-0xc\(%rbp\)
+  3a:	89 75 f4             	mov    %esi,-0xc\(%rbp\)
+  3d:	5d                   	pop    %rbp
+  3e:	5d                   	pop    %rbp
+  3f:	90                   	nop
+  40:	74 40                	je     82 <foo\+0x82>
+  42:	5d                   	pop    %rbp
+  43:	74 3d                	je     82 <foo\+0x82>
+  45:	89 45 fc             	mov    %eax,-0x4\(%rbp\)
+  48:	89 75 f4             	mov    %esi,-0xc\(%rbp\)
+  4b:	89 7d f8             	mov    %edi,-0x8\(%rbp\)
+  4e:	89 75 f4             	mov    %esi,-0xc\(%rbp\)
+  51:	89 75 f4             	mov    %esi,-0xc\(%rbp\)
+  54:	89 75 f4             	mov    %esi,-0xc\(%rbp\)
+  57:	89 75 f4             	mov    %esi,-0xc\(%rbp\)
+  5a:	89 75 f4             	mov    %esi,-0xc\(%rbp\)
+  5d:	5d                   	pop    %rbp
+  5e:	5d                   	pop    %rbp
+  5f:	90                   	nop
+  60:	eb 26                	jmp    88 <foo\+0x88>
+  62:	eb 24                	jmp    88 <foo\+0x88>
+  64:	eb 22                	jmp    88 <foo\+0x88>
+  66:	89 45 fc             	mov    %eax,-0x4\(%rbp\)
+  69:	89 75 f4             	mov    %esi,-0xc\(%rbp\)
+  6c:	89 7d f8             	mov    %edi,-0x8\(%rbp\)
+  6f:	89 75 f4             	mov    %esi,-0xc\(%rbp\)
+  72:	89 75 f4             	mov    %esi,-0xc\(%rbp\)
+  75:	89 75 f4             	mov    %esi,-0xc\(%rbp\)
+  78:	5d                   	pop    %rbp
+  79:	5d                   	pop    %rbp
+  7a:	48 39 c5             	cmp    %rax,%rbp
+  7d:	74 03                	je     82 <foo\+0x82>
+  7f:	90                   	nop
+  80:	eb 06                	jmp    88 <foo\+0x88>
+  82:	8b 45 f4             	mov    -0xc\(%rbp\),%eax
+  85:	89 45 fc             	mov    %eax,-0x4\(%rbp\)
+  88:	89 b5 50 fb ff ff    	mov    %esi,-0x4b0\(%rbp\)
+  8e:	89 b5 50 fb ff ff    	mov    %esi,-0x4b0\(%rbp\)
+  94:	89 b5 50 fb ff ff    	mov    %esi,-0x4b0\(%rbp\)
+  9a:	89 b5 50 fb ff ff    	mov    %esi,-0x4b0\(%rbp\)
+  a0:	89 b5 50 fb ff ff    	mov    %esi,-0x4b0\(%rbp\)
+  a6:	89 b5 50 fb ff ff    	mov    %esi,-0x4b0\(%rbp\)
+  ac:	89 b5 50 fb ff ff    	mov    %esi,-0x4b0\(%rbp\)
+  b2:	89 b5 50 fb ff ff    	mov    %esi,-0x4b0\(%rbp\)
+  b8:	89 b5 50 fb ff ff    	mov    %esi,-0x4b0\(%rbp\)
+  be:	89 b5 50 fb ff ff    	mov    %esi,-0x4b0\(%rbp\)
+  c4:	eb c2                	jmp    88 <foo\+0x88>
+  c6:	5d                   	pop    %rbp
+  c7:	c3                   	retq   
+#pass
diff --git a/gas/testsuite/gas/i386/x86-64-align-branch-2.s b/gas/testsuite/gas/i386/x86-64-align-branch-2.s
new file mode 100644
index 0000000000..54999f85b0
--- /dev/null
+++ b/gas/testsuite/gas/i386/x86-64-align-branch-2.s
@@ -0,0 +1,44 @@
+  .text
+  .globl  foo
+  .p2align  4
+foo:
+  movl  %eax, %fs:0x1
+  pushq  %rbp
+  pushq  %rbp
+  pushq  %rbp
+  pushq  %rbp
+  movq  %rsp, %rbp
+  movl  %esi, -12(%rbp)
+  movl  %esi, -12(%rbp)
+  movl  %esi, -12(%rbp)
+  movl  %esi, -12(%rbp)
+  movl  %esi, -12(%rbp)
+  jmp  *%rax
+  pushq  %rbp
+  pushq  %rbp
+  movl  %eax, %fs:0x1
+  movq  %rsp, %rbp
+  movl  %esi, -12(%rbp)
+  movl  %esi, -12(%rbp)
+  movl  %esi, -12(%rbp)
+  movl  %esi, -12(%rbp)
+  movl  %esi, -12(%rbp)
+  call *%rax
+  movl  %esi, -12(%rbp)
+  pushq  %rbp
+  pushq  %rbp
+  movl  %eax, %fs:0x1
+  movq  %rsp, %rbp
+  movl  %esi, -12(%rbp)
+  movl  %esi, -12(%rbp)
+  movl  %esi, -12(%rbp)
+  call  foo
+  movl  %esi, -12(%rbp)
+  pushq  %rbp
+  pushq  %rbp
+  pushq  %rbp
+  movl  %eax, %fs:0x1
+  movq  %rsp, %rbp
+  movl  %esi, -12(%rbp)
+  call  *foo
+  pushq  %rbp
diff --git a/gas/testsuite/gas/i386/x86-64-align-branch-2a.d b/gas/testsuite/gas/i386/x86-64-align-branch-2a.d
new file mode 100644
index 0000000000..aaf759d42e
--- /dev/null
+++ b/gas/testsuite/gas/i386/x86-64-align-branch-2a.d
@@ -0,0 +1,50 @@
+#source: x86-64-align-branch-2.s
+#as: -malign-branch-boundary=32 -malign-branch=fused+jcc+jmp
+#objdump: -dw
+
+.*: +file format .*
+
+Disassembly of section .text:
+
+0+ <foo>:
+   0:	64 89 04 25 01 00 00 00 	mov    %eax,%fs:0x1
+   8:	55                   	push   %rbp
+   9:	55                   	push   %rbp
+   a:	55                   	push   %rbp
+   b:	55                   	push   %rbp
+   c:	48 89 e5             	mov    %rsp,%rbp
+   f:	89 75 f4             	mov    %esi,-0xc\(%rbp\)
+  12:	89 75 f4             	mov    %esi,-0xc\(%rbp\)
+  15:	89 75 f4             	mov    %esi,-0xc\(%rbp\)
+  18:	89 75 f4             	mov    %esi,-0xc\(%rbp\)
+  1b:	89 75 f4             	mov    %esi,-0xc\(%rbp\)
+  1e:	ff e0                	jmpq   \*%rax
+  20:	55                   	push   %rbp
+  21:	55                   	push   %rbp
+  22:	64 89 04 25 01 00 00 00 	mov    %eax,%fs:0x1
+  2a:	48 89 e5             	mov    %rsp,%rbp
+  2d:	89 75 f4             	mov    %esi,-0xc\(%rbp\)
+  30:	89 75 f4             	mov    %esi,-0xc\(%rbp\)
+  33:	89 75 f4             	mov    %esi,-0xc\(%rbp\)
+  36:	89 75 f4             	mov    %esi,-0xc\(%rbp\)
+  39:	89 75 f4             	mov    %esi,-0xc\(%rbp\)
+  3c:	ff d0                	callq  \*%rax
+  3e:	89 75 f4             	mov    %esi,-0xc\(%rbp\)
+  41:	55                   	push   %rbp
+  42:	55                   	push   %rbp
+  43:	64 89 04 25 01 00 00 00 	mov    %eax,%fs:0x1
+  4b:	48 89 e5             	mov    %rsp,%rbp
+  4e:	89 75 f4             	mov    %esi,-0xc\(%rbp\)
+  51:	89 75 f4             	mov    %esi,-0xc\(%rbp\)
+  54:	89 75 f4             	mov    %esi,-0xc\(%rbp\)
+  57:	e8 [0-9a-f ]+       	callq  .*
+  5c:	89 75 f4             	mov    %esi,-0xc\(%rbp\)
+  5f:	55                   	push   %rbp
+  60:	55                   	push   %rbp
+  61:	55                   	push   %rbp
+  62:	64 89 04 25 01 00 00 00 	mov    %eax,%fs:0x1
+  6a:	48 89 e5             	mov    %rsp,%rbp
+  6d:	89 75 f4             	mov    %esi,-0xc\(%rbp\)
+  70:	ff 14 25 00 00 00 00 	callq  \*0x0
+  77:	55                   	push   %rbp
+#pass
diff --git a/gas/testsuite/gas/i386/x86-64-align-branch-2b.d b/gas/testsuite/gas/i386/x86-64-align-branch-2b.d
new file mode 100644
index 0000000000..720868e363
--- /dev/null
+++ b/gas/testsuite/gas/i386/x86-64-align-branch-2b.d
@@ -0,0 +1,50 @@
+#source: x86-64-align-branch-2.s
+#as: -malign-branch-boundary=32 -malign-branch=indirect
+#objdump: -dw
+
+.*: +file format .*
+
+Disassembly of section .text:
+
+0+ <foo>:
+   0:	64 64 64 89 04 25 01 00 00 00 	fs fs mov %eax,%fs:0x1
+   a:	55                   	push   %rbp
+   b:	55                   	push   %rbp
+   c:	55                   	push   %rbp
+   d:	55                   	push   %rbp
+   e:	48 89 e5             	mov    %rsp,%rbp
+  11:	89 75 f4             	mov    %esi,-0xc\(%rbp\)
+  14:	89 75 f4             	mov    %esi,-0xc\(%rbp\)
+  17:	89 75 f4             	mov    %esi,-0xc\(%rbp\)
+  1a:	89 75 f4             	mov    %esi,-0xc\(%rbp\)
+  1d:	89 75 f4             	mov    %esi,-0xc\(%rbp\)
+  20:	ff e0                	jmpq   \*%rax
+  22:	2e 2e 55             	cs cs push %rbp
+  25:	55                   	push   %rbp
+  26:	64 89 04 25 01 00 00 00 	mov    %eax,%fs:0x1
+  2e:	48 89 e5             	mov    %rsp,%rbp
+  31:	89 75 f4             	mov    %esi,-0xc\(%rbp\)
+  34:	89 75 f4             	mov    %esi,-0xc\(%rbp\)
+  37:	89 75 f4             	mov    %esi,-0xc\(%rbp\)
+  3a:	89 75 f4             	mov    %esi,-0xc\(%rbp\)
+  3d:	89 75 f4             	mov    %esi,-0xc\(%rbp\)
+  40:	ff d0                	callq  \*%rax
+  42:	89 75 f4             	mov    %esi,-0xc\(%rbp\)
+  45:	55                   	push   %rbp
+  46:	55                   	push   %rbp
+  47:	64 89 04 25 01 00 00 00 	mov    %eax,%fs:0x1
+  4f:	48 89 e5             	mov    %rsp,%rbp
+  52:	89 75 f4             	mov    %esi,-0xc\(%rbp\)
+  55:	89 75 f4             	mov    %esi,-0xc\(%rbp\)
+  58:	89 75 f4             	mov    %esi,-0xc\(%rbp\)
+  5b:	e8 [0-9a-f ]+       	callq  .*
+  60:	89 75 f4             	mov    %esi,-0xc\(%rbp\)
+  63:	55                   	push   %rbp
+  64:	55                   	push   %rbp
+  65:	55                   	push   %rbp
+  66:	64 89 04 25 01 00 00 00 	mov    %eax,%fs:0x1
+  6e:	48 89 e5             	mov    %rsp,%rbp
+  71:	89 75 f4             	mov    %esi,-0xc\(%rbp\)
+  74:	ff 14 25 00 00 00 00 	callq  \*0x0
+  7b:	55                   	push   %rbp
+#pass
diff --git a/gas/testsuite/gas/i386/x86-64-align-branch-2c.d b/gas/testsuite/gas/i386/x86-64-align-branch-2c.d
new file mode 100644
index 0000000000..fb87c49cd5
--- /dev/null
+++ b/gas/testsuite/gas/i386/x86-64-align-branch-2c.d
@@ -0,0 +1,50 @@
+#source: x86-64-align-branch-2.s
+#as: -malign-branch-boundary=32 -malign-branch=indirect+call
+#objdump: -dw
+
+.*: +file format .*
+
+Disassembly of section .text:
+
+0+ <foo>:
+   0:	64 64 64 89 04 25 01 00 00 00 	fs fs mov %eax,%fs:0x1
+   a:	55                   	push   %rbp
+   b:	55                   	push   %rbp
+   c:	55                   	push   %rbp
+   d:	55                   	push   %rbp
+   e:	48 89 e5             	mov    %rsp,%rbp
+  11:	89 75 f4             	mov    %esi,-0xc\(%rbp\)
+  14:	89 75 f4             	mov    %esi,-0xc\(%rbp\)
+  17:	89 75 f4             	mov    %esi,-0xc\(%rbp\)
+  1a:	89 75 f4             	mov    %esi,-0xc\(%rbp\)
+  1d:	89 75 f4             	mov    %esi,-0xc\(%rbp\)
+  20:	ff e0                	jmpq   \*%rax
+  22:	2e 2e 55             	cs cs push %rbp
+  25:	55                   	push   %rbp
+  26:	64 89 04 25 01 00 00 00 	mov    %eax,%fs:0x1
+  2e:	48 89 e5             	mov    %rsp,%rbp
+  31:	89 75 f4             	mov    %esi,-0xc\(%rbp\)
+  34:	89 75 f4             	mov    %esi,-0xc\(%rbp\)
+  37:	89 75 f4             	mov    %esi,-0xc\(%rbp\)
+  3a:	89 75 f4             	mov    %esi,-0xc\(%rbp\)
+  3d:	89 75 f4             	mov    %esi,-0xc\(%rbp\)
+  40:	ff d0                	callq  \*%rax
+  42:	2e 2e 2e 2e 2e 89 75 f4 	cs cs cs cs mov %esi,%cs:-0xc\(%rbp\)
+  4a:	55                   	push   %rbp
+  4b:	55                   	push   %rbp
+  4c:	64 89 04 25 01 00 00 00 	mov    %eax,%fs:0x1
+  54:	48 89 e5             	mov    %rsp,%rbp
+  57:	89 75 f4             	mov    %esi,-0xc\(%rbp\)
+  5a:	89 75 f4             	mov    %esi,-0xc\(%rbp\)
+  5d:	89 75 f4             	mov    %esi,-0xc\(%rbp\)
+  60:	e8 [0-9a-f ]+       	callq  .*
+  65:	2e 2e 2e 2e 2e 89 75 f4 	cs cs cs cs mov %esi,%cs:-0xc\(%rbp\)
+  6d:	2e 2e 55             	cs cs push %rbp
+  70:	55                   	push   %rbp
+  71:	55                   	push   %rbp
+  72:	64 89 04 25 01 00 00 00 	mov    %eax,%fs:0x1
+  7a:	48 89 e5             	mov    %rsp,%rbp
+  7d:	89 75 f4             	mov    %esi,-0xc\(%rbp\)
+  80:	ff 14 25 00 00 00 00 	callq  \*0x0
+  87:	55                   	push   %rbp
+#pass
diff --git a/gas/testsuite/gas/i386/x86-64-align-branch-3.d b/gas/testsuite/gas/i386/x86-64-align-branch-3.d
new file mode 100644
index 0000000000..18767a7045
--- /dev/null
+++ b/gas/testsuite/gas/i386/x86-64-align-branch-3.d
@@ -0,0 +1,32 @@
+#as: -malign-branch-boundary=32 -malign-branch=indirect+call
+#objdump: -dw
+
+.*: +file format .*
+
+Disassembly of section .text:
+
+0+ <foo>:
+   0:	64 89 04 25 01 00 00 00 	mov    %eax,%fs:0x1
+   8:	55                   	push   %rbp
+   9:	55                   	push   %rbp
+   a:	55                   	push   %rbp
+   b:	55                   	push   %rbp
+   c:	48 89 e5             	mov    %rsp,%rbp
+   f:	89 75 f4             	mov    %esi,-0xc\(%rbp\)
+  12:	89 75 f4             	mov    %esi,-0xc\(%rbp\)
+  15:	89 75 f4             	mov    %esi,-0xc\(%rbp\)
+  18:	89 75 f4             	mov    %esi,-0xc\(%rbp\)
+  1b:	89 75 f4             	mov    %esi,-0xc\(%rbp\)
+  1e:	e8 00 00 00 00       	callq  23 <foo\+0x23>
+  23:	55                   	push   %rbp
+  24:	55                   	push   %rbp
+  25:	64 89 04 25 01 00 00 00 	mov    %eax,%fs:0x1
+  2d:	48 89 e5             	mov    %rsp,%rbp
+  30:	89 75 f4             	mov    %esi,-0xc\(%rbp\)
+  33:	89 75 f4             	mov    %esi,-0xc\(%rbp\)
+  36:	89 75 f4             	mov    %esi,-0xc\(%rbp\)
+  39:	89 75 f4             	mov    %esi,-0xc\(%rbp\)
+  3c:	89 75 f4             	mov    %esi,-0xc\(%rbp\)
+  3f:	ff 15 00 00 00 00    	callq  \*0x0\(%rip\)        # 45 <foo\+0x45>
+  45:	89 75 f4             	mov    %esi,-0xc\(%rbp\)
+#pass
diff --git a/gas/testsuite/gas/i386/x86-64-align-branch-3.s b/gas/testsuite/gas/i386/x86-64-align-branch-3.s
new file mode 100644
index 0000000000..6787cdc36f
--- /dev/null
+++ b/gas/testsuite/gas/i386/x86-64-align-branch-3.s
@@ -0,0 +1,27 @@
+  .text
+  .globl  foo
+  .p2align  4
+foo:
+  movl  %eax, %fs:0x1
+  pushq  %rbp
+  pushq  %rbp
+  pushq  %rbp
+  pushq  %rbp
+  movq  %rsp, %rbp
+  movl  %esi, -12(%rbp)
+  movl  %esi, -12(%rbp)
+  movl  %esi, -12(%rbp)
+  movl  %esi, -12(%rbp)
+  movl  %esi, -12(%rbp)
+  call	__tls_get_addr
+  pushq  %rbp
+  pushq  %rbp
+  movl  %eax, %fs:0x1
+  movq  %rsp, %rbp
+  movl  %esi, -12(%rbp)
+  movl  %esi, -12(%rbp)
+  movl  %esi, -12(%rbp)
+  movl  %esi, -12(%rbp)
+  movl  %esi, -12(%rbp)
+  call	*__tls_get_addr@GOTPCREL(%rip)
+  movl  %esi, -12(%rbp)
diff --git a/gas/testsuite/gas/i386/x86-64-align-branch-4.s b/gas/testsuite/gas/i386/x86-64-align-branch-4.s
new file mode 100644
index 0000000000..9b546fe189
--- /dev/null
+++ b/gas/testsuite/gas/i386/x86-64-align-branch-4.s
@@ -0,0 +1,27 @@
+  .text
+  .globl  foo
+  .p2align  4
+foo:
+  movl  %eax, %fs:0x1
+  pushq  %rbp
+  pushq  %rbp
+  movq  %rsp, %rbp
+  movl  %esi, -12(%rbp)
+  movl  %esi, -12(%rbp)
+  movl  %esi, -12(%rbp)
+  movl  %esi, -12(%rbp)
+  movl  %esi, -12(%rbp)
+  movl  %esi, -12(%rbp)
+  ret
+  pushq  %rbp
+  movl  %eax, %fs:0x1
+  pushq  %rbp
+  pushq  %rbp
+  movl  %esi, -12(%rbp)
+  movl  %esi, -12(%rbp)
+  movl  %esi, -12(%rbp)
+  movl  %esi, -12(%rbp)
+  movl  %esi, -12(%rbp)
+  movl  %esi, -12(%rbp)
+  ret $30
+  pushq  %rbp
diff --git a/gas/testsuite/gas/i386/x86-64-align-branch-4a.d b/gas/testsuite/gas/i386/x86-64-align-branch-4a.d
new file mode 100644
index 0000000000..47318e832a
--- /dev/null
+++ b/gas/testsuite/gas/i386/x86-64-align-branch-4a.d
@@ -0,0 +1,33 @@
+#source: x86-64-align-branch-4.s
+#as: -malign-branch-boundary=32 -malign-branch=fused+jcc+jmp
+#objdump: -dw
+
+.*: +file format .*
+
+Disassembly of section .text:
+
+0+ <foo>:
+   0:	64 89 04 25 01 00 00 00 	mov    %eax,%fs:0x1
+   8:	55                   	push   %rbp
+   9:	55                   	push   %rbp
+   a:	48 89 e5             	mov    %rsp,%rbp
+   d:	89 75 f4             	mov    %esi,-0xc\(%rbp\)
+  10:	89 75 f4             	mov    %esi,-0xc\(%rbp\)
+  13:	89 75 f4             	mov    %esi,-0xc\(%rbp\)
+  16:	89 75 f4             	mov    %esi,-0xc\(%rbp\)
+  19:	89 75 f4             	mov    %esi,-0xc\(%rbp\)
+  1c:	89 75 f4             	mov    %esi,-0xc\(%rbp\)
+  1f:	c3                   	retq   
+  20:	55                   	push   %rbp
+  21:	64 89 04 25 01 00 00 00 	mov    %eax,%fs:0x1
+  29:	55                   	push   %rbp
+  2a:	55                   	push   %rbp
+  2b:	89 75 f4             	mov    %esi,-0xc\(%rbp\)
+  2e:	89 75 f4             	mov    %esi,-0xc\(%rbp\)
+  31:	89 75 f4             	mov    %esi,-0xc\(%rbp\)
+  34:	89 75 f4             	mov    %esi,-0xc\(%rbp\)
+  37:	89 75 f4             	mov    %esi,-0xc\(%rbp\)
+  3a:	89 75 f4             	mov    %esi,-0xc\(%rbp\)
+  3d:	c2 1e 00             	retq   \$0x1e
+  40:	55                   	push   %rbp
+#pass
diff --git a/gas/testsuite/gas/i386/x86-64-align-branch-4b.d b/gas/testsuite/gas/i386/x86-64-align-branch-4b.d
new file mode 100644
index 0000000000..9a030dd246
--- /dev/null
+++ b/gas/testsuite/gas/i386/x86-64-align-branch-4b.d
@@ -0,0 +1,33 @@
+#source: x86-64-align-branch-4.s
+#as: -malign-branch-boundary=32 -malign-branch=ret
+#objdump: -dw
+
+.*: +file format .*
+
+Disassembly of section .text:
+
+0+ <foo>:
+   0:	64 64 89 04 25 01 00 00 00 	fs mov %eax,%fs:0x1
+   9:	55                   	push   %rbp
+   a:	55                   	push   %rbp
+   b:	48 89 e5             	mov    %rsp,%rbp
+   e:	89 75 f4             	mov    %esi,-0xc\(%rbp\)
+  11:	89 75 f4             	mov    %esi,-0xc\(%rbp\)
+  14:	89 75 f4             	mov    %esi,-0xc\(%rbp\)
+  17:	89 75 f4             	mov    %esi,-0xc\(%rbp\)
+  1a:	89 75 f4             	mov    %esi,-0xc\(%rbp\)
+  1d:	89 75 f4             	mov    %esi,-0xc\(%rbp\)
+  20:	c3                   	retq   
+  21:	2e 2e 55             	cs cs push %rbp
+  24:	64 89 04 25 01 00 00 00 	mov    %eax,%fs:0x1
+  2c:	55                   	push   %rbp
+  2d:	55                   	push   %rbp
+  2e:	89 75 f4             	mov    %esi,-0xc\(%rbp\)
+  31:	89 75 f4             	mov    %esi,-0xc\(%rbp\)
+  34:	89 75 f4             	mov    %esi,-0xc\(%rbp\)
+  37:	89 75 f4             	mov    %esi,-0xc\(%rbp\)
+  3a:	89 75 f4             	mov    %esi,-0xc\(%rbp\)
+  3d:	89 75 f4             	mov    %esi,-0xc\(%rbp\)
+  40:	c2 1e 00             	retq   \$0x1e
+  43:	55                   	push   %rbp
+#pass
diff --git a/gas/testsuite/gas/i386/x86-64-align-branch-5.d b/gas/testsuite/gas/i386/x86-64-align-branch-5.d
new file mode 100644
index 0000000000..3a16c1bef1
--- /dev/null
+++ b/gas/testsuite/gas/i386/x86-64-align-branch-5.d
@@ -0,0 +1,37 @@
+#source: align-branch-5.s
+#as: -malign-branch-boundary=32 -malign-branch=jcc+fused+jmp
+#objdump: -dw
+
+.*: +file format .*
+
+Disassembly of section .text:
+
+0+ <foo>:
+   0:	c1 e9 02             	shr    \$0x2,%ecx
+   3:	c1 e9 02             	shr    \$0x2,%ecx
+   6:	c1 e9 02             	shr    \$0x2,%ecx
+   9:	89 d1                	mov    %edx,%ecx
+   b:	31 c0                	xor    %eax,%eax
+   d:	c1 e9 02             	shr    \$0x2,%ecx
+  10:	c1 e9 02             	shr    \$0x2,%ecx
+  13:	c1 e9 02             	shr    \$0x2,%ecx
+  16:	c1 e9 02             	shr    \$0x2,%ecx
+  19:	c1 e9 02             	shr    \$0x2,%ecx
+  1c:	c1 e9 02             	shr    \$0x2,%ecx
+  1f:	f6 c2 02             	test   \$0x2,%dl
+  22:	f3 ab                	rep stos %eax,%es:\(%rdi\)
+  24:	75 dd                	jne    3 <foo\+0x3>
+  26:	31 c0                	xor    %eax,%eax
+  28:	c1 e9 02             	shr    \$0x2,%ecx
+  2b:	c1 e9 02             	shr    \$0x2,%ecx
+  2e:	c1 e9 02             	shr    \$0x2,%ecx
+  31:	89 d1                	mov    %edx,%ecx
+  33:	31 c0                	xor    %eax,%eax
+  35:	c1 e9 02             	shr    \$0x2,%ecx
+  38:	c1 e9 02             	shr    \$0x2,%ecx
+  3b:	c1 e9 02             	shr    \$0x2,%ecx
+  3e:	f6 c2 02             	test   \$0x2,%dl
+  41:	e8 00 00 00 00       	callq  46 <foo\+0x46>
+  46:	75 e3                	jne    2b <foo\+0x2b>
+  48:	31 c0                	xor    %eax,%eax
+#pass
diff --git a/gas/testsuite/gas/i386/x86-64-align-branch-6.d b/gas/testsuite/gas/i386/x86-64-align-branch-6.d
new file mode 100644
index 0000000000..59a157c809
--- /dev/null
+++ b/gas/testsuite/gas/i386/x86-64-align-branch-6.d
@@ -0,0 +1,19 @@
+#source: align-branch-6.s
+#as: -mbranches-within-32B-boundaries -D
+#objdump: -dw
+#warning_output: align-branch-6.e
+
+.*: +file format .*
+
+Disassembly of section .text:
+
+0+ <_start>:
+ +[a-f0-9]+:	66 66 2e 0f 1f 84 00 00 00 00 00 	data16 nopw %cs:0x0\(%rax,%rax,1\)
+ +[a-f0-9]+:	66 66 2e 0f 1f 84 00 00 00 00 00 	data16 nopw %cs:0x0\(%rax,%rax,1\)
+ +[a-f0-9]+:	66 66 2e 0f 1f 84 00 00 00 00 00 	data16 nopw %cs:0x0\(%rax,%rax,1\)
+ +[a-f0-9]+:	66 66 2e 0f 1f 84 00 00 00 00 00 	data16 nopw %cs:0x0\(%rax,%rax,1\)
+ +[a-f0-9]+:	66 66 2e 0f 1f 84 00 00 00 00 00 	data16 nopw %cs:0x0\(%rax,%rax,1\)
+ +[a-f0-9]+:	0f 1f 80 00 00 00 00 	nopl   0x0\(%rax\)
+ +[a-f0-9]+:	f2 73 bf             	bnd jae 0 <_start>
+ +[a-f0-9]+:	c3                   	retq   
+#pass
diff --git a/gas/testsuite/gas/i386/x86-64-align-branch-7.d b/gas/testsuite/gas/i386/x86-64-align-branch-7.d
new file mode 100644
index 0000000000..9454d5317e
--- /dev/null
+++ b/gas/testsuite/gas/i386/x86-64-align-branch-7.d
@@ -0,0 +1,18 @@
+#as: -mbranches-within-32B-boundaries -malign-branch-prefix-size=4
+#objdump: -dw
+
+.*: +file format .*
+
+Disassembly of section .text:
+
+0+ <foo>:
+ +[a-f0-9]+:	2e 66 0f 3a 60 00 03 	pcmpestrm \$0x3,%cs:\(%rax\),%xmm0
+ +[a-f0-9]+:	2e 2e 48 89 e5       	cs cs mov %rsp,%rbp
+ +[a-f0-9]+:	89 7d f8             	mov    %edi,-0x8\(%rbp\)
+ +[a-f0-9]+:	89 75 f4             	mov    %esi,-0xc\(%rbp\)
+ +[a-f0-9]+:	89 75 f4             	mov    %esi,-0xc\(%rbp\)
+ +[a-f0-9]+:	89 75 f4             	mov    %esi,-0xc\(%rbp\)
+ +[a-f0-9]+:	64 89 04 25 01 00 00 00 	mov    %eax,%fs:0x1
+ +[a-f0-9]+:	a8 04                	test   \$0x4,%al
+ +[a-f0-9]+:	70 dc                	jo     0 <foo>
+#pass
diff --git a/gas/testsuite/gas/i386/x86-64-align-branch-7.s b/gas/testsuite/gas/i386/x86-64-align-branch-7.s
new file mode 100644
index 0000000000..73f58077a1
--- /dev/null
+++ b/gas/testsuite/gas/i386/x86-64-align-branch-7.s
@@ -0,0 +1,14 @@
+  .text
+  .globl  foo
+  .p2align  4
+foo:
+.L1:
+  pcmpestrm $3, (%rax), %xmm0
+  movq  %rsp, %rbp
+  movl  %edi, -8(%rbp)
+  movl  %esi, -12(%rbp)
+  movl  %esi, -12(%rbp)
+  movl  %esi, -12(%rbp)
+  movl	%eax, %fs:0x1
+  testb $0x4,%al
+  jo  .L1
diff --git a/gas/testsuite/gas/i386/x86-64-align-branch-8.d b/gas/testsuite/gas/i386/x86-64-align-branch-8.d
new file mode 100644
index 0000000000..bffabc1d1c
--- /dev/null
+++ b/gas/testsuite/gas/i386/x86-64-align-branch-8.d
@@ -0,0 +1,18 @@
+#as: -mbranches-within-32B-boundaries -malign-branch-prefix-size=4
+#objdump: -dw
+
+.*: +file format .*
+
+Disassembly of section .text:
+
+0+ <foo>:
+ +[a-f0-9]+:	2e c4 63 79 60 38 03 	vpcmpestrm \$0x3,%cs:\(%rax\),%xmm15
+ +[a-f0-9]+:	2e 2e 48 89 e5       	cs cs mov %rsp,%rbp
+ +[a-f0-9]+:	89 7d f8             	mov    %edi,-0x8\(%rbp\)
+ +[a-f0-9]+:	89 75 f4             	mov    %esi,-0xc\(%rbp\)
+ +[a-f0-9]+:	89 75 f4             	mov    %esi,-0xc\(%rbp\)
+ +[a-f0-9]+:	89 75 f4             	mov    %esi,-0xc\(%rbp\)
+ +[a-f0-9]+:	64 89 04 25 01 00 00 00 	mov    %eax,%fs:0x1
+ +[a-f0-9]+:	a8 04                	test   \$0x4,%al
+ +[a-f0-9]+:	70 dc                	jo     0 <foo>
+#pass
diff --git a/gas/testsuite/gas/i386/x86-64-align-branch-8.s b/gas/testsuite/gas/i386/x86-64-align-branch-8.s
new file mode 100644
index 0000000000..bab825c405
--- /dev/null
+++ b/gas/testsuite/gas/i386/x86-64-align-branch-8.s
@@ -0,0 +1,14 @@
+  .text
+  .globl  foo
+  .p2align  4
+foo:
+.L1:
+  vpcmpestrm $3, (%rax), %xmm15
+  movq  %rsp, %rbp
+  movl  %edi, -8(%rbp)
+  movl  %esi, -12(%rbp)
+  movl  %esi, -12(%rbp)
+  movl  %esi, -12(%rbp)
+  movl	%eax, %fs:0x1
+  testb $0x4,%al
+  jo  .L1
diff --git a/ld/testsuite/ld-i386/align-branch-1.d b/ld/testsuite/ld-i386/align-branch-1.d
new file mode 100644
index 0000000000..9eb728728d
--- /dev/null
+++ b/ld/testsuite/ld-i386/align-branch-1.d
@@ -0,0 +1,25 @@
+#as: --32 -mbranches-within-32B-boundaries
+#ld: -melf_i386
+#objdump: -dw
+#notarget: i?86-*-nacl* x86_64-*-nacl*
+
+.*: +file format .*
+
+
+Disassembly of section .text:
+
+[a-f0-9]+ <_start>:
+ +[a-f0-9]+:	85 d2                	test   %edx,%edx
+ +[a-f0-9]+:	74 20                	je     8049024 <_start\+0x24>
+ +[a-f0-9]+:	85 d2                	test   %edx,%edx
+ +[a-f0-9]+:	74 1c                	je     8049024 <_start\+0x24>
+ +[a-f0-9]+:	85 ff                	test   %edi,%edi
+ +[a-f0-9]+:	74 18                	je     8049024 <_start\+0x24>
+ +[a-f0-9]+:	65 a1 00 00 00 00    	mov    %gs:0x0,%eax
+ +[a-f0-9]+:	90                   	nop
+ +[a-f0-9]+:	8d 74 26 00          	lea    0x0\(%esi,%eiz,1\),%esi
+ +[a-f0-9]+:	3e 3e 3e 8b 90 fc ff ff ff 	ds ds mov %ds:-0x4\(%eax\),%edx
+ +[a-f0-9]+:	85 d2                	test   %edx,%edx
+ +[a-f0-9]+:	74 00                	je     8049024 <_start\+0x24>
+ +[a-f0-9]+:	c3                   	ret    
+#pass
diff --git a/ld/testsuite/ld-i386/align-branch-1.s b/ld/testsuite/ld-i386/align-branch-1.s
new file mode 100644
index 0000000000..48edffbe64
--- /dev/null
+++ b/ld/testsuite/ld-i386/align-branch-1.s
@@ -0,0 +1,19 @@
+	.text
+	.globl _start
+_start:
+	testl   %edx, %edx
+	je	.L1
+	testl   %edx, %edx
+	je	.L1
+	testl   %edi, %edi
+	je	.L1
+	leal	bar@tlsldm(%ebx), %eax
+	call	___tls_get_addr@PLT
+	movl	bar@dtpoff(%eax), %edx
+	testl   %edx, %edx
+	je	.L1
+.L1:
+	ret
+	.section ".tdata", "awT", @progbits
+bar:
+	.long 10
diff --git a/ld/testsuite/ld-i386/i386.exp b/ld/testsuite/ld-i386/i386.exp
index 3a1fd8b3cf..8fe047bba0 100644
--- a/ld/testsuite/ld-i386/i386.exp
+++ b/ld/testsuite/ld-i386/i386.exp
@@ -495,6 +495,7 @@ run_dump_test "pr23854"
 run_dump_test "pr23930"
 run_dump_test "pr24322a"
 run_dump_test "pr24322b"
+run_dump_test "align-branch-1"
 
 if { !([istarget "i?86-*-linux*"]
        || [istarget "i?86-*-gnu*"]
diff --git a/ld/testsuite/ld-x86-64/align-branch-1.d b/ld/testsuite/ld-x86-64/align-branch-1.d
new file mode 100644
index 0000000000..85679123d7
--- /dev/null
+++ b/ld/testsuite/ld-x86-64/align-branch-1.d
@@ -0,0 +1,21 @@
+#as: --64 -mbranches-within-32B-boundaries
+#ld: -melf_x86_64
+#objdump: -dw
+#notarget: i?86-*-nacl* x86_64-*-nacl*
+
+.*: +file format .*
+
+
+Disassembly of section .text:
+
+[a-f0-9]+ <_start>:
+ +[a-f0-9]+:	85 d2                	test   %edx,%edx
+ +[a-f0-9]+:	74 21                	je     401025 <_start\+0x25>
+ +[a-f0-9]+:	48 85 ff             	test   %rdi,%rdi
+ +[a-f0-9]+:	74 1c                	je     401025 <_start\+0x25>
+ +[a-f0-9]+:	66 66 66 64 48 8b 04 25 00 00 00 00 	data16 data16 data16 mov %fs:0x0,%rax
+ +[a-f0-9]+:	2e 2e 2e 2e 48 8b 98 fc ff ff ff 	cs cs cs mov %cs:-0x4\(%rax\),%rbx
+ +[a-f0-9]+:	48 85 db             	test   %rbx,%rbx
+ +[a-f0-9]+:	74 00                	je     401025 <_start\+0x25>
+ +[a-f0-9]+:	c3                   	retq   
+#pass
diff --git a/ld/testsuite/ld-x86-64/align-branch-1.s b/ld/testsuite/ld-x86-64/align-branch-1.s
new file mode 100644
index 0000000000..5c60a37e44
--- /dev/null
+++ b/ld/testsuite/ld-x86-64/align-branch-1.s
@@ -0,0 +1,17 @@
+	.text
+	.globl _start
+_start:
+	testl   %edx, %edx
+	je	.L1
+	testq   %rdi, %rdi
+	je	.L1
+	leaq	bar@tlsld(%rip), %rdi
+	call	__tls_get_addr@PLT
+	movq	bar@dtpoff(%rax), %rbx
+	testq   %rbx, %rbx
+	je	.L1
+.L1:
+	ret
+	.section ".tdata", "awT", @progbits
+bar:
+	.long 10
diff --git a/ld/testsuite/ld-x86-64/x86-64.exp b/ld/testsuite/ld-x86-64/x86-64.exp
index b13cc7df0e..ab4822e2b4 100644
--- a/ld/testsuite/ld-x86-64/x86-64.exp
+++ b/ld/testsuite/ld-x86-64/x86-64.exp
@@ -460,6 +460,7 @@ run_dump_test "pr24721"
 run_dump_test "pr24721-x32"
 run_dump_test "pr24905"
 run_dump_test "pr24905-x32"
+run_dump_test "align-branch-1"
 
 if { ![istarget "x86_64-*-linux*"] && ![istarget "x86_64-*-nacl*"]} {
     return
-- 
2.21.0


Index Nav: [Date Index] [Subject Index] [Author Index] [Thread Index]
Message Nav: [Date Prev] [Date Next] [Thread Prev] [Thread Next]