Merge lp:~ams-codesourcery/gcc-linaro/lp663939 into lp:gcc-linaro/4.6

Proposed by Andrew Stubbs
Status: Superseded
Proposed branch: lp:~ams-codesourcery/gcc-linaro/lp663939
Merge into: lp:gcc-linaro/4.6
Diff against target: 917 lines (+491/-202)
9 files modified
ChangeLog.linaro (+15/-0)
gcc/config/arm/arm-protos.h (+1/-0)
gcc/config/arm/arm.c (+297/-192)
gcc/config/arm/arm.md (+13/-9)
gcc/config/arm/constraints.md (+13/-1)
gcc/testsuite/gcc.target/arm/thumb2-replicated-constant1.c (+27/-0)
gcc/testsuite/gcc.target/arm/thumb2-replicated-constant2.c (+75/-0)
gcc/testsuite/gcc.target/arm/thumb2-replicated-constant3.c (+28/-0)
gcc/testsuite/gcc.target/arm/thumb2-replicated-constant4.c (+22/-0)
To merge this branch: bzr merge lp:~ams-codesourcery/gcc-linaro/lp663939
Reviewer Review Type Date Requested Status
Richard Sandiford Approve
Linaro Toolchain Builder Pending
Review via email: mp+72895@code.launchpad.net

This proposal supersedes a proposal from 2011-07-11.

This proposal has been superseded by a proposal from 2011-09-06.

Description of the change

These patches improve support for Thumb replicated constants, add support for ADDW and SUBW, and ensure that the most efficient sense is used (inverted, negated, or normal).

This addresses the problems identified in LP:663939.

It has now been approved upstream in this new form.

Update: The testing found a bug. I think I fixed this now, and I've overwritten this branch with the fixed patch.

(Resubmitted with updated patches 2011-08-25)

To post a comment you must log in.
Revision history for this message
Loïc Minier (lool) wrote : Posted in a previous version of this proposal

Looks like we should ping upstream again here

Revision history for this message
Loïc Minier (lool) wrote : Posted in a previous version of this proposal

11:57 < lool> ams_cs: Is
https://code.launchpad.net/~ams-codesourcery/gcc-linaro/lp663939/+merge/45750
              still work in progress? It seems really old now
[...]
11:58 < ams_cs> lool: last activity 12th april
11:58 < ams_cs> lool: I have to do some reworking
11:58 < ams_cs> lool: I've also discussed this patch with Ramana quite a bit

Revision history for this message
Linaro Toolchain Builder (cbuild) wrote : Posted in a previous version of this proposal

cbuild has taken a snapshot of this branch at r106756 and queued it for build.

The snapshot is available at:
 http://ex.seabright.co.nz/snapshots/gcc-linaro-4.6+bzr106756~ams-codesourcery~lp663939.tar.xdelta3.xz

and will be built on the following builders:
 a9-builder i686 x86_64

You can track the build queue at:
 http://ex.seabright.co.nz/helpers/scheduler

cbuild-snapshot: gcc-linaro-4.6+bzr106756~ams-codesourcery~lp663939
cbuild-ancestor: lp:gcc-linaro/4.6+bzr106752
cbuild-state: check

Revision history for this message
Linaro Toolchain Builder (cbuild) wrote : Posted in a previous version of this proposal

cbuild successfully built this on i686-lucid-cbuild123-scorpius-i686r1.

The build results are available at:
 http://ex.seabright.co.nz/build/gcc-linaro-4.6+bzr106756~ams-codesourcery~lp663939/logs/i686-lucid-cbuild123-scorpius-i686r1

The test suite results were unchanged compared to the branch point lp:gcc-linaro/4.6+bzr106752.

The full testsuite results are at:
 http://ex.seabright.co.nz/build/gcc-linaro-4.6+bzr106756~ams-codesourcery~lp663939/logs/i686-lucid-cbuild123-scorpius-i686r1/gcc-testsuite.txt

cbuild-checked: i686-lucid-cbuild123-scorpius-i686r1

Revision history for this message
Linaro Toolchain Builder (cbuild) wrote : Posted in a previous version of this proposal

cbuild had trouble building this on armv7l-maverick-cbuild123-ursa4-cortexa9r1.
See the following failure logs:
 failed.txt gcc-build-failed.txt

under the build results at:
 http://ex.seabright.co.nz/build/gcc-linaro-4.6+bzr106756~ams-codesourcery~lp663939/logs/armv7l-maverick-cbuild123-ursa4-cortexa9r1

The test suite was not checked as this build has no .sum style test results

cbuild-checked: armv7l-maverick-cbuild123-ursa4-cortexa9r1

review: Needs Fixing
Revision history for this message
Linaro Toolchain Builder (cbuild) wrote : Posted in a previous version of this proposal

cbuild successfully built this on x86_64-maverick-cbuild123-crucis-x86_64r1.

The build results are available at:
 http://ex.seabright.co.nz/build/gcc-linaro-4.6+bzr106756~ams-codesourcery~lp663939/logs/x86_64-maverick-cbuild123-crucis-x86_64r1

The test suite results were unchanged compared to the branch point lp:gcc-linaro/4.6+bzr106752.

The full testsuite results are at:
 http://ex.seabright.co.nz/build/gcc-linaro-4.6+bzr106756~ams-codesourcery~lp663939/logs/x86_64-maverick-cbuild123-crucis-x86_64r1/gcc-testsuite.txt

cbuild-checked: x86_64-maverick-cbuild123-crucis-x86_64r1

Revision history for this message
Linaro Toolchain Builder (cbuild) wrote : Posted in a previous version of this proposal

cbuild has taken a snapshot of this branch at r106756 and queued it for build.

The snapshot is available at:
 http://ex.seabright.co.nz/snapshots/gcc-linaro-4.6+bzr106756~ams-codesourcery~lp663939.tar.xdelta3.xz

and will be built on the following builders:

You can track the build queue at:
 http://ex.seabright.co.nz/helpers/scheduler

cbuild-snapshot: gcc-linaro-4.6+bzr106756~ams-codesourcery~lp663939
cbuild-ancestor: lp:gcc-linaro/4.6+bzr106752
cbuild-state: check

Revision history for this message
Linaro Toolchain Builder (cbuild) wrote : Posted in a previous version of this proposal

cbuild successfully built this on i686-lucid-cbuild123-scorpius-i686r1.

The build results are available at:
 http://ex.seabright.co.nz/build/gcc-linaro-4.6+bzr106756~ams-codesourcery~lp663939/logs/i686-lucid-cbuild123-scorpius-i686r1

The test suite results were unchanged compared to the branch point lp:gcc-linaro/4.6+bzr106752.

The full testsuite results are at:
 http://ex.seabright.co.nz/build/gcc-linaro-4.6+bzr106756~ams-codesourcery~lp663939/logs/i686-lucid-cbuild123-scorpius-i686r1/gcc-testsuite.txt

cbuild-checked: i686-lucid-cbuild123-scorpius-i686r1

Revision history for this message
Linaro Toolchain Builder (cbuild) wrote : Posted in a previous version of this proposal

cbuild has taken a snapshot of this branch at r106756 and queued it for build.

The snapshot is available at:
 http://ex.seabright.co.nz/snapshots/gcc-linaro-4.6+bzr106756~ams-codesourcery~lp663939.tar.xdelta3.xz

and will be built on the following builders:
 a9-builder armv5-builder i686 x86_64

You can track the build queue at:
 http://ex.seabright.co.nz/helpers/scheduler

cbuild-snapshot: gcc-linaro-4.6+bzr106756~ams-codesourcery~lp663939
cbuild-ancestor: lp:gcc-linaro/4.6+bzr106752
cbuild-state: check

Revision history for this message
Linaro Toolchain Builder (cbuild) wrote : Posted in a previous version of this proposal

cbuild successfully built this on i686-lucid-cbuild123-scorpius-i686r1.

The build results are available at:
 http://ex.seabright.co.nz/build/gcc-linaro-4.6+bzr106756~ams-codesourcery~lp663939/logs/i686-lucid-cbuild123-scorpius-i686r1

The test suite results were unchanged compared to the branch point lp:gcc-linaro/4.6+bzr106752.

The full testsuite results are at:
 http://ex.seabright.co.nz/build/gcc-linaro-4.6+bzr106756~ams-codesourcery~lp663939/logs/i686-lucid-cbuild123-scorpius-i686r1/gcc-testsuite.txt

cbuild-checked: i686-lucid-cbuild123-scorpius-i686r1

Revision history for this message
Linaro Toolchain Builder (cbuild) wrote : Posted in a previous version of this proposal

cbuild successfully built this on x86_64-natty-cbuild151-oort1-x86_64r1.

The build results are available at:
 http://ex.seabright.co.nz/build/gcc-linaro-4.6+bzr106756~ams-codesourcery~lp663939/logs/x86_64-natty-cbuild151-oort1-x86_64r1

The test suite results were unchanged compared to the branch point lp:gcc-linaro/4.6+bzr106752.

The full testsuite results are at:
 http://ex.seabright.co.nz/build/gcc-linaro-4.6+bzr106756~ams-codesourcery~lp663939/logs/x86_64-natty-cbuild151-oort1-x86_64r1/gcc-testsuite.txt

cbuild-checked: x86_64-natty-cbuild151-oort1-x86_64r1

Revision history for this message
Linaro Toolchain Builder (cbuild) wrote : Posted in a previous version of this proposal

cbuild successfully built this on armv7l-natty-cbuild152-ursa1-armv5r2.

The build results are available at:
 http://ex.seabright.co.nz/build/gcc-linaro-4.6+bzr106756~ams-codesourcery~lp663939/logs/armv7l-natty-cbuild152-ursa1-armv5r2

The test suite was not checked as the branch point lp:gcc-linaro/4.6+bzr106752 has nothing to compare against.

The full testsuite results are at:
 http://ex.seabright.co.nz/build/gcc-linaro-4.6+bzr106756~ams-codesourcery~lp663939/logs/armv7l-natty-cbuild152-ursa1-armv5r2/gcc-testsuite.txt

cbuild-checked: armv7l-natty-cbuild152-ursa1-armv5r2

Revision history for this message
Michael Hope (michaelh1) wrote : Posted in a previous version of this proposal

I've nuked all previous builds and re-spawned them.

Revision history for this message
Michael Hope (michaelh1) wrote : Posted in a previous version of this proposal

cbuild successfully built this on x86_64-natty-cbuild158-oort3-x86_64r1.

The build results are available at:
 http://ex.seabright.co.nz/build/gcc-linaro-4.6+bzr106756~ams-codesourcery~lp663939/logs/x86_64-natty-cbuild158-oort3-x86_64r1

The testsuite results are the same as the branch point lp:gcc-linaro/4.6+bzr106752

The full testsuite results are at:
 http://ex.seabright.co.nz/build/gcc-linaro-4.6+bzr106756~ams-codesourcery~lp663939/logs/x86_64-natty-cbuild158-oort3-x86_64r1/gcc-testsuite.txt

cbuild-checked: x86_64-natty-cbuild158-oort3-x86_64r1

Revision history for this message
Michael Hope (michaelh1) wrote : Posted in a previous version of this proposal

cbuild successfully built this on i686-natty-cbuild158-oort2-i686r1.

The build results are available at:
 http://ex.seabright.co.nz/build/gcc-linaro-4.6+bzr106756~ams-codesourcery~lp663939/logs/i686-natty-cbuild158-oort2-i686r1

The testsuite results are the same as the branch point lp:gcc-linaro/4.6+bzr106752

The full testsuite results are at:
 http://ex.seabright.co.nz/build/gcc-linaro-4.6+bzr106756~ams-codesourcery~lp663939/logs/i686-natty-cbuild158-oort2-i686r1/gcc-testsuite.txt

cbuild-checked: i686-natty-cbuild158-oort2-i686r1

Revision history for this message
Michael Hope (michaelh1) wrote :

cbuild has taken a snapshot of this branch at r106800 and queued it for build.

The snapshot is available at:
 http://ex.seabright.co.nz/snapshots/gcc-linaro-4.6+bzr106800~ams-codesourcery~lp663939.tar.xdelta3.xz

and will be built on the following builders:
 a9-builder armv5-builder baremetal i686 x86_64

You can track the build queue at:
 http://ex.seabright.co.nz/helpers/scheduler

cbuild-snapshot: gcc-linaro-4.6+bzr106800~ams-codesourcery~lp663939
cbuild-ancestor: lp:gcc-linaro/4.6+bzr106796
cbuild-state: check

Revision history for this message
Michael Hope (michaelh1) wrote :

cbuild successfully built this on i686-natty-cbuild172-oort2-i686r1.

The build results are available at:
 http://ex.seabright.co.nz/build/gcc-linaro-4.6+bzr106800~ams-codesourcery~lp663939/logs/i686-natty-cbuild172-oort2-i686r1

The testsuite results are the same as the branch point lp:gcc-linaro/4.6+bzr106796

The full testsuite results are at:
 http://ex.seabright.co.nz/build/gcc-linaro-4.6+bzr106800~ams-codesourcery~lp663939/logs/i686-natty-cbuild172-oort2-i686r1/gcc-testsuite.txt

cbuild-checked: i686-natty-cbuild172-oort2-i686r1

Revision history for this message
Michael Hope (michaelh1) wrote :

cbuild successfully built this on armv7l-natty-cbuild172-ursa1-cortexa9r1.

The build results are available at:
 http://ex.seabright.co.nz/build/gcc-linaro-4.6+bzr106800~ams-codesourcery~lp663939/logs/armv7l-natty-cbuild172-ursa1-cortexa9r1

+PASS: gcc.target/arm/thumb2-replicated-constant1.c (test for excess errors)
+PASS: gcc.target/arm/thumb2-replicated-constant1.c scan-assembler add.*#-16843010
+PASS: gcc.target/arm/thumb2-replicated-constant1.c scan-assembler and.*#13435085
+PASS: gcc.target/arm/thumb2-replicated-constant1.c scan-assembler sub.*#-1426019584
+PASS: gcc.target/arm/thumb2-replicated-constant2.c (test for excess errors)
+PASS: gcc.target/arm/thumb2-replicated-constant2.c scan-assembler add.*#-2004318072
+PASS: gcc.target/arm/thumb2-replicated-constant2.c scan-assembler add.*#-33489408
+PASS: gcc.target/arm/thumb2-replicated-constant2.c scan-assembler add.*#-572662307
+PASS: gcc.target/arm/thumb2-replicated-constant2.c scan-assembler add.*#-587145984
+PASS: gcc.target/arm/thumb2-replicated-constant2.c scan-assembler add.*#1
+PASS: gcc.target/arm/thumb2-replicated-constant2.c scan-assembler add.*#13056
+PASS: gcc.target/arm/thumb2-replicated-constant2.c scan-assembler add.*#17
+PASS: gcc.target/arm/thumb2-replicated-constant2.c scan-assembler add.*#1717986918
+PASS: gcc.target/arm/thumb2-replicated-constant2.c scan-assembler add.*#1996488704
+PASS: gcc.target/arm/thumb2-replicated-constant2.c scan-assembler add.*#2228258
+PASS: gcc.target/arm/thumb2-replicated-constant2.c scan-assembler add.*#285212672
+PASS: gcc.target/arm/thumb2-replicated-constant2.c scan-assembler add.*#285217024
+PASS: gcc.target/arm/thumb2-replicated-constant2.c scan-assembler add.*#3342387
+PASS: gcc.target/arm/thumb2-replicated-constant2.c scan-assembler add.*#4456516
+PASS: gcc.target/arm/thumb2-replicated-constant2.c scan-assembler add.*#65536
+PASS: gcc.target/arm/thumb2-replicated-constant2.c scan-assembler addw.*#546
+PASS: gcc.target/arm/thumb2-replicated-constant3.c (test for excess errors)
+PASS: gcc.target/arm/thumb2-replicated-constant3.c scan-assembler and.*#-1431655766
+PASS: gcc.target/arm/thumb2-replicated-constant3.c scan-assembler bic.*#1114129
+PASS: gcc.target/arm/thumb2-replicated-constant3.c scan-assembler bic.*#170
+PASS: gcc.target/arm/thumb2-replicated-constant3.c scan-assembler orn.*#255
+PASS: gcc.target/arm/thumb2-replicated-constant4.c (test for excess errors)
+PASS: gcc.target/arm/thumb2-replicated-constant4.c scan-assembler add.*#252706816
+PASS: gcc.target/arm/thumb2-replicated-constant4.c scan-assembler add.*#32505856
+PASS: gcc.target/arm/thumb2-replicated-constant4.c scan-assembler add.*#3600
+PASS: gcc.target/arm/thumb2-replicated-constant4.c scan-assembler add.*#480

The full testsuite results are at:
 http://ex.seabright.co.nz/build/gcc-linaro-4.6+bzr106800~ams-codesourcery~lp663939/logs/armv7l-natty-cbuild172-ursa1-cortexa9r1/gcc-testsuite.txt

cbuild-checked: armv7l-natty-cbuild172-ursa1-cortexa9r1

Revision history for this message
Michael Hope (michaelh1) wrote :

cbuild successfully built this on x86_64-natty-cbuild172-oort1-x86_64r1.

The build results are available at:
 http://ex.seabright.co.nz/build/gcc-linaro-4.6+bzr106800~ams-codesourcery~lp663939/logs/x86_64-natty-cbuild172-oort1-x86_64r1

The testsuite results are the same as the branch point lp:gcc-linaro/4.6+bzr106796

The full testsuite results are at:
 http://ex.seabright.co.nz/build/gcc-linaro-4.6+bzr106800~ams-codesourcery~lp663939/logs/x86_64-natty-cbuild172-oort1-x86_64r1/gcc-testsuite.txt

cbuild-checked: x86_64-natty-cbuild172-oort1-x86_64r1

Revision history for this message
Michael Hope (michaelh1) wrote :

cbuild successfully built this on armv7l-natty-cbuild172-ursa1-cortexa9r1.

The build results are available at:
 http://ex.seabright.co.nz/build/gcc-linaro-4.6+bzr106800~ams-codesourcery~lp663939/logs/armv7l-natty-cbuild172-ursa1-cortexa9r1

+PASS: gcc.target/arm/thumb2-replicated-constant1.c (test for excess errors)
+PASS: gcc.target/arm/thumb2-replicated-constant1.c scan-assembler add.*#-16843010
+PASS: gcc.target/arm/thumb2-replicated-constant1.c scan-assembler and.*#13435085
+PASS: gcc.target/arm/thumb2-replicated-constant1.c scan-assembler sub.*#-1426019584
+PASS: gcc.target/arm/thumb2-replicated-constant2.c (test for excess errors)
+PASS: gcc.target/arm/thumb2-replicated-constant2.c scan-assembler add.*#-2004318072
+PASS: gcc.target/arm/thumb2-replicated-constant2.c scan-assembler add.*#-33489408
+PASS: gcc.target/arm/thumb2-replicated-constant2.c scan-assembler add.*#-572662307
+PASS: gcc.target/arm/thumb2-replicated-constant2.c scan-assembler add.*#-587145984
+PASS: gcc.target/arm/thumb2-replicated-constant2.c scan-assembler add.*#1
+PASS: gcc.target/arm/thumb2-replicated-constant2.c scan-assembler add.*#13056
+PASS: gcc.target/arm/thumb2-replicated-constant2.c scan-assembler add.*#17
+PASS: gcc.target/arm/thumb2-replicated-constant2.c scan-assembler add.*#1717986918
+PASS: gcc.target/arm/thumb2-replicated-constant2.c scan-assembler add.*#1996488704
+PASS: gcc.target/arm/thumb2-replicated-constant2.c scan-assembler add.*#2228258
+PASS: gcc.target/arm/thumb2-replicated-constant2.c scan-assembler add.*#285212672
+PASS: gcc.target/arm/thumb2-replicated-constant2.c scan-assembler add.*#285217024
+PASS: gcc.target/arm/thumb2-replicated-constant2.c scan-assembler add.*#3342387
+PASS: gcc.target/arm/thumb2-replicated-constant2.c scan-assembler add.*#4456516
+PASS: gcc.target/arm/thumb2-replicated-constant2.c scan-assembler add.*#65536
+PASS: gcc.target/arm/thumb2-replicated-constant2.c scan-assembler addw.*#546
+PASS: gcc.target/arm/thumb2-replicated-constant3.c (test for excess errors)
+PASS: gcc.target/arm/thumb2-replicated-constant3.c scan-assembler and.*#-1431655766
+PASS: gcc.target/arm/thumb2-replicated-constant3.c scan-assembler bic.*#1114129
+PASS: gcc.target/arm/thumb2-replicated-constant3.c scan-assembler bic.*#170
+PASS: gcc.target/arm/thumb2-replicated-constant3.c scan-assembler orn.*#255
+PASS: gcc.target/arm/thumb2-replicated-constant4.c (test for excess errors)
+PASS: gcc.target/arm/thumb2-replicated-constant4.c scan-assembler add.*#252706816
+PASS: gcc.target/arm/thumb2-replicated-constant4.c scan-assembler add.*#32505856
+PASS: gcc.target/arm/thumb2-replicated-constant4.c scan-assembler add.*#3600
+PASS: gcc.target/arm/thumb2-replicated-constant4.c scan-assembler add.*#480

The full testsuite results are at:
 http://ex.seabright.co.nz/build/gcc-linaro-4.6+bzr106800~ams-codesourcery~lp663939/logs/armv7l-natty-cbuild172-ursa1-cortexa9r1/gcc-testsuite.txt

cbuild-checked: armv7l-natty-cbuild172-ursa1-cortexa9r1

Revision history for this message
Richard Sandiford (rsandifo) wrote :

OK

review: Approve

Preview Diff

[H/L] Next/Prev Comment, [J/K] Next/Prev File, [N/P] Next/Prev Hunk
1=== modified file 'ChangeLog.linaro'
2--- ChangeLog.linaro 2011-08-25 11:42:09 +0000
3+++ ChangeLog.linaro 2011-08-25 13:44:32 +0000
4@@ -2,6 +2,21 @@
5
6 Backport from FSF mainline:
7
8+ 2011-04-20 Andrew Stubbs <ams@codesourcery.com>
9+
10+ gcc/
11+ * config/arm/arm.c (arm_gen_constant): Move movw support ....
12+ (const_ok_for_op): ... to here.
13+
14+ 2011-04-20 Andrew Stubbs <ams@codesourcery.com>
15+
16+ gcc/
17+ * config/arm/arm.c (arm_gen_constant): Remove redundant can_invert.
18+
19+2011-08-25 Andrew Stubbs <ams@codesourcery.com>
20+
21+ Backport from FSF mainline:
22+
23 2011-08-19 Andrew Stubbs <ams@codesourcery.com>
24
25 gcc/
26
27=== modified file 'gcc/config/arm/arm-protos.h'
28--- gcc/config/arm/arm-protos.h 2011-07-04 14:03:49 +0000
29+++ gcc/config/arm/arm-protos.h 2011-08-25 13:44:32 +0000
30@@ -46,6 +46,7 @@
31 extern bool arm_small_register_classes_for_mode_p (enum machine_mode);
32 extern int arm_hard_regno_mode_ok (unsigned int, enum machine_mode);
33 extern int const_ok_for_arm (HOST_WIDE_INT);
34+extern int const_ok_for_op (HOST_WIDE_INT, enum rtx_code);
35 extern int arm_split_constant (RTX_CODE, enum machine_mode, rtx,
36 HOST_WIDE_INT, rtx, rtx, int);
37 extern RTX_CODE arm_canonicalize_comparison (RTX_CODE, rtx *, rtx *);
38
39=== modified file 'gcc/config/arm/arm.c'
40--- gcc/config/arm/arm.c 2011-08-24 17:35:16 +0000
41+++ gcc/config/arm/arm.c 2011-08-25 13:44:32 +0000
42@@ -63,6 +63,11 @@
43
44 void (*arm_lang_output_object_attributes_hook)(void);
45
46+struct four_ints
47+{
48+ int i[4];
49+};
50+
51 /* Forward function declarations. */
52 static bool arm_needs_doubleword_align (enum machine_mode, const_tree);
53 static int arm_compute_static_chain_stack_bytes (void);
54@@ -81,7 +86,6 @@
55 static bool arm_legitimate_address_p (enum machine_mode, rtx, bool);
56 static int thumb_far_jump_used_p (void);
57 static bool thumb_force_lr_save (void);
58-static int const_ok_for_op (HOST_WIDE_INT, enum rtx_code);
59 static rtx emit_sfm (int, int);
60 static unsigned arm_size_return_regs (void);
61 static bool arm_assemble_integer (rtx, unsigned int, int);
62@@ -129,7 +133,13 @@
63 static int arm_comp_type_attributes (const_tree, const_tree);
64 static void arm_set_default_type_attributes (tree);
65 static int arm_adjust_cost (rtx, rtx, rtx, int);
66-static int count_insns_for_constant (HOST_WIDE_INT, int);
67+static int optimal_immediate_sequence (enum rtx_code code,
68+ unsigned HOST_WIDE_INT val,
69+ struct four_ints *return_sequence);
70+static int optimal_immediate_sequence_1 (enum rtx_code code,
71+ unsigned HOST_WIDE_INT val,
72+ struct four_ints *return_sequence,
73+ int i);
74 static int arm_get_strip_length (int);
75 static bool arm_function_ok_for_sibcall (tree, tree);
76 static enum machine_mode arm_promote_function_mode (const_tree,
77@@ -2525,7 +2535,7 @@
78 }
79
80 /* Return true if I is a valid constant for the operation CODE. */
81-static int
82+int
83 const_ok_for_op (HOST_WIDE_INT i, enum rtx_code code)
84 {
85 if (const_ok_for_arm (i))
86@@ -2533,7 +2543,21 @@
87
88 switch (code)
89 {
90+ case SET:
91+ /* See if we can use movw. */
92+ if (arm_arch_thumb2 && (i & 0xffff0000) == 0)
93+ return 1;
94+ else
95+ return 0;
96+
97 case PLUS:
98+ /* See if we can use addw or subw. */
99+ if (TARGET_THUMB2
100+ && ((i & 0xfffff000) == 0
101+ || ((-i) & 0xfffff000) == 0))
102+ return 1;
103+ /* else fall through. */
104+
105 case COMPARE:
106 case EQ:
107 case NE:
108@@ -2649,68 +2673,41 @@
109 1);
110 }
111
112-/* Return the number of instructions required to synthesize the given
113- constant, if we start emitting them from bit-position I. */
114-static int
115-count_insns_for_constant (HOST_WIDE_INT remainder, int i)
116-{
117- HOST_WIDE_INT temp1;
118- int step_size = TARGET_ARM ? 2 : 1;
119- int num_insns = 0;
120-
121- gcc_assert (TARGET_ARM || i == 0);
122-
123- do
124- {
125- int end;
126-
127- if (i <= 0)
128- i += 32;
129- if (remainder & (((1 << step_size) - 1) << (i - step_size)))
130- {
131- end = i - 8;
132- if (end < 0)
133- end += 32;
134- temp1 = remainder & ((0x0ff << end)
135- | ((i < end) ? (0xff >> (32 - end)) : 0));
136- remainder &= ~temp1;
137- num_insns++;
138- i -= 8 - step_size;
139- }
140- i -= step_size;
141- } while (remainder);
142- return num_insns;
143-}
144-
145-static int
146-find_best_start (unsigned HOST_WIDE_INT remainder)
147+/* Return a sequence of integers, in RETURN_SEQUENCE that fit into
148+ ARM/THUMB2 immediates, and add up to VAL.
149+ Thr function return value gives the number of insns required. */
150+static int
151+optimal_immediate_sequence (enum rtx_code code, unsigned HOST_WIDE_INT val,
152+ struct four_ints *return_sequence)
153 {
154 int best_consecutive_zeros = 0;
155 int i;
156 int best_start = 0;
157+ int insns1, insns2;
158+ struct four_ints tmp_sequence;
159
160 /* If we aren't targetting ARM, the best place to start is always at
161- the bottom. */
162- if (! TARGET_ARM)
163- return 0;
164-
165- for (i = 0; i < 32; i += 2)
166+ the bottom, otherwise look more closely. */
167+ if (TARGET_ARM)
168 {
169- int consecutive_zeros = 0;
170-
171- if (!(remainder & (3 << i)))
172+ for (i = 0; i < 32; i += 2)
173 {
174- while ((i < 32) && !(remainder & (3 << i)))
175- {
176- consecutive_zeros += 2;
177- i += 2;
178- }
179- if (consecutive_zeros > best_consecutive_zeros)
180- {
181- best_consecutive_zeros = consecutive_zeros;
182- best_start = i - consecutive_zeros;
183- }
184- i -= 2;
185+ int consecutive_zeros = 0;
186+
187+ if (!(val & (3 << i)))
188+ {
189+ while ((i < 32) && !(val & (3 << i)))
190+ {
191+ consecutive_zeros += 2;
192+ i += 2;
193+ }
194+ if (consecutive_zeros > best_consecutive_zeros)
195+ {
196+ best_consecutive_zeros = consecutive_zeros;
197+ best_start = i - consecutive_zeros;
198+ }
199+ i -= 2;
200+ }
201 }
202 }
203
204@@ -2737,13 +2734,161 @@
205 the constant starting from `best_start', and also starting from
206 zero (i.e. with bit 31 first to be output). If `best_start' doesn't
207 yield a shorter sequence, we may as well use zero. */
208+ insns1 = optimal_immediate_sequence_1 (code, val, return_sequence, best_start);
209 if (best_start != 0
210- && ((((unsigned HOST_WIDE_INT) 1) << best_start) < remainder)
211- && (count_insns_for_constant (remainder, 0) <=
212- count_insns_for_constant (remainder, best_start)))
213- best_start = 0;
214-
215- return best_start;
216+ && ((((unsigned HOST_WIDE_INT) 1) << best_start) < val))
217+ {
218+ insns2 = optimal_immediate_sequence_1 (code, val, &tmp_sequence, 0);
219+ if (insns2 <= insns1)
220+ {
221+ *return_sequence = tmp_sequence;
222+ insns1 = insns2;
223+ }
224+ }
225+
226+ return insns1;
227+}
228+
229+/* As for optimal_immediate_sequence, but starting at bit-position I. */
230+static int
231+optimal_immediate_sequence_1 (enum rtx_code code, unsigned HOST_WIDE_INT val,
232+ struct four_ints *return_sequence, int i)
233+{
234+ int remainder = val & 0xffffffff;
235+ int insns = 0;
236+
237+ /* Try and find a way of doing the job in either two or three
238+ instructions.
239+
240+ In ARM mode we can use 8-bit constants, rotated to any 2-bit aligned
241+ location. We start at position I. This may be the MSB, or
242+ optimial_immediate_sequence may have positioned it at the largest block
243+ of zeros that are aligned on a 2-bit boundary. We then fill up the temps,
244+ wrapping around to the top of the word when we drop off the bottom.
245+ In the worst case this code should produce no more than four insns.
246+
247+ In Thumb2 mode, we can use 32/16-bit replicated constants, and 8-bit
248+ constants, shifted to any arbitrary location. We should always start
249+ at the MSB. */
250+ do
251+ {
252+ int end;
253+ int b1, b2, b3, b4;
254+ unsigned HOST_WIDE_INT result;
255+ int loc;
256+
257+ gcc_assert (insns < 4);
258+
259+ if (i <= 0)
260+ i += 32;
261+
262+ /* First, find the next normal 12/8-bit shifted/rotated immediate. */
263+ if (remainder & ((TARGET_ARM ? (3 << (i - 2)) : (1 << (i - 1)))))
264+ {
265+ loc = i;
266+ if (i <= 12 && TARGET_THUMB2 && code == PLUS)
267+ /* We can use addw/subw for the last 12 bits. */
268+ result = remainder;
269+ else
270+ {
271+ /* Use an 8-bit shifted/rotated immediate. */
272+ end = i - 8;
273+ if (end < 0)
274+ end += 32;
275+ result = remainder & ((0x0ff << end)
276+ | ((i < end) ? (0xff >> (32 - end))
277+ : 0));
278+ i -= 8;
279+ }
280+ }
281+ else
282+ {
283+ /* Arm allows rotates by a multiple of two. Thumb-2 allows
284+ arbitrary shifts. */
285+ i -= TARGET_ARM ? 2 : 1;
286+ continue;
287+ }
288+
289+ /* Next, see if we can do a better job with a thumb2 replicated
290+ constant.
291+
292+ We do it this way around to catch the cases like 0x01F001E0 where
293+ two 8-bit immediates would work, but a replicated constant would
294+ make it worse.
295+
296+ TODO: 16-bit constants that don't clear all the bits, but still win.
297+ TODO: Arithmetic splitting for set/add/sub, rather than bitwise. */
298+ if (TARGET_THUMB2)
299+ {
300+ b1 = (remainder & 0xff000000) >> 24;
301+ b2 = (remainder & 0x00ff0000) >> 16;
302+ b3 = (remainder & 0x0000ff00) >> 8;
303+ b4 = remainder & 0xff;
304+
305+ if (loc > 24)
306+ {
307+ /* The 8-bit immediate already found clears b1 (and maybe b2),
308+ but must leave b3 and b4 alone. */
309+
310+ /* First try to find a 32-bit replicated constant that clears
311+ almost everything. We can assume that we can't do it in one,
312+ or else we wouldn't be here. */
313+ unsigned int tmp = b1 & b2 & b3 & b4;
314+ unsigned int tmp2 = tmp + (tmp << 8) + (tmp << 16)
315+ + (tmp << 24);
316+ unsigned int matching_bytes = (tmp == b1) + (tmp == b2)
317+ + (tmp == b3) + (tmp == b4);
318+ if (tmp
319+ && (matching_bytes >= 3
320+ || (matching_bytes == 2
321+ && const_ok_for_op (remainder & ~tmp2, code))))
322+ {
323+ /* At least 3 of the bytes match, and the fourth has at
324+ least as many bits set, or two of the bytes match
325+ and it will only require one more insn to finish. */
326+ result = tmp2;
327+ i = tmp != b1 ? 32
328+ : tmp != b2 ? 24
329+ : tmp != b3 ? 16
330+ : 8;
331+ }
332+
333+ /* Second, try to find a 16-bit replicated constant that can
334+ leave three of the bytes clear. If b2 or b4 is already
335+ zero, then we can. If the 8-bit from above would not
336+ clear b2 anyway, then we still win. */
337+ else if (b1 == b3 && (!b2 || !b4
338+ || (remainder & 0x00ff0000 & ~result)))
339+ {
340+ result = remainder & 0xff00ff00;
341+ i = 24;
342+ }
343+ }
344+ else if (loc > 16)
345+ {
346+ /* The 8-bit immediate already found clears b2 (and maybe b3)
347+ and we don't get here unless b1 is alredy clear, but it will
348+ leave b4 unchanged. */
349+
350+ /* If we can clear b2 and b4 at once, then we win, since the
351+ 8-bits couldn't possibly reach that far. */
352+ if (b2 == b4)
353+ {
354+ result = remainder & 0x00ff00ff;
355+ i = 16;
356+ }
357+ }
358+ }
359+
360+ return_sequence->i[insns++] = result;
361+ remainder &= ~result;
362+
363+ if (code == SET || code == MINUS)
364+ code = PLUS;
365+ }
366+ while (remainder);
367+
368+ return insns;
369 }
370
371 /* Emit an instruction with the indicated PATTERN. If COND is
372@@ -2760,7 +2905,6 @@
373
374 /* As above, but extra parameter GENERATE which, if clear, suppresses
375 RTL generation. */
376-/* ??? This needs more work for thumb2. */
377
378 static int
379 arm_gen_constant (enum rtx_code code, enum machine_mode mode, rtx cond,
380@@ -2772,15 +2916,15 @@
381 int final_invert = 0;
382 int can_negate_initial = 0;
383 int i;
384- int num_bits_set = 0;
385 int set_sign_bit_copies = 0;
386 int clear_sign_bit_copies = 0;
387 int clear_zero_bit_copies = 0;
388 int set_zero_bit_copies = 0;
389- int insns = 0;
390+ int insns = 0, neg_insns, inv_insns;
391 unsigned HOST_WIDE_INT temp1, temp2;
392 unsigned HOST_WIDE_INT remainder = val & 0xffffffff;
393- int step_size = TARGET_ARM ? 2 : 1;
394+ struct four_ints *immediates;
395+ struct four_ints pos_immediates, neg_immediates, inv_immediates;
396
397 /* Find out which operations are safe for a given CODE. Also do a quick
398 check for degenerate cases; these can occur when DImode operations
399@@ -2789,7 +2933,6 @@
400 {
401 case SET:
402 can_invert = 1;
403- can_negate = 1;
404 break;
405
406 case PLUS:
407@@ -2817,9 +2960,6 @@
408 gen_rtx_SET (VOIDmode, target, source));
409 return 1;
410 }
411-
412- if (TARGET_THUMB2)
413- can_invert = 1;
414 break;
415
416 case AND:
417@@ -2861,6 +3001,7 @@
418 gen_rtx_NOT (mode, source)));
419 return 1;
420 }
421+ final_invert = 1;
422 break;
423
424 case MINUS:
425@@ -2883,7 +3024,6 @@
426 source)));
427 return 1;
428 }
429- can_negate = 1;
430
431 break;
432
433@@ -2892,9 +3032,7 @@
434 }
435
436 /* If we can do it in one insn get out quickly. */
437- if (const_ok_for_arm (val)
438- || (can_negate_initial && const_ok_for_arm (-val))
439- || (can_invert && const_ok_for_arm (~val)))
440+ if (const_ok_for_op (val, code))
441 {
442 if (generate)
443 emit_constant_insn (cond,
444@@ -2947,15 +3085,6 @@
445 switch (code)
446 {
447 case SET:
448- /* See if we can use movw. */
449- if (arm_arch_thumb2 && (remainder & 0xffff0000) == 0)
450- {
451- if (generate)
452- emit_constant_insn (cond, gen_rtx_SET (VOIDmode, target,
453- GEN_INT (val)));
454- return 1;
455- }
456-
457 /* See if we can do this by sign_extending a constant that is known
458 to be negative. This is a good, way of doing it, since the shift
459 may well merge into a subsequent insn. */
460@@ -3306,121 +3435,97 @@
461 break;
462 }
463
464- for (i = 0; i < 32; i++)
465- if (remainder & (1 << i))
466- num_bits_set++;
467-
468- if ((code == AND)
469- || (code != IOR && can_invert && num_bits_set > 16))
470- remainder ^= 0xffffffff;
471- else if (code == PLUS && num_bits_set > 16)
472- remainder = (-remainder) & 0xffffffff;
473-
474- /* For XOR, if more than half the bits are set and there's a sequence
475- of more than 8 consecutive ones in the pattern then we can XOR by the
476- inverted constant and then invert the final result; this may save an
477- instruction and might also lead to the final mvn being merged with
478- some other operation. */
479- else if (code == XOR && num_bits_set > 16
480- && (count_insns_for_constant (remainder ^ 0xffffffff,
481- find_best_start
482- (remainder ^ 0xffffffff))
483- < count_insns_for_constant (remainder,
484- find_best_start (remainder))))
485- {
486- remainder ^= 0xffffffff;
487- final_invert = 1;
488+ /* Calculate what the instruction sequences would be if we generated it
489+ normally, negated, or inverted. */
490+ if (code == AND)
491+ /* AND cannot be split into multiple insns, so invert and use BIC. */
492+ insns = 99;
493+ else
494+ insns = optimal_immediate_sequence (code, remainder, &pos_immediates);
495+
496+ if (can_negate)
497+ neg_insns = optimal_immediate_sequence (code, (-remainder) & 0xffffffff,
498+ &neg_immediates);
499+ else
500+ neg_insns = 99;
501+
502+ if (can_invert || final_invert)
503+ inv_insns = optimal_immediate_sequence (code, remainder ^ 0xffffffff,
504+ &inv_immediates);
505+ else
506+ inv_insns = 99;
507+
508+ immediates = &pos_immediates;
509+
510+ /* Is the negated immediate sequence more efficient? */
511+ if (neg_insns < insns && neg_insns <= inv_insns)
512+ {
513+ insns = neg_insns;
514+ immediates = &neg_immediates;
515+ }
516+ else
517+ can_negate = 0;
518+
519+ /* Is the inverted immediate sequence more efficient?
520+ We must allow for an extra NOT instruction for XOR operations, although
521+ there is some chance that the final 'mvn' will get optimized later. */
522+ if ((inv_insns + 1) < insns || (!final_invert && inv_insns < insns))
523+ {
524+ insns = inv_insns;
525+ immediates = &inv_immediates;
526 }
527 else
528 {
529 can_invert = 0;
530- can_negate = 0;
531+ final_invert = 0;
532 }
533
534- /* Now try and find a way of doing the job in either two or three
535- instructions.
536- We start by looking for the largest block of zeros that are aligned on
537- a 2-bit boundary, we then fill up the temps, wrapping around to the
538- top of the word when we drop off the bottom.
539- In the worst case this code should produce no more than four insns.
540- Thumb-2 constants are shifted, not rotated, so the MSB is always the
541- best place to start. */
542-
543- /* ??? Use thumb2 replicated constants when the high and low halfwords are
544- the same. */
545- {
546- /* Now start emitting the insns. */
547- i = find_best_start (remainder);
548- do
549- {
550- int end;
551-
552- if (i <= 0)
553- i += 32;
554- if (remainder & (3 << (i - 2)))
555- {
556- end = i - 8;
557- if (end < 0)
558- end += 32;
559- temp1 = remainder & ((0x0ff << end)
560- | ((i < end) ? (0xff >> (32 - end)) : 0));
561- remainder &= ~temp1;
562-
563- if (generate)
564- {
565- rtx new_src, temp1_rtx;
566-
567- if (code == SET || code == MINUS)
568- {
569- new_src = (subtargets ? gen_reg_rtx (mode) : target);
570- if (can_invert && code != MINUS)
571- temp1 = ~temp1;
572- }
573- else
574- {
575- if ((final_invert || remainder) && subtargets)
576- new_src = gen_reg_rtx (mode);
577- else
578- new_src = target;
579- if (can_invert)
580- temp1 = ~temp1;
581- else if (can_negate)
582- temp1 = -temp1;
583- }
584-
585- temp1 = trunc_int_for_mode (temp1, mode);
586- temp1_rtx = GEN_INT (temp1);
587-
588- if (code == SET)
589- ;
590- else if (code == MINUS)
591- temp1_rtx = gen_rtx_MINUS (mode, temp1_rtx, source);
592- else
593- temp1_rtx = gen_rtx_fmt_ee (code, mode, source, temp1_rtx);
594-
595- emit_constant_insn (cond,
596- gen_rtx_SET (VOIDmode, new_src,
597- temp1_rtx));
598- source = new_src;
599- }
600-
601- if (code == SET)
602- {
603- can_invert = 0;
604- code = PLUS;
605- }
606- else if (code == MINUS)
607+ /* Now output the chosen sequence as instructions. */
608+ if (generate)
609+ {
610+ for (i = 0; i < insns; i++)
611+ {
612+ rtx new_src, temp1_rtx;
613+
614+ temp1 = immediates->i[i];
615+
616+ if (code == SET || code == MINUS)
617+ new_src = (subtargets ? gen_reg_rtx (mode) : target);
618+ else if ((final_invert || i < (insns - 1)) && subtargets)
619+ new_src = gen_reg_rtx (mode);
620+ else
621+ new_src = target;
622+
623+ if (can_invert)
624+ temp1 = ~temp1;
625+ else if (can_negate)
626+ temp1 = -temp1;
627+
628+ temp1 = trunc_int_for_mode (temp1, mode);
629+ temp1_rtx = GEN_INT (temp1);
630+
631+ if (code == SET)
632+ ;
633+ else if (code == MINUS)
634+ temp1_rtx = gen_rtx_MINUS (mode, temp1_rtx, source);
635+ else
636+ temp1_rtx = gen_rtx_fmt_ee (code, mode, source, temp1_rtx);
637+
638+ emit_constant_insn (cond,
639+ gen_rtx_SET (VOIDmode, new_src,
640+ temp1_rtx));
641+ source = new_src;
642+
643+ if (code == SET)
644+ {
645+ can_invert = 0;
646+ can_negate = 1;
647 code = PLUS;
648-
649- insns++;
650- i -= 8 - step_size;
651- }
652- /* Arm allows rotates by a multiple of two. Thumb-2 allows arbitrary
653- shifts. */
654- i -= step_size;
655- }
656- while (remainder);
657- }
658+ }
659+ else if (code == MINUS)
660+ code = PLUS;
661+ }
662+ }
663
664 if (final_invert)
665 {
666
667=== modified file 'gcc/config/arm/arm.md'
668--- gcc/config/arm/arm.md 2011-08-25 11:42:09 +0000
669+++ gcc/config/arm/arm.md 2011-08-25 13:44:32 +0000
670@@ -701,21 +701,24 @@
671 ;; (plus (reg rN) (reg sp)) into (reg rN). In this case reload will
672 ;; put the duplicated register first, and not try the commutative version.
673 (define_insn_and_split "*arm_addsi3"
674- [(set (match_operand:SI 0 "s_register_operand" "=r, k,r,r, k,r")
675- (plus:SI (match_operand:SI 1 "s_register_operand" "%rk,k,r,rk,k,rk")
676- (match_operand:SI 2 "reg_or_int_operand" "rI,rI,k,L, L,?n")))]
677+ [(set (match_operand:SI 0 "s_register_operand" "=r, k,r,r, k, r, k,r, k, r")
678+ (plus:SI (match_operand:SI 1 "s_register_operand" "%rk,k,r,rk,k, rk,k,rk,k, rk")
679+ (match_operand:SI 2 "reg_or_int_operand" "rI,rI,k,Pj,Pj,L, L,PJ,PJ,?n")))]
680 "TARGET_32BIT"
681 "@
682 add%?\\t%0, %1, %2
683 add%?\\t%0, %1, %2
684 add%?\\t%0, %2, %1
685- sub%?\\t%0, %1, #%n2
686- sub%?\\t%0, %1, #%n2
687+ addw%?\\t%0, %1, %2
688+ addw%?\\t%0, %1, %2
689+ sub%?\\t%0, %1, #%n2
690+ sub%?\\t%0, %1, #%n2
691+ subw%?\\t%0, %1, #%n2
692+ subw%?\\t%0, %1, #%n2
693 #"
694 "TARGET_32BIT
695 && GET_CODE (operands[2]) == CONST_INT
696- && !(const_ok_for_arm (INTVAL (operands[2]))
697- || const_ok_for_arm (-INTVAL (operands[2])))
698+ && !const_ok_for_op (INTVAL (operands[2]), PLUS)
699 && (reload_completed || !arm_eliminable_register (operands[1]))"
700 [(clobber (const_int 0))]
701 "
702@@ -724,8 +727,9 @@
703 operands[1], 0);
704 DONE;
705 "
706- [(set_attr "length" "4,4,4,4,4,16")
707- (set_attr "predicable" "yes")]
708+ [(set_attr "length" "4,4,4,4,4,4,4,4,4,16")
709+ (set_attr "predicable" "yes")
710+ (set_attr "arch" "*,*,*,t2,t2,*,*,t2,t2,*")]
711 )
712
713 (define_insn_and_split "*thumb1_addsi3"
714
715=== modified file 'gcc/config/arm/constraints.md'
716--- gcc/config/arm/constraints.md 2011-01-03 20:52:22 +0000
717+++ gcc/config/arm/constraints.md 2011-08-25 13:44:32 +0000
718@@ -31,7 +31,7 @@
719 ;; The following multi-letter normal constraints have been used:
720 ;; in ARM/Thumb-2 state: Da, Db, Dc, Dn, Dl, DL, Dv, Dy, Di, Dz
721 ;; in Thumb-1 state: Pa, Pb, Pc, Pd
722-;; in Thumb-2 state: Ps, Pt, Pu, Pv, Pw, Px
723+;; in Thumb-2 state: Pj, PJ, Ps, Pt, Pu, Pv, Pw, Px
724
725 ;; The following memory constraints have been used:
726 ;; in ARM/Thumb-2 state: Q, Ut, Uv, Uy, Un, Um, Us
727@@ -74,6 +74,18 @@
728 (and (match_code "const_int")
729 (match_test "(ival & 0xffff0000) == 0")))))
730
731+(define_constraint "Pj"
732+ "@internal A 12-bit constant suitable for an ADDW or SUBW instruction. (Thumb-2)"
733+ (and (match_code "const_int")
734+ (and (match_test "TARGET_THUMB2")
735+ (match_test "(ival & 0xfffff000) == 0"))))
736+
737+(define_constraint "PJ"
738+ "@internal A constant that satisfies the Pj constrant if negated."
739+ (and (match_code "const_int")
740+ (and (match_test "TARGET_THUMB2")
741+ (match_test "((-ival) & 0xfffff000) == 0"))))
742+
743 (define_register_constraint "k" "STACK_REG"
744 "@internal The stack register.")
745
746
747=== added file 'gcc/testsuite/gcc.target/arm/thumb2-replicated-constant1.c'
748--- gcc/testsuite/gcc.target/arm/thumb2-replicated-constant1.c 1970-01-01 00:00:00 +0000
749+++ gcc/testsuite/gcc.target/arm/thumb2-replicated-constant1.c 2011-08-25 13:44:32 +0000
750@@ -0,0 +1,27 @@
751+/* Ensure simple replicated constant immediates work. */
752+/* { dg-options "-mthumb -O2" } */
753+/* { dg-require-effective-target arm_thumb2_ok } */
754+
755+int
756+foo1 (int a)
757+{
758+ return a + 0xfefefefe;
759+}
760+
761+/* { dg-final { scan-assembler "add.*#-16843010" } } */
762+
763+int
764+foo2 (int a)
765+{
766+ return a - 0xab00ab00;
767+}
768+
769+/* { dg-final { scan-assembler "sub.*#-1426019584" } } */
770+
771+int
772+foo3 (int a)
773+{
774+ return a & 0x00cd00cd;
775+}
776+
777+/* { dg-final { scan-assembler "and.*#13435085" } } */
778
779=== added file 'gcc/testsuite/gcc.target/arm/thumb2-replicated-constant2.c'
780--- gcc/testsuite/gcc.target/arm/thumb2-replicated-constant2.c 1970-01-01 00:00:00 +0000
781+++ gcc/testsuite/gcc.target/arm/thumb2-replicated-constant2.c 2011-08-25 13:44:32 +0000
782@@ -0,0 +1,75 @@
783+/* Ensure split constants can use replicated patterns. */
784+/* { dg-options "-mthumb -O2" } */
785+/* { dg-require-effective-target arm_thumb2_ok } */
786+
787+int
788+foo1 (int a)
789+{
790+ return a + 0xfe00fe01;
791+}
792+
793+/* { dg-final { scan-assembler "add.*#-33489408" } } */
794+/* { dg-final { scan-assembler "add.*#1" } } */
795+
796+int
797+foo2 (int a)
798+{
799+ return a + 0xdd01dd00;
800+}
801+
802+/* { dg-final { scan-assembler "add.*#-587145984" } } */
803+/* { dg-final { scan-assembler "add.*#65536" } } */
804+
805+int
806+foo3 (int a)
807+{
808+ return a + 0x00443344;
809+}
810+
811+/* { dg-final { scan-assembler "add.*#4456516" } } */
812+/* { dg-final { scan-assembler "add.*#13056" } } */
813+
814+int
815+foo4 (int a)
816+{
817+ return a + 0x77330033;
818+}
819+
820+/* { dg-final { scan-assembler "add.*#1996488704" } } */
821+/* { dg-final { scan-assembler "add.*#3342387" } } */
822+
823+int
824+foo5 (int a)
825+{
826+ return a + 0x11221122;
827+}
828+
829+/* { dg-final { scan-assembler "add.*#285217024" } } */
830+/* { dg-final { scan-assembler "add.*#2228258" } } */
831+
832+int
833+foo6 (int a)
834+{
835+ return a + 0x66666677;
836+}
837+
838+/* { dg-final { scan-assembler "add.*#1717986918" } } */
839+/* { dg-final { scan-assembler "add.*#17" } } */
840+
841+int
842+foo7 (int a)
843+{
844+ return a + 0x99888888;
845+}
846+
847+/* { dg-final { scan-assembler "add.*#-2004318072" } } */
848+/* { dg-final { scan-assembler "add.*#285212672" } } */
849+
850+int
851+foo8 (int a)
852+{
853+ return a + 0xdddddfff;
854+}
855+
856+/* { dg-final { scan-assembler "add.*#-572662307" } } */
857+/* { dg-final { scan-assembler "addw.*#546" } } */
858
859=== added file 'gcc/testsuite/gcc.target/arm/thumb2-replicated-constant3.c'
860--- gcc/testsuite/gcc.target/arm/thumb2-replicated-constant3.c 1970-01-01 00:00:00 +0000
861+++ gcc/testsuite/gcc.target/arm/thumb2-replicated-constant3.c 2011-08-25 13:44:32 +0000
862@@ -0,0 +1,28 @@
863+/* Ensure negated/inverted replicated constant immediates work. */
864+/* { dg-options "-mthumb -O2" } */
865+/* { dg-require-effective-target arm_thumb2_ok } */
866+
867+int
868+foo1 (int a)
869+{
870+ return a | 0xffffff00;
871+}
872+
873+/* { dg-final { scan-assembler "orn.*#255" } } */
874+
875+int
876+foo2 (int a)
877+{
878+ return a & 0xffeeffee;
879+}
880+
881+/* { dg-final { scan-assembler "bic.*#1114129" } } */
882+
883+int
884+foo3 (int a)
885+{
886+ return a & 0xaaaaaa00;
887+}
888+
889+/* { dg-final { scan-assembler "and.*#-1431655766" } } */
890+/* { dg-final { scan-assembler "bic.*#170" } } */
891
892=== added file 'gcc/testsuite/gcc.target/arm/thumb2-replicated-constant4.c'
893--- gcc/testsuite/gcc.target/arm/thumb2-replicated-constant4.c 1970-01-01 00:00:00 +0000
894+++ gcc/testsuite/gcc.target/arm/thumb2-replicated-constant4.c 2011-08-25 13:44:32 +0000
895@@ -0,0 +1,22 @@
896+/* Ensure replicated constants don't make things worse. */
897+/* { dg-options "-mthumb -O2" } */
898+/* { dg-require-effective-target arm_thumb2_ok } */
899+
900+int
901+foo1 (int a)
902+{
903+ /* It might be tempting to use 0x01000100, but it wouldn't help. */
904+ return a + 0x01f001e0;
905+}
906+
907+/* { dg-final { scan-assembler "add.*#32505856" } } */
908+/* { dg-final { scan-assembler "add.*#480" } } */
909+
910+int
911+foo2 (int a)
912+{
913+ return a + 0x0f100e10;
914+}
915+
916+/* { dg-final { scan-assembler "add.*#252706816" } } */
917+/* { dg-final { scan-assembler "add.*#3600" } } */

Subscribers

People subscribed via source and target branches