Merge lp:~ams-codesourcery/gcc-linaro/widening-multiplies-4.6 into lp:gcc-linaro/4.6
- widening-multiplies-4.6
- Merge into 4.6
Status: | Merged |
---|---|
Approved by: | Richard Sandiford |
Approved revision: | no longer in the source branch. |
Merged at revision: | 106796 |
Proposed branch: | lp:~ams-codesourcery/gcc-linaro/widening-multiplies-4.6 |
Merge into: | lp:gcc-linaro/4.6 |
Diff against target: |
1272 lines (+740/-140) (has conflicts) 20 files modified
ChangeLog.linaro (+129/-0) gcc/config/arm/arm.md (+1/-1) gcc/expr.c (+14/-15) gcc/genopinit.c (+24/-20) gcc/optabs.c (+78/-13) gcc/optabs.h (+52/-0) gcc/testsuite/gcc.target/arm/no-wmla-1.c (+11/-0) gcc/testsuite/gcc.target/arm/wmul-10.c (+10/-0) gcc/testsuite/gcc.target/arm/wmul-11.c (+10/-0) gcc/testsuite/gcc.target/arm/wmul-12.c (+11/-0) gcc/testsuite/gcc.target/arm/wmul-13.c (+10/-0) gcc/testsuite/gcc.target/arm/wmul-5.c (+10/-0) gcc/testsuite/gcc.target/arm/wmul-6.c (+10/-0) gcc/testsuite/gcc.target/arm/wmul-7.c (+10/-0) gcc/testsuite/gcc.target/arm/wmul-8.c (+10/-0) gcc/testsuite/gcc.target/arm/wmul-9.c (+10/-0) gcc/testsuite/gcc.target/arm/wmul-bitfield-1.c (+17/-0) gcc/testsuite/gcc.target/arm/wmul-bitfield-2.c (+17/-0) gcc/tree-cfg.c (+2/-2) gcc/tree-ssa-math-opts.c (+304/-89) Text conflict in ChangeLog.linaro |
To merge this branch: | bzr merge lp:~ams-codesourcery/gcc-linaro/widening-multiplies-4.6 |
Related bugs: |
Reviewer | Review Type | Date Requested | Status |
---|---|---|---|
Richard Sandiford | Approve | ||
Michael Hope | Pending | ||
Review via email:
|
This proposal supersedes a proposal from 2011-08-05.
Commit message
Description of the change
Widening multiplies optimizations.
The first commit is not approved yet, but the rest are reviewed upstream, and read to commit.
http://<email address hidden>
UPDATE: Now with an extra bug-fix.
![](/+icing/build/overlay/assets/skins/sam/images/close.gif)
Linaro Toolchain Builder (cbuild) wrote : Posted in a previous version of this proposal | # |
![](/+icing/build/overlay/assets/skins/sam/images/close.gif)
Michael Hope (michaelh1) wrote : Posted in a previous version of this proposal | # |
cbuild had trouble building this on <proposals.Build instance at 0x2b85680>.
See the *failed.txt logs under the build results at:
http://
The test suite results were not checked.
cbuild-checked: armv7l-
![](/+icing/build/overlay/assets/skins/sam/images/close.gif)
Michael Hope (michaelh1) wrote : Posted in a previous version of this proposal | # |
cbuild had trouble building this on <proposals.Build instance at 0x2141ea8>.
See the *failed.txt logs under the build results at:
http://
The test suite results were not checked.
cbuild-checked: armv7l-
![](/+icing/build/overlay/assets/skins/sam/images/close.gif)
Michael Hope (michaelh1) wrote : Posted in a previous version of this proposal | # |
cbuild had trouble building this on <proposals.Build instance at 0x7fe8f501a050>.
See the *failed.txt logs under the build results at:
http://
The test suite results were not checked.
cbuild-checked: i686-natty-
![](/+icing/build/overlay/assets/skins/sam/images/close.gif)
Michael Hope (michaelh1) wrote : Posted in a previous version of this proposal | # |
cbuild had trouble building this on <proposals.Build instance at 0x7fe8f5028ab8>.
See the *failed.txt logs under the build results at:
http://
The test suite results were not checked.
cbuild-checked: x86_64-
![](/+icing/build/overlay/assets/skins/sam/images/close.gif)
Linaro Toolchain Builder (cbuild) wrote : Posted in a previous version of this proposal | # |
cbuild has taken a snapshot of this branch at r106782 and queued it for build.
The snapshot is available at:
http://
and will be built on the following builders:
a9-builder armv5-builder i686 x86_64
You can track the build queue at:
http://
cbuild-snapshot: gcc-linaro-
cbuild-ancestor: lp:gcc-linaro/4.6+bzr106774
cbuild-state: check
![](/+icing/build/overlay/assets/skins/sam/images/close.gif)
Michael Hope (michaelh1) wrote : Posted in a previous version of this proposal | # |
cbuild had trouble building this on <proposals.Build instance at 0x3fec710>.
See the *failed.txt logs under the build results at:
http://
The test suite results were not checked.
cbuild-checked: i686-natty-
![](/+icing/build/overlay/assets/skins/sam/images/close.gif)
Michael Hope (michaelh1) wrote : Posted in a previous version of this proposal | # |
cbuild had trouble building this on <proposals.Build instance at 0x2b08c68>.
See the *failed.txt logs under the build results at:
http://
The test suite results were not checked.
cbuild-checked: x86_64-
![](/+icing/build/overlay/assets/skins/sam/images/close.gif)
Michael Hope (michaelh1) wrote : Posted in a previous version of this proposal | # |
cbuild had trouble building this on armv7l-
See the *failed.txt logs under the build results at:
http://
The test suite results were not checked.
cbuild-checked: armv7l-
![](/+icing/build/overlay/assets/skins/sam/images/close.gif)
Michael Hope (michaelh1) wrote : Posted in a previous version of this proposal | # |
cbuild had trouble building this on armv7l-
See the *failed.txt logs under the build results at:
http://
The test suite results were not checked.
cbuild-checked: armv7l-
![](/+icing/build/overlay/assets/skins/sam/images/close.gif)
Linaro Toolchain Builder (cbuild) wrote : Posted in a previous version of this proposal | # |
cbuild has taken a snapshot of this branch at r106783 and queued it for build.
The snapshot is available at:
http://
and will be built on the following builders:
a9-builder armv5-builder i686 x86_64
You can track the build queue at:
http://
cbuild-snapshot: gcc-linaro-
cbuild-ancestor: lp:gcc-linaro/4.6+bzr106774
cbuild-state: check
![](/+icing/build/overlay/assets/skins/sam/images/close.gif)
Michael Hope (michaelh1) wrote : Posted in a previous version of this proposal | # |
cbuild had trouble building this on x86_64-
See the *failed.txt logs under the build results at:
http://
The test suite results were not checked.
cbuild-checked: x86_64-
![](/+icing/build/overlay/assets/skins/sam/images/close.gif)
Michael Hope (michaelh1) wrote : Posted in a previous version of this proposal | # |
cbuild had trouble building this on i686-natty-
See the *failed.txt logs under the build results at:
http://
The test suite results were not checked.
cbuild-checked: i686-natty-
![](/+icing/build/overlay/assets/skins/sam/images/close.gif)
Michael Hope (michaelh1) wrote : Posted in a previous version of this proposal | # |
cbuild had trouble building this on armv7l-
See the *failed.txt logs under the build results at:
http://
The test suite results were not checked.
cbuild-checked: armv7l-
![](/+icing/build/overlay/assets/skins/sam/images/close.gif)
Linaro Toolchain Builder (cbuild) wrote : Posted in a previous version of this proposal | # |
cbuild has taken a snapshot of this branch at r106784 and queued it for build.
The snapshot is available at:
http://
and will be built on the following builders:
a9-builder armv5-builder i686 x86_64
You can track the build queue at:
http://
cbuild-snapshot: gcc-linaro-
cbuild-ancestor: lp:gcc-linaro/4.6+bzr106774
cbuild-state: check
![](/+icing/build/overlay/assets/skins/sam/images/close.gif)
Michael Hope (michaelh1) wrote : Posted in a previous version of this proposal | # |
cbuild successfully built this on armv7l-
The build results are available at:
http://
-PASS: gcc.c-torture/
-PASS: gcc.c-torture/
-PASS: gcc.c-torture/
-PASS: gcc.c-torture/
+FAIL: gcc.c-torture/
+FAIL: gcc.c-torture/
+FAIL: gcc.c-torture/
+FAIL: gcc.c-torture/
-PASS: gcc.c-torture/
-PASS: gcc.c-torture/
-PASS: gcc.c-torture/
-PASS: gcc.c-torture/
+UNRESOLVED: gcc.c-torture/
+UNRESOLVED: gcc.c-torture/
+UNRESOLVED: gcc.c-torture/
+UNRESOLVED: gcc.c-torture/
-PASS: gcc.dg/pr46499-1.c execution test
-PASS: gcc.dg/pr46499-1.c (test for excess errors)
+UNRESOLVED: gcc.dg/pr46499-1.c compilation failed to produce executable
+FAIL: gcc.dg/pr46499-1.c (test for excess errors)
+PASS: gcc.target/
+PASS: gcc.target/
+PASS: gcc.target/
+PASS: gcc.target/
+PASS: gcc.target/
+PASS: gcc.target/
+PASS: gcc.target/
+PASS: gcc.target/
+PASS: gcc.target/
+PASS: gcc.target/
+PASS: gcc.target/
+PASS: gcc.target/
+PASS: gcc.target/
+PASS: gcc.target/
+PASS: gcc.target/
+PASS: gcc.target/
+PASS: gcc.target/
+PASS: gcc.target/
+PASS: gcc.target/
+PASS: gcc.target/
+PASS: gcc.target/
+PAS...
![](/+icing/build/overlay/assets/skins/sam/images/close.gif)
Michael Hope (michaelh1) wrote : Posted in a previous version of this proposal | # |
cbuild had trouble building this on i686-natty-
See the *failed.txt logs under the build results at:
http://
The test suite results were not checked.
cbuild-checked: i686-natty-
![](/+icing/build/overlay/assets/skins/sam/images/close.gif)
Michael Hope (michaelh1) wrote : Posted in a previous version of this proposal | # |
cbuild had trouble building this on x86_64-
See the *failed.txt logs under the build results at:
http://
The test suite results were not checked.
cbuild-checked: x86_64-
![](/+icing/build/overlay/assets/skins/sam/images/close.gif)
Michael Hope (michaelh1) wrote : Posted in a previous version of this proposal | # |
cbuild had trouble building this on x86_64-
See the *failed.txt logs under the build results at:
http://
The test suite results were not checked.
cbuild-checked: x86_64-
![](/+icing/build/overlay/assets/skins/sam/images/close.gif)
Linaro Toolchain Builder (cbuild) wrote : Posted in a previous version of this proposal | # |
cbuild has taken a snapshot of this branch at r106785 and queued it for build.
The snapshot is available at:
http://
and will be built on the following builders:
a9-builder armv5-builder i686 x86_64
You can track the build queue at:
http://
cbuild-snapshot: gcc-linaro-
cbuild-ancestor: lp:gcc-linaro/4.6+bzr106774
cbuild-state: check
![](/+icing/build/overlay/assets/skins/sam/images/close.gif)
Michael Hope (michaelh1) wrote : Posted in a previous version of this proposal | # |
cbuild successfully built this on armv7l-
The build results are available at:
http://
-PASS: gcc.c-torture/
-PASS: gcc.c-torture/
-PASS: gcc.c-torture/
-PASS: gcc.c-torture/
+FAIL: gcc.c-torture/
+FAIL: gcc.c-torture/
+FAIL: gcc.c-torture/
+FAIL: gcc.c-torture/
-PASS: gcc.c-torture/
-PASS: gcc.c-torture/
-PASS: gcc.c-torture/
-PASS: gcc.c-torture/
+UNRESOLVED: gcc.c-torture/
+UNRESOLVED: gcc.c-torture/
+UNRESOLVED: gcc.c-torture/
+UNRESOLVED: gcc.c-torture/
+PASS: gcc.target/
+PASS: gcc.target/
+PASS: gcc.target/
+PASS: gcc.target/
+PASS: gcc.target/
+PASS: gcc.target/
+PASS: gcc.target/
+PASS: gcc.target/
+PASS: gcc.target/
+PASS: gcc.target/
+PASS: gcc.target/
+PASS: gcc.target/
+PASS: gcc.target/
+PASS: gcc.target/
+PASS: gcc.target/
+PASS: gcc.target/
+PASS: gcc.target/
+PASS: gcc.target/
+PASS: gcc.target/
+PASS: gcc.target/
+PASS: gcc.target/
+PASS: gcc.target/
+PASS: gcc.target/
+PASS: gcc.target/
-PASS: gfortran.
![](/+icing/build/overlay/assets/skins/sam/images/close.gif)
Michael Hope (michaelh1) wrote : Posted in a previous version of this proposal | # |
cbuild successfully built this on armv7l-
The build results are available at:
http://
-PASS: gcc.c-torture/
-PASS: gcc.c-torture/
-PASS: gcc.c-torture/
-PASS: gcc.c-torture/
+FAIL: gcc.c-torture/
+FAIL: gcc.c-torture/
+FAIL: gcc.c-torture/
+FAIL: gcc.c-torture/
-PASS: gcc.c-torture/
-PASS: gcc.c-torture/
-PASS: gcc.c-torture/
-PASS: gcc.c-torture/
+UNRESOLVED: gcc.c-torture/
+UNRESOLVED: gcc.c-torture/
+UNRESOLVED: gcc.c-torture/
+UNRESOLVED: gcc.c-torture/
+PASS: gcc.target/
+PASS: gcc.target/
+PASS: gcc.target/
+PASS: gcc.target/
+PASS: gcc.target/
+PASS: gcc.target/
+PASS: gcc.target/
+PASS: gcc.target/
+PASS: gcc.target/
+PASS: gcc.target/
+PASS: gcc.target/
+PASS: gcc.target/
+PASS: gcc.target/
+PASS: gcc.target/
+PASS: gcc.target/
+PASS: gcc.target/
+PASS: gcc.target/
+PASS: gcc.target/
+PASS: gcc.target/
+PASS: gcc.target/
+PASS: gcc.target/
+PASS: gcc.target/
+PASS: gcc.target/
+PASS: gcc.target/
-PASS: gfortran.
![](/+icing/build/overlay/assets/skins/sam/images/close.gif)
Michael Hope (michaelh1) wrote : Posted in a previous version of this proposal | # |
cbuild successfully built this on i686-natty-
The build results are available at:
http://
-PASS: gfortran.
-PASS: gfortran.
+FAIL: gfortran.
+FAIL: gfortran.
+UNRESOLVED: gfortran.
-PASS: gfortran.
-PASS: gfortran.
+FAIL: gfortran.
+FAIL: gfortran.
+UNRESOLVED: gfortran.
-PASS: gfortran.
-PASS: gfortran.
+FAIL: gfortran.
+FAIL: gfortran.
+UNRESOLVED: gfortran.
-PASS: gfortran.
-PASS: gfortran.
+FAIL: gfortran.
+FAIL: gfortran.
+UNRESOLVED: gfortran.
-PASS: gfortran.
-PASS: gfortran.
+FAIL: gfortran.
+FAIL: gfortran.
+UNRESOLVED: gfortran.
The full testsuite results are at:
http://
cbuild-checked: i686-natty-
![](/+icing/build/overlay/assets/skins/sam/images/close.gif)
Michael Hope (michaelh1) wrote : Posted in a previous version of this proposal | # |
cbuild successfully built this on x86_64-
The build results are available at:
http://
The testsuite results are the same as the branch point lp:gcc-linaro/4.6+bzr106774
The full testsuite results are at:
http://
cbuild-checked: x86_64-
![](/+icing/build/overlay/assets/skins/sam/images/close.gif)
Michael Hope (michaelh1) wrote : Posted in a previous version of this proposal | # |
Note that the tests pass on a 64 bit host but fail on all 32 bit hosts.
![](/+icing/build/overlay/assets/skins/sam/images/close.gif)
Linaro Toolchain Builder (cbuild) wrote : | # |
cbuild has taken a snapshot of this branch at r106787 and queued it for build.
The snapshot is available at:
http://
and will be built on the following builders:
a9-builder armv5-builder i686 x86_64
You can track the build queue at:
http://
cbuild-snapshot: gcc-linaro-
cbuild-ancestor: lp:gcc-linaro/4.6+bzr106774
cbuild-state: check
![](/+icing/build/overlay/assets/skins/sam/images/close.gif)
Michael Hope (michaelh1) wrote : | # |
cbuild successfully built this on x86_64-
The build results are available at:
http://
The testsuite results are the same as the branch point lp:gcc-linaro/4.6+bzr106774
The full testsuite results are at:
http://
cbuild-checked: x86_64-
![](/+icing/build/overlay/assets/skins/sam/images/close.gif)
Michael Hope (michaelh1) wrote : | # |
cbuild successfully built this on i686-natty-
The build results are available at:
http://
The testsuite results are the same as the branch point lp:gcc-linaro/4.6+bzr106774
The full testsuite results are at:
http://
cbuild-checked: i686-natty-
![](/+icing/build/overlay/assets/skins/sam/images/close.gif)
Michael Hope (michaelh1) wrote : | # |
cbuild successfully built this on armv7l-
The build results are available at:
http://
+PASS: gcc.target/
+PASS: gcc.target/
+PASS: gcc.target/
+PASS: gcc.target/
+PASS: gcc.target/
+PASS: gcc.target/
+PASS: gcc.target/
+PASS: gcc.target/
+PASS: gcc.target/
+PASS: gcc.target/
+PASS: gcc.target/
+PASS: gcc.target/
+PASS: gcc.target/
+PASS: gcc.target/
+PASS: gcc.target/
+PASS: gcc.target/
+PASS: gcc.target/
+PASS: gcc.target/
+PASS: gcc.target/
+PASS: gcc.target/
+PASS: gcc.target/
+PASS: gcc.target/
+PASS: gcc.target/
+PASS: gcc.target/
The full testsuite results are at:
http://
cbuild-checked: armv7l-
![](/+icing/build/overlay/assets/skins/sam/images/close.gif)
Michael Hope (michaelh1) wrote : | # |
cbuild successfully built this on armv7l-
The build results are available at:
http://
+PASS: gcc.target/
+PASS: gcc.target/
+PASS: gcc.target/
+PASS: gcc.target/
+PASS: gcc.target/
+PASS: gcc.target/
+PASS: gcc.target/
+PASS: gcc.target/
+PASS: gcc.target/
+PASS: gcc.target/
+PASS: gcc.target/
+PASS: gcc.target/
+PASS: gcc.target/
+PASS: gcc.target/
+PASS: gcc.target/
+PASS: gcc.target/
+PASS: gcc.target/
+PASS: gcc.target/
+PASS: gcc.target/
+PASS: gcc.target/
+PASS: gcc.target/
+PASS: gcc.target/
+PASS: gcc.target/
+PASS: gcc.target/
The full testsuite results are at:
http://
cbuild-checked: armv7l-
![](/+icing/build/overlay/assets/skins/sam/images/close.gif)
Ramana Radhakrishnan (ramana) wrote : | # |
Could you point me at the one set of patches that were finally accepted upstream ?
Also, is that one extra bug fix that you say at the top in FSF trunk upstream ?
Ramana
![](/+icing/build/overlay/assets/skins/sam/images/close.gif)
Andrew Stubbs (ams-codesourcery) wrote : | # |
The patches are not yet committed upstream. The accepted versions of the patches are in the thread on the gcc-patches@ list, but I have not yet posted the bug-fixed versions.
Here are the originals:
http://
http://
http://
http://
http://
http://
http://
http://
http://
I do not expect them to require further approval. I plan to do some tests on the 4.7 baseline, and then commit the patches and post the new versions with updated context and bug fixes, where they have changed.
![](/+icing/build/overlay/assets/skins/sam/images/close.gif)
Ramana Radhakrishnan (ramana) wrote : | # |
I had a quick look through them - the patches that have been committed upstream have been committed slightly different to the revisions here which makes a complete review a bit harder. Also given that there is a bit of churn because of backport conflicts doing a full review is harder in this case.
The testresults look OK. Given I'm not on review duty this week I don't have more time to spend on this.
Ramana
Preview Diff
1 | === modified file 'ChangeLog.linaro' | |||
2 | --- ChangeLog.linaro 2011-08-10 23:03:03 +0000 | |||
3 | +++ ChangeLog.linaro 2011-08-11 16:16:07 +0000 | |||
4 | @@ -1,3 +1,4 @@ | |||
5 | 1 | <<<<<<< TREE | ||
6 | 1 | 2011-08-11 Ramana Radhakrishnan <ramana.radhakrishnan@linaro.org> | 2 | 2011-08-11 Ramana Radhakrishnan <ramana.radhakrishnan@linaro.org> |
7 | 2 | 3 | ||
8 | 3 | gcc/ | 4 | gcc/ |
9 | @@ -185,6 +186,134 @@ | |||
10 | 185 | 186 | ||
11 | 186 | * gcc.c-torture/compile/20110401-1.c: New test. | 187 | * gcc.c-torture/compile/20110401-1.c: New test. |
12 | 187 | 188 | ||
13 | 189 | ======= | ||
14 | 190 | 2011-08-05 Andrew Stubbs <ams@codesourcery.com> | ||
15 | 191 | |||
16 | 192 | Backport from patches proposed for 4.7: | ||
17 | 193 | |||
18 | 194 | 2011-07-22 Andrew Stubbs <ams@codesourcery.com> | ||
19 | 195 | |||
20 | 196 | gcc/ | ||
21 | 197 | * tree-ssa-math-opts.c (is_widening_mult_rhs_p): Handle constants | ||
22 | 198 | beyond conversions. | ||
23 | 199 | (convert_mult_to_widen): Convert constant inputs to the right type. | ||
24 | 200 | (convert_plusminus_to_widen): Don't automatically reject inputs that | ||
25 | 201 | are not an SSA_NAME. | ||
26 | 202 | Convert constant inputs to the right type. | ||
27 | 203 | |||
28 | 204 | gcc/testsuite/ | ||
29 | 205 | * gcc.target/arm/wmul-11.c: New file. | ||
30 | 206 | * gcc.target/arm/wmul-12.c: New file. | ||
31 | 207 | * gcc.target/arm/wmul-13.c: New file. | ||
32 | 208 | |||
33 | 209 | 2011-07-21 Andrew Stubbs <ams@codesourcery.com> | ||
34 | 210 | |||
35 | 211 | gcc/ | ||
36 | 212 | * tree-ssa-math-opts.c (convert_plusminus_to_widen): Convert add_rhs | ||
37 | 213 | to the correct type. | ||
38 | 214 | |||
39 | 215 | gcc/testsuite/ | ||
40 | 216 | * gcc.target/arm/wmul-10.c: New file. | ||
41 | 217 | |||
42 | 218 | 2011-06-24 Andrew Stubbs <ams@codesourcery.com> | ||
43 | 219 | |||
44 | 220 | gcc/ | ||
45 | 221 | * tree-ssa-math-opts.c (convert_mult_to_widen): Better handle | ||
46 | 222 | unsigned inputs of different modes. | ||
47 | 223 | (convert_plusminus_to_widen): Likewise. | ||
48 | 224 | |||
49 | 225 | gcc/testsuite/ | ||
50 | 226 | * gcc.target/arm/wmul-9.c: New file. | ||
51 | 227 | * gcc.target/arm/wmul-bitfield-2.c: New file. | ||
52 | 228 | |||
53 | 229 | 2011-07-14 Andrew Stubbs <ams@codesourcery.com> | ||
54 | 230 | |||
55 | 231 | gcc/ | ||
56 | 232 | * tree-ssa-math-opts.c (is_widening_mult_rhs_p): Add new argument | ||
57 | 233 | 'type'. | ||
58 | 234 | Use 'type' from caller, not inferred from 'rhs'. | ||
59 | 235 | Don't reject non-conversion statements. Do return lhs in this case. | ||
60 | 236 | (is_widening_mult_p): Add new argument 'type'. | ||
61 | 237 | Use 'type' from caller, not inferred from 'stmt'. | ||
62 | 238 | Pass type to is_widening_mult_rhs_p. | ||
63 | 239 | (convert_mult_to_widen): Pass type to is_widening_mult_p. | ||
64 | 240 | (convert_plusminus_to_widen): Likewise. | ||
65 | 241 | |||
66 | 242 | gcc/testsuite/ | ||
67 | 243 | * gcc.target/arm/wmul-8.c: New file. | ||
68 | 244 | |||
69 | 245 | 2011-07-14 Andrew Stubbs <ams@codesourcery.com> | ||
70 | 246 | |||
71 | 247 | gcc/ | ||
72 | 248 | * tree-ssa-math-opts.c (is_widening_mult_p): Remove FIXME. | ||
73 | 249 | Ensure the the larger type is the first operand. | ||
74 | 250 | |||
75 | 251 | gcc/testsuite/ | ||
76 | 252 | * gcc.target/arm/wmul-7.c: New file. | ||
77 | 253 | |||
78 | 254 | 2011-07-14 Andrew Stubbs <ams@codesourcery.com> | ||
79 | 255 | |||
80 | 256 | gcc/ | ||
81 | 257 | * tree-ssa-math-opts.c (convert_mult_to_widen): Convert | ||
82 | 258 | unsupported unsigned multiplies to signed. | ||
83 | 259 | (convert_plusminus_to_widen): Likewise. | ||
84 | 260 | |||
85 | 261 | gcc/testsuite/ | ||
86 | 262 | * gcc.target/arm/wmul-6.c: New file. | ||
87 | 263 | |||
88 | 264 | 2011-07-14 Andrew Stubbs <ams@codesourcery.com> | ||
89 | 265 | |||
90 | 266 | gcc/ | ||
91 | 267 | * tree-ssa-math-opts.c (convert_plusminus_to_widen): Permit a single | ||
92 | 268 | conversion statement separating multiply-and-accumulate. | ||
93 | 269 | |||
94 | 270 | gcc/testsuite/ | ||
95 | 271 | * gcc.target/arm/wmul-5.c: New file. | ||
96 | 272 | * gcc.target/arm/no-wmla-1.c: New file. | ||
97 | 273 | |||
98 | 274 | 2011-07-27 Andrew Stubbs <ams@codesourcery.com> | ||
99 | 275 | |||
100 | 276 | gcc/ | ||
101 | 277 | * config/arm/arm.md (maddhidi4): Remove '*' from name. | ||
102 | 278 | * expr.c (expand_expr_real_2): Use find_widening_optab_handler. | ||
103 | 279 | * optabs.c (find_widening_optab_handler_and_mode): New function. | ||
104 | 280 | (expand_widen_pattern_expr): Use find_widening_optab_handler. | ||
105 | 281 | (expand_binop_directly): Likewise. | ||
106 | 282 | (expand_binop): Likewise. | ||
107 | 283 | * optabs.h (find_widening_optab_handler): New macro define. | ||
108 | 284 | (find_widening_optab_handler_and_mode): New prototype. | ||
109 | 285 | * tree-cfg.c (verify_gimple_assign_binary): Adjust WIDEN_MULT_EXPR | ||
110 | 286 | type precision rules. | ||
111 | 287 | (verify_gimple_assign_ternary): Likewise for WIDEN_MULT_PLUS_EXPR. | ||
112 | 288 | * tree-ssa-math-opts.c (build_and_insert_cast): New function. | ||
113 | 289 | (is_widening_mult_rhs_p): Allow widening by more than one mode. | ||
114 | 290 | Explicitly disallow mis-matched input types. | ||
115 | 291 | (convert_mult_to_widen): Use find_widening_optab_handler, and cast | ||
116 | 292 | input types to fit the new handler. | ||
117 | 293 | (convert_plusminus_to_widen): Likewise. | ||
118 | 294 | |||
119 | 295 | gcc/testsuite/ | ||
120 | 296 | * gcc.target/arm/wmul-bitfield-1.c: New file. | ||
121 | 297 | |||
122 | 298 | 2011-07-27 Andrew Stubbs <ams@codesourcery.com> | ||
123 | 299 | |||
124 | 300 | gcc/ | ||
125 | 301 | * expr.c (expand_expr_real_2): Use widening_optab_handler. | ||
126 | 302 | * genopinit.c (optabs): Use set_widening_optab_handler for $N. | ||
127 | 303 | (gen_insn): $N now means $a must be wider than $b, not consecutive. | ||
128 | 304 | * optabs.c (widened_mode): New function. | ||
129 | 305 | (expand_widen_pattern_expr): Use widening_optab_handler. | ||
130 | 306 | (expand_binop_directly): Likewise. | ||
131 | 307 | (expand_binop): Likewise. | ||
132 | 308 | * optabs.h (widening_optab_handlers): New struct. | ||
133 | 309 | (optab_d): New member, 'widening'. | ||
134 | 310 | (widening_optab_handler): New function. | ||
135 | 311 | (set_widening_optab_handler): New function. | ||
136 | 312 | * tree-ssa-math-opts.c (convert_mult_to_widen): Use | ||
137 | 313 | widening_optab_handler. | ||
138 | 314 | (convert_plusminus_to_widen): Likewise. | ||
139 | 315 | |||
140 | 316 | >>>>>>> MERGE-SOURCE | ||
141 | 188 | 2011-07-13 Richard Sandiford <richard.sandiford@linaro.org> | 317 | 2011-07-13 Richard Sandiford <richard.sandiford@linaro.org> |
142 | 189 | 318 | ||
143 | 190 | Backport from mainline: | 319 | Backport from mainline: |
144 | 191 | 320 | ||
145 | === modified file 'gcc/config/arm/arm.md' | |||
146 | --- gcc/config/arm/arm.md 2011-06-28 12:02:27 +0000 | |||
147 | +++ gcc/config/arm/arm.md 2011-08-11 16:16:07 +0000 | |||
148 | @@ -1839,7 +1839,7 @@ | |||
149 | 1839 | (set_attr "predicable" "yes")] | 1839 | (set_attr "predicable" "yes")] |
150 | 1840 | ) | 1840 | ) |
151 | 1841 | 1841 | ||
153 | 1842 | (define_insn "*maddhidi4" | 1842 | (define_insn "maddhidi4" |
154 | 1843 | [(set (match_operand:DI 0 "s_register_operand" "=r") | 1843 | [(set (match_operand:DI 0 "s_register_operand" "=r") |
155 | 1844 | (plus:DI | 1844 | (plus:DI |
156 | 1845 | (mult:DI (sign_extend:DI | 1845 | (mult:DI (sign_extend:DI |
157 | 1846 | 1846 | ||
158 | === modified file 'gcc/expr.c' | |||
159 | --- gcc/expr.c 2011-07-14 11:52:32 +0000 | |||
160 | +++ gcc/expr.c 2011-08-11 16:16:07 +0000 | |||
161 | @@ -7680,18 +7680,16 @@ | |||
162 | 7680 | { | 7680 | { |
163 | 7681 | enum machine_mode innermode = TYPE_MODE (TREE_TYPE (treeop0)); | 7681 | enum machine_mode innermode = TYPE_MODE (TREE_TYPE (treeop0)); |
164 | 7682 | this_optab = usmul_widen_optab; | 7682 | this_optab = usmul_widen_optab; |
166 | 7683 | if (mode == GET_MODE_2XWIDER_MODE (innermode)) | 7683 | if (find_widening_optab_handler (this_optab, mode, innermode, 0) |
167 | 7684 | != CODE_FOR_nothing) | ||
168 | 7684 | { | 7685 | { |
179 | 7685 | if (optab_handler (this_optab, mode) != CODE_FOR_nothing) | 7686 | if (TYPE_UNSIGNED (TREE_TYPE (treeop0))) |
180 | 7686 | { | 7687 | expand_operands (treeop0, treeop1, NULL_RTX, &op0, &op1, |
181 | 7687 | if (TYPE_UNSIGNED (TREE_TYPE (treeop0))) | 7688 | EXPAND_NORMAL); |
182 | 7688 | expand_operands (treeop0, treeop1, NULL_RTX, &op0, &op1, | 7689 | else |
183 | 7689 | EXPAND_NORMAL); | 7690 | expand_operands (treeop0, treeop1, NULL_RTX, &op1, &op0, |
184 | 7690 | else | 7691 | EXPAND_NORMAL); |
185 | 7691 | expand_operands (treeop0, treeop1, NULL_RTX, &op1, &op0, | 7692 | goto binop3; |
176 | 7692 | EXPAND_NORMAL); | ||
177 | 7693 | goto binop3; | ||
178 | 7694 | } | ||
186 | 7695 | } | 7693 | } |
187 | 7696 | } | 7694 | } |
188 | 7697 | /* Check for a multiplication with matching signedness. */ | 7695 | /* Check for a multiplication with matching signedness. */ |
189 | @@ -7706,10 +7704,10 @@ | |||
190 | 7706 | optab other_optab = zextend_p ? smul_widen_optab : umul_widen_optab; | 7704 | optab other_optab = zextend_p ? smul_widen_optab : umul_widen_optab; |
191 | 7707 | this_optab = zextend_p ? umul_widen_optab : smul_widen_optab; | 7705 | this_optab = zextend_p ? umul_widen_optab : smul_widen_optab; |
192 | 7708 | 7706 | ||
195 | 7709 | if (mode == GET_MODE_2XWIDER_MODE (innermode) | 7707 | if (TREE_CODE (treeop0) != INTEGER_CST) |
194 | 7710 | && TREE_CODE (treeop0) != INTEGER_CST) | ||
196 | 7711 | { | 7708 | { |
198 | 7712 | if (optab_handler (this_optab, mode) != CODE_FOR_nothing) | 7709 | if (find_widening_optab_handler (this_optab, mode, innermode, 0) |
199 | 7710 | != CODE_FOR_nothing) | ||
200 | 7713 | { | 7711 | { |
201 | 7714 | expand_operands (treeop0, treeop1, NULL_RTX, &op0, &op1, | 7712 | expand_operands (treeop0, treeop1, NULL_RTX, &op0, &op1, |
202 | 7715 | EXPAND_NORMAL); | 7713 | EXPAND_NORMAL); |
203 | @@ -7717,7 +7715,8 @@ | |||
204 | 7717 | unsignedp, this_optab); | 7715 | unsignedp, this_optab); |
205 | 7718 | return REDUCE_BIT_FIELD (temp); | 7716 | return REDUCE_BIT_FIELD (temp); |
206 | 7719 | } | 7717 | } |
208 | 7720 | if (optab_handler (other_optab, mode) != CODE_FOR_nothing | 7718 | if (find_widening_optab_handler (other_optab, mode, innermode, 0) |
209 | 7719 | != CODE_FOR_nothing | ||
210 | 7721 | && innermode == word_mode) | 7720 | && innermode == word_mode) |
211 | 7722 | { | 7721 | { |
212 | 7723 | rtx htem, hipart; | 7722 | rtx htem, hipart; |
213 | 7724 | 7723 | ||
214 | === modified file 'gcc/genopinit.c' | |||
215 | --- gcc/genopinit.c 2011-05-05 15:43:06 +0000 | |||
216 | +++ gcc/genopinit.c 2011-08-11 16:16:07 +0000 | |||
217 | @@ -46,10 +46,12 @@ | |||
218 | 46 | used. $A and $B are replaced with the full name of the mode; $a and $b | 46 | used. $A and $B are replaced with the full name of the mode; $a and $b |
219 | 47 | are replaced with the short form of the name, as above. | 47 | are replaced with the short form of the name, as above. |
220 | 48 | 48 | ||
225 | 49 | If $N is present in the pattern, it means the two modes must be consecutive | 49 | If $N is present in the pattern, it means the two modes must be in |
226 | 50 | widths in the same mode class (e.g, QImode and HImode). $I means that | 50 | the same mode class, and $b must be greater than $a (e.g, QImode |
227 | 51 | only full integer modes should be considered for the next mode, and $F | 51 | and HImode). |
228 | 52 | means that only float modes should be considered. | 52 | |
229 | 53 | $I means that only full integer modes should be considered for the | ||
230 | 54 | next mode, and $F means that only float modes should be considered. | ||
231 | 53 | $P means that both full and partial integer modes should be considered. | 55 | $P means that both full and partial integer modes should be considered. |
232 | 54 | $Q means that only fixed-point modes should be considered. | 56 | $Q means that only fixed-point modes should be considered. |
233 | 55 | 57 | ||
234 | @@ -99,17 +101,17 @@ | |||
235 | 99 | "set_optab_handler (smulv_optab, $A, CODE_FOR_$(mulv$I$a3$))", | 101 | "set_optab_handler (smulv_optab, $A, CODE_FOR_$(mulv$I$a3$))", |
236 | 100 | "set_optab_handler (umul_highpart_optab, $A, CODE_FOR_$(umul$a3_highpart$))", | 102 | "set_optab_handler (umul_highpart_optab, $A, CODE_FOR_$(umul$a3_highpart$))", |
237 | 101 | "set_optab_handler (smul_highpart_optab, $A, CODE_FOR_$(smul$a3_highpart$))", | 103 | "set_optab_handler (smul_highpart_optab, $A, CODE_FOR_$(smul$a3_highpart$))", |
249 | 102 | "set_optab_handler (smul_widen_optab, $B, CODE_FOR_$(mul$a$b3$)$N)", | 104 | "set_widening_optab_handler (smul_widen_optab, $B, $A, CODE_FOR_$(mul$a$b3$)$N)", |
250 | 103 | "set_optab_handler (umul_widen_optab, $B, CODE_FOR_$(umul$a$b3$)$N)", | 105 | "set_widening_optab_handler (umul_widen_optab, $B, $A, CODE_FOR_$(umul$a$b3$)$N)", |
251 | 104 | "set_optab_handler (usmul_widen_optab, $B, CODE_FOR_$(usmul$a$b3$)$N)", | 106 | "set_widening_optab_handler (usmul_widen_optab, $B, $A, CODE_FOR_$(usmul$a$b3$)$N)", |
252 | 105 | "set_optab_handler (smadd_widen_optab, $B, CODE_FOR_$(madd$a$b4$)$N)", | 107 | "set_widening_optab_handler (smadd_widen_optab, $B, $A, CODE_FOR_$(madd$a$b4$)$N)", |
253 | 106 | "set_optab_handler (umadd_widen_optab, $B, CODE_FOR_$(umadd$a$b4$)$N)", | 108 | "set_widening_optab_handler (umadd_widen_optab, $B, $A, CODE_FOR_$(umadd$a$b4$)$N)", |
254 | 107 | "set_optab_handler (ssmadd_widen_optab, $B, CODE_FOR_$(ssmadd$a$b4$)$N)", | 109 | "set_widening_optab_handler (ssmadd_widen_optab, $B, $A, CODE_FOR_$(ssmadd$a$b4$)$N)", |
255 | 108 | "set_optab_handler (usmadd_widen_optab, $B, CODE_FOR_$(usmadd$a$b4$)$N)", | 110 | "set_widening_optab_handler (usmadd_widen_optab, $B, $A, CODE_FOR_$(usmadd$a$b4$)$N)", |
256 | 109 | "set_optab_handler (smsub_widen_optab, $B, CODE_FOR_$(msub$a$b4$)$N)", | 111 | "set_widening_optab_handler (smsub_widen_optab, $B, $A, CODE_FOR_$(msub$a$b4$)$N)", |
257 | 110 | "set_optab_handler (umsub_widen_optab, $B, CODE_FOR_$(umsub$a$b4$)$N)", | 112 | "set_widening_optab_handler (umsub_widen_optab, $B, $A, CODE_FOR_$(umsub$a$b4$)$N)", |
258 | 111 | "set_optab_handler (ssmsub_widen_optab, $B, CODE_FOR_$(ssmsub$a$b4$)$N)", | 113 | "set_widening_optab_handler (ssmsub_widen_optab, $B, $A, CODE_FOR_$(ssmsub$a$b4$)$N)", |
259 | 112 | "set_optab_handler (usmsub_widen_optab, $B, CODE_FOR_$(usmsub$a$b4$)$N)", | 114 | "set_widening_optab_handler (usmsub_widen_optab, $B, $A, CODE_FOR_$(usmsub$a$b4$)$N)", |
260 | 113 | "set_optab_handler (sdiv_optab, $A, CODE_FOR_$(div$a3$))", | 115 | "set_optab_handler (sdiv_optab, $A, CODE_FOR_$(div$a3$))", |
261 | 114 | "set_optab_handler (ssdiv_optab, $A, CODE_FOR_$(ssdiv$Q$a3$))", | 116 | "set_optab_handler (ssdiv_optab, $A, CODE_FOR_$(ssdiv$Q$a3$))", |
262 | 115 | "set_optab_handler (sdivv_optab, $A, CODE_FOR_$(div$V$I$a3$))", | 117 | "set_optab_handler (sdivv_optab, $A, CODE_FOR_$(div$V$I$a3$))", |
263 | @@ -304,7 +306,7 @@ | |||
264 | 304 | { | 306 | { |
265 | 305 | int force_float = 0, force_int = 0, force_partial_int = 0; | 307 | int force_float = 0, force_int = 0, force_partial_int = 0; |
266 | 306 | int force_fixed = 0; | 308 | int force_fixed = 0; |
268 | 307 | int force_consec = 0; | 309 | int force_wider = 0; |
269 | 308 | int matches = 1; | 310 | int matches = 1; |
270 | 309 | 311 | ||
271 | 310 | for (pp = optabs[pindex]; pp[0] != '$' || pp[1] != '('; pp++) | 312 | for (pp = optabs[pindex]; pp[0] != '$' || pp[1] != '('; pp++) |
272 | @@ -322,7 +324,7 @@ | |||
273 | 322 | switch (*++pp) | 324 | switch (*++pp) |
274 | 323 | { | 325 | { |
275 | 324 | case 'N': | 326 | case 'N': |
277 | 325 | force_consec = 1; | 327 | force_wider = 1; |
278 | 326 | break; | 328 | break; |
279 | 327 | case 'I': | 329 | case 'I': |
280 | 328 | force_int = 1; | 330 | force_int = 1; |
281 | @@ -391,7 +393,10 @@ | |||
282 | 391 | || mode_class[i] == MODE_VECTOR_FRACT | 393 | || mode_class[i] == MODE_VECTOR_FRACT |
283 | 392 | || mode_class[i] == MODE_VECTOR_UFRACT | 394 | || mode_class[i] == MODE_VECTOR_UFRACT |
284 | 393 | || mode_class[i] == MODE_VECTOR_ACCUM | 395 | || mode_class[i] == MODE_VECTOR_ACCUM |
286 | 394 | || mode_class[i] == MODE_VECTOR_UACCUM)) | 396 | || mode_class[i] == MODE_VECTOR_UACCUM) |
287 | 397 | && (! force_wider | ||
288 | 398 | || *pp == 'a' | ||
289 | 399 | || m1 < i)) | ||
290 | 395 | break; | 400 | break; |
291 | 396 | } | 401 | } |
292 | 397 | 402 | ||
293 | @@ -411,8 +416,7 @@ | |||
294 | 411 | } | 416 | } |
295 | 412 | 417 | ||
296 | 413 | if (matches && pp[0] == '$' && pp[1] == ')' | 418 | if (matches && pp[0] == '$' && pp[1] == ')' |
299 | 414 | && *np == 0 | 419 | && *np == 0) |
298 | 415 | && (! force_consec || (int) GET_MODE_WIDER_MODE(m1) == m2)) | ||
300 | 416 | break; | 420 | break; |
301 | 417 | } | 421 | } |
302 | 418 | 422 | ||
303 | 419 | 423 | ||
304 | === modified file 'gcc/optabs.c' | |||
305 | --- gcc/optabs.c 2011-07-04 14:03:49 +0000 | |||
306 | +++ gcc/optabs.c 2011-08-11 16:16:07 +0000 | |||
307 | @@ -225,6 +225,61 @@ | |||
308 | 225 | return 1; | 225 | return 1; |
309 | 226 | } | 226 | } |
310 | 227 | 227 | ||
311 | 228 | 228 | ||
312 | 229 | /* Given two input operands, OP0 and OP1, determine what the correct from_mode | ||
313 | 230 | for a widening operation would be. In most cases this would be OP0, but if | ||
314 | 231 | that's a constant it'll be VOIDmode, which isn't useful. */ | ||
315 | 232 | |||
316 | 233 | static enum machine_mode | ||
317 | 234 | widened_mode (enum machine_mode to_mode, rtx op0, rtx op1) | ||
318 | 235 | { | ||
319 | 236 | enum machine_mode m0 = GET_MODE (op0); | ||
320 | 237 | enum machine_mode m1 = GET_MODE (op1); | ||
321 | 238 | enum machine_mode result; | ||
322 | 239 | |||
323 | 240 | if (m0 == VOIDmode && m1 == VOIDmode) | ||
324 | 241 | return to_mode; | ||
325 | 242 | else if (m0 == VOIDmode || GET_MODE_SIZE (m0) < GET_MODE_SIZE (m1)) | ||
326 | 243 | result = m1; | ||
327 | 244 | else | ||
328 | 245 | result = m0; | ||
329 | 246 | |||
330 | 247 | if (GET_MODE_SIZE (result) > GET_MODE_SIZE (to_mode)) | ||
331 | 248 | return to_mode; | ||
332 | 249 | |||
333 | 250 | return result; | ||
334 | 251 | } | ||
335 | 252 | |||
336 | 229 | 253 | ||
337 | 254 | /* Find a widening optab even if it doesn't widen as much as we want. | ||
338 | 255 | E.g. if from_mode is HImode, and to_mode is DImode, and there is no | ||
339 | 256 | direct HI->SI insn, then return SI->DI, if that exists. | ||
340 | 257 | If PERMIT_NON_WIDENING is non-zero then this can be used with | ||
341 | 258 | non-widening optabs also. */ | ||
342 | 259 | |||
343 | 260 | enum insn_code | ||
344 | 261 | find_widening_optab_handler_and_mode (optab op, enum machine_mode to_mode, | ||
345 | 262 | enum machine_mode from_mode, | ||
346 | 263 | int permit_non_widening, | ||
347 | 264 | enum machine_mode *found_mode) | ||
348 | 265 | { | ||
349 | 266 | for (; (permit_non_widening || from_mode != to_mode) | ||
350 | 267 | && GET_MODE_SIZE (from_mode) <= GET_MODE_SIZE (to_mode) | ||
351 | 268 | && from_mode != VOIDmode; | ||
352 | 269 | from_mode = GET_MODE_WIDER_MODE (from_mode)) | ||
353 | 270 | { | ||
354 | 271 | enum insn_code handler = widening_optab_handler (op, to_mode, | ||
355 | 272 | from_mode); | ||
356 | 273 | |||
357 | 274 | if (handler != CODE_FOR_nothing) | ||
358 | 275 | { | ||
359 | 276 | if (found_mode) | ||
360 | 277 | *found_mode = from_mode; | ||
361 | 278 | return handler; | ||
362 | 279 | } | ||
363 | 280 | } | ||
364 | 281 | |||
365 | 282 | return CODE_FOR_nothing; | ||
366 | 283 | } | ||
367 | 284 | |||
368 | 230 | 285 | ||
369 | 231 | /* Widen OP to MODE and return the rtx for the widened operand. UNSIGNEDP | 286 | /* Widen OP to MODE and return the rtx for the widened operand. UNSIGNEDP |
370 | 232 | says whether OP is signed or unsigned. NO_EXTEND is nonzero if we need | 287 | says whether OP is signed or unsigned. NO_EXTEND is nonzero if we need |
371 | 233 | not actually do a sign-extend or zero-extend, but can leave the | 288 | not actually do a sign-extend or zero-extend, but can leave the |
372 | @@ -517,8 +572,9 @@ | |||
373 | 517 | optab_for_tree_code (ops->code, TREE_TYPE (oprnd0), optab_default); | 572 | optab_for_tree_code (ops->code, TREE_TYPE (oprnd0), optab_default); |
374 | 518 | if (ops->code == WIDEN_MULT_PLUS_EXPR | 573 | if (ops->code == WIDEN_MULT_PLUS_EXPR |
375 | 519 | || ops->code == WIDEN_MULT_MINUS_EXPR) | 574 | || ops->code == WIDEN_MULT_MINUS_EXPR) |
378 | 520 | icode = (int) optab_handler (widen_pattern_optab, | 575 | icode = (int) find_widening_optab_handler (widen_pattern_optab, |
379 | 521 | TYPE_MODE (TREE_TYPE (ops->op2))); | 576 | TYPE_MODE (TREE_TYPE (ops->op2)), |
380 | 577 | tmode0, 0); | ||
381 | 522 | else | 578 | else |
382 | 523 | icode = (int) optab_handler (widen_pattern_optab, tmode0); | 579 | icode = (int) optab_handler (widen_pattern_optab, tmode0); |
383 | 524 | gcc_assert (icode != CODE_FOR_nothing); | 580 | gcc_assert (icode != CODE_FOR_nothing); |
384 | @@ -1389,7 +1445,9 @@ | |||
385 | 1389 | rtx target, int unsignedp, enum optab_methods methods, | 1445 | rtx target, int unsignedp, enum optab_methods methods, |
386 | 1390 | rtx last) | 1446 | rtx last) |
387 | 1391 | { | 1447 | { |
389 | 1392 | int icode = (int) optab_handler (binoptab, mode); | 1448 | enum machine_mode from_mode = widened_mode (mode, op0, op1); |
390 | 1449 | int icode = (int) find_widening_optab_handler (binoptab, mode, | ||
391 | 1450 | from_mode, 1); | ||
392 | 1393 | enum machine_mode mode0 = insn_data[icode].operand[1].mode; | 1451 | enum machine_mode mode0 = insn_data[icode].operand[1].mode; |
393 | 1394 | enum machine_mode mode1 = insn_data[icode].operand[2].mode; | 1452 | enum machine_mode mode1 = insn_data[icode].operand[2].mode; |
394 | 1395 | enum machine_mode tmp_mode; | 1453 | enum machine_mode tmp_mode; |
395 | @@ -1546,7 +1604,9 @@ | |||
396 | 1546 | /* If we can do it with a three-operand insn, do so. */ | 1604 | /* If we can do it with a three-operand insn, do so. */ |
397 | 1547 | 1605 | ||
398 | 1548 | if (methods != OPTAB_MUST_WIDEN | 1606 | if (methods != OPTAB_MUST_WIDEN |
400 | 1549 | && optab_handler (binoptab, mode) != CODE_FOR_nothing) | 1607 | && find_widening_optab_handler (binoptab, mode, |
401 | 1608 | widened_mode (mode, op0, op1), 1) | ||
402 | 1609 | != CODE_FOR_nothing) | ||
403 | 1550 | { | 1610 | { |
404 | 1551 | temp = expand_binop_directly (mode, binoptab, op0, op1, target, | 1611 | temp = expand_binop_directly (mode, binoptab, op0, op1, target, |
405 | 1552 | unsignedp, methods, last); | 1612 | unsignedp, methods, last); |
406 | @@ -1586,8 +1646,9 @@ | |||
407 | 1586 | 1646 | ||
408 | 1587 | if (binoptab == smul_optab | 1647 | if (binoptab == smul_optab |
409 | 1588 | && GET_MODE_WIDER_MODE (mode) != VOIDmode | 1648 | && GET_MODE_WIDER_MODE (mode) != VOIDmode |
412 | 1589 | && (optab_handler ((unsignedp ? umul_widen_optab : smul_widen_optab), | 1649 | && (widening_optab_handler ((unsignedp ? umul_widen_optab |
413 | 1590 | GET_MODE_WIDER_MODE (mode)) | 1650 | : smul_widen_optab), |
414 | 1651 | GET_MODE_WIDER_MODE (mode), mode) | ||
415 | 1591 | != CODE_FOR_nothing)) | 1652 | != CODE_FOR_nothing)) |
416 | 1592 | { | 1653 | { |
417 | 1593 | temp = expand_binop (GET_MODE_WIDER_MODE (mode), | 1654 | temp = expand_binop (GET_MODE_WIDER_MODE (mode), |
418 | @@ -1618,9 +1679,11 @@ | |||
419 | 1618 | if (optab_handler (binoptab, wider_mode) != CODE_FOR_nothing | 1679 | if (optab_handler (binoptab, wider_mode) != CODE_FOR_nothing |
420 | 1619 | || (binoptab == smul_optab | 1680 | || (binoptab == smul_optab |
421 | 1620 | && GET_MODE_WIDER_MODE (wider_mode) != VOIDmode | 1681 | && GET_MODE_WIDER_MODE (wider_mode) != VOIDmode |
425 | 1621 | && (optab_handler ((unsignedp ? umul_widen_optab | 1682 | && (find_widening_optab_handler ((unsignedp |
426 | 1622 | : smul_widen_optab), | 1683 | ? umul_widen_optab |
427 | 1623 | GET_MODE_WIDER_MODE (wider_mode)) | 1684 | : smul_widen_optab), |
428 | 1685 | GET_MODE_WIDER_MODE (wider_mode), | ||
429 | 1686 | mode, 0) | ||
430 | 1624 | != CODE_FOR_nothing))) | 1687 | != CODE_FOR_nothing))) |
431 | 1625 | { | 1688 | { |
432 | 1626 | rtx xop0 = op0, xop1 = op1; | 1689 | rtx xop0 = op0, xop1 = op1; |
433 | @@ -2043,8 +2106,8 @@ | |||
434 | 2043 | && optab_handler (add_optab, word_mode) != CODE_FOR_nothing) | 2106 | && optab_handler (add_optab, word_mode) != CODE_FOR_nothing) |
435 | 2044 | { | 2107 | { |
436 | 2045 | rtx product = NULL_RTX; | 2108 | rtx product = NULL_RTX; |
439 | 2046 | 2109 | if (widening_optab_handler (umul_widen_optab, mode, word_mode) | |
440 | 2047 | if (optab_handler (umul_widen_optab, mode) != CODE_FOR_nothing) | 2110 | != CODE_FOR_nothing) |
441 | 2048 | { | 2111 | { |
442 | 2049 | product = expand_doubleword_mult (mode, op0, op1, target, | 2112 | product = expand_doubleword_mult (mode, op0, op1, target, |
443 | 2050 | true, methods); | 2113 | true, methods); |
444 | @@ -2053,7 +2116,8 @@ | |||
445 | 2053 | } | 2116 | } |
446 | 2054 | 2117 | ||
447 | 2055 | if (product == NULL_RTX | 2118 | if (product == NULL_RTX |
449 | 2056 | && optab_handler (smul_widen_optab, mode) != CODE_FOR_nothing) | 2119 | && widening_optab_handler (smul_widen_optab, mode, word_mode) |
450 | 2120 | != CODE_FOR_nothing) | ||
451 | 2057 | { | 2121 | { |
452 | 2058 | product = expand_doubleword_mult (mode, op0, op1, target, | 2122 | product = expand_doubleword_mult (mode, op0, op1, target, |
453 | 2059 | false, methods); | 2123 | false, methods); |
454 | @@ -2144,7 +2208,8 @@ | |||
455 | 2144 | wider_mode != VOIDmode; | 2208 | wider_mode != VOIDmode; |
456 | 2145 | wider_mode = GET_MODE_WIDER_MODE (wider_mode)) | 2209 | wider_mode = GET_MODE_WIDER_MODE (wider_mode)) |
457 | 2146 | { | 2210 | { |
459 | 2147 | if (optab_handler (binoptab, wider_mode) != CODE_FOR_nothing | 2211 | if (find_widening_optab_handler (binoptab, wider_mode, mode, 1) |
460 | 2212 | != CODE_FOR_nothing | ||
461 | 2148 | || (methods == OPTAB_LIB | 2213 | || (methods == OPTAB_LIB |
462 | 2149 | && optab_libfunc (binoptab, wider_mode))) | 2214 | && optab_libfunc (binoptab, wider_mode))) |
463 | 2150 | { | 2215 | { |
464 | 2151 | 2216 | ||
465 | === modified file 'gcc/optabs.h' | |||
466 | --- gcc/optabs.h 2011-05-05 15:43:06 +0000 | |||
467 | +++ gcc/optabs.h 2011-08-11 16:16:07 +0000 | |||
468 | @@ -42,6 +42,11 @@ | |||
469 | 42 | int insn_code; | 42 | int insn_code; |
470 | 43 | }; | 43 | }; |
471 | 44 | 44 | ||
472 | 45 | struct widening_optab_handlers | ||
473 | 46 | { | ||
474 | 47 | struct optab_handlers handlers[NUM_MACHINE_MODES][NUM_MACHINE_MODES]; | ||
475 | 48 | }; | ||
476 | 49 | |||
477 | 45 | struct optab_d | 50 | struct optab_d |
478 | 46 | { | 51 | { |
479 | 47 | enum rtx_code code; | 52 | enum rtx_code code; |
480 | @@ -50,6 +55,7 @@ | |||
481 | 50 | void (*libcall_gen)(struct optab_d *, const char *name, char suffix, | 55 | void (*libcall_gen)(struct optab_d *, const char *name, char suffix, |
482 | 51 | enum machine_mode); | 56 | enum machine_mode); |
483 | 52 | struct optab_handlers handlers[NUM_MACHINE_MODES]; | 57 | struct optab_handlers handlers[NUM_MACHINE_MODES]; |
484 | 58 | struct widening_optab_handlers *widening; | ||
485 | 53 | }; | 59 | }; |
486 | 54 | typedef struct optab_d * optab; | 60 | typedef struct optab_d * optab; |
487 | 55 | 61 | ||
488 | @@ -799,6 +805,15 @@ | |||
489 | 799 | extern void emit_unop_insn (int, rtx, rtx, enum rtx_code); | 805 | extern void emit_unop_insn (int, rtx, rtx, enum rtx_code); |
490 | 800 | extern bool maybe_emit_unop_insn (int, rtx, rtx, enum rtx_code); | 806 | extern bool maybe_emit_unop_insn (int, rtx, rtx, enum rtx_code); |
491 | 801 | 807 | ||
492 | 808 | /* Find a widening optab even if it doesn't widen as much as we want. */ | ||
493 | 809 | #define find_widening_optab_handler(A,B,C,D) \ | ||
494 | 810 | find_widening_optab_handler_and_mode (A, B, C, D, NULL) | ||
495 | 811 | extern enum insn_code find_widening_optab_handler_and_mode (optab, | ||
496 | 812 | enum machine_mode, | ||
497 | 813 | enum machine_mode, | ||
498 | 814 | int, | ||
499 | 815 | enum machine_mode *); | ||
500 | 816 | |||
501 | 802 | /* An extra flag to control optab_for_tree_code's behavior. This is needed to | 817 | /* An extra flag to control optab_for_tree_code's behavior. This is needed to |
502 | 803 | distinguish between machines with a vector shift that takes a scalar for the | 818 | distinguish between machines with a vector shift that takes a scalar for the |
503 | 804 | shift amount vs. machines that take a vector for the shift amount. */ | 819 | shift amount vs. machines that take a vector for the shift amount. */ |
504 | @@ -874,6 +889,23 @@ | |||
505 | 874 | + (int) CODE_FOR_nothing); | 889 | + (int) CODE_FOR_nothing); |
506 | 875 | } | 890 | } |
507 | 876 | 891 | ||
508 | 892 | /* Like optab_handler, but for widening_operations that have a TO_MODE and | ||
509 | 893 | a FROM_MODE. */ | ||
510 | 894 | |||
511 | 895 | static inline enum insn_code | ||
512 | 896 | widening_optab_handler (optab op, enum machine_mode to_mode, | ||
513 | 897 | enum machine_mode from_mode) | ||
514 | 898 | { | ||
515 | 899 | if (to_mode == from_mode || from_mode == VOIDmode) | ||
516 | 900 | return optab_handler (op, to_mode); | ||
517 | 901 | |||
518 | 902 | if (op->widening) | ||
519 | 903 | return (enum insn_code) (op->widening->handlers[(int) to_mode][(int) from_mode].insn_code | ||
520 | 904 | + (int) CODE_FOR_nothing); | ||
521 | 905 | |||
522 | 906 | return CODE_FOR_nothing; | ||
523 | 907 | } | ||
524 | 908 | |||
525 | 877 | /* Record that insn CODE should be used to implement mode MODE of OP. */ | 909 | /* Record that insn CODE should be used to implement mode MODE of OP. */ |
526 | 878 | 910 | ||
527 | 879 | static inline void | 911 | static inline void |
528 | @@ -882,6 +914,26 @@ | |||
529 | 882 | op->handlers[(int) mode].insn_code = (int) code - (int) CODE_FOR_nothing; | 914 | op->handlers[(int) mode].insn_code = (int) code - (int) CODE_FOR_nothing; |
530 | 883 | } | 915 | } |
531 | 884 | 916 | ||
532 | 917 | /* Like set_optab_handler, but for widening operations that have a TO_MODE | ||
533 | 918 | and a FROM_MODE. */ | ||
534 | 919 | |||
535 | 920 | static inline void | ||
536 | 921 | set_widening_optab_handler (optab op, enum machine_mode to_mode, | ||
537 | 922 | enum machine_mode from_mode, enum insn_code code) | ||
538 | 923 | { | ||
539 | 924 | if (to_mode == from_mode) | ||
540 | 925 | set_optab_handler (op, to_mode, code); | ||
541 | 926 | else | ||
542 | 927 | { | ||
543 | 928 | if (op->widening == NULL) | ||
544 | 929 | op->widening = (struct widening_optab_handlers *) | ||
545 | 930 | xcalloc (1, sizeof (struct widening_optab_handlers)); | ||
546 | 931 | |||
547 | 932 | op->widening->handlers[(int) to_mode][(int) from_mode].insn_code | ||
548 | 933 | = (int) code - (int) CODE_FOR_nothing; | ||
549 | 934 | } | ||
550 | 935 | } | ||
551 | 936 | |||
552 | 885 | /* Return the insn used to perform conversion OP from mode FROM_MODE | 937 | /* Return the insn used to perform conversion OP from mode FROM_MODE |
553 | 886 | to mode TO_MODE; return CODE_FOR_nothing if the target does not have | 938 | to mode TO_MODE; return CODE_FOR_nothing if the target does not have |
554 | 887 | such an insn. */ | 939 | such an insn. */ |
555 | 888 | 940 | ||
556 | === added file 'gcc/testsuite/gcc.target/arm/no-wmla-1.c' | |||
557 | --- gcc/testsuite/gcc.target/arm/no-wmla-1.c 1970-01-01 00:00:00 +0000 | |||
558 | +++ gcc/testsuite/gcc.target/arm/no-wmla-1.c 2011-08-11 16:16:07 +0000 | |||
559 | @@ -0,0 +1,11 @@ | |||
560 | 1 | /* { dg-do compile } */ | ||
561 | 2 | /* { dg-options "-O2 -march=armv7-a" } */ | ||
562 | 3 | |||
563 | 4 | int | ||
564 | 5 | foo (int a, short b, short c) | ||
565 | 6 | { | ||
566 | 7 | int bc = b * c; | ||
567 | 8 | return a + (short)bc; | ||
568 | 9 | } | ||
569 | 10 | |||
570 | 11 | /* { dg-final { scan-assembler "mul" } } */ | ||
571 | 0 | 12 | ||
572 | === added file 'gcc/testsuite/gcc.target/arm/wmul-10.c' | |||
573 | --- gcc/testsuite/gcc.target/arm/wmul-10.c 1970-01-01 00:00:00 +0000 | |||
574 | +++ gcc/testsuite/gcc.target/arm/wmul-10.c 2011-08-11 16:16:07 +0000 | |||
575 | @@ -0,0 +1,10 @@ | |||
576 | 1 | /* { dg-do compile } */ | ||
577 | 2 | /* { dg-options "-O2 -march=armv7-a" } */ | ||
578 | 3 | |||
579 | 4 | unsigned long long | ||
580 | 5 | foo (unsigned short a, unsigned short *b, unsigned short *c) | ||
581 | 6 | { | ||
582 | 7 | return (unsigned)a + (unsigned long long)*b * (unsigned long long)*c; | ||
583 | 8 | } | ||
584 | 9 | |||
585 | 10 | /* { dg-final { scan-assembler "umlal" } } */ | ||
586 | 0 | 11 | ||
587 | === added file 'gcc/testsuite/gcc.target/arm/wmul-11.c' | |||
588 | --- gcc/testsuite/gcc.target/arm/wmul-11.c 1970-01-01 00:00:00 +0000 | |||
589 | +++ gcc/testsuite/gcc.target/arm/wmul-11.c 2011-08-11 16:16:07 +0000 | |||
590 | @@ -0,0 +1,10 @@ | |||
591 | 1 | /* { dg-do compile } */ | ||
592 | 2 | /* { dg-options "-O2 -march=armv7-a" } */ | ||
593 | 3 | |||
594 | 4 | long long | ||
595 | 5 | foo (int *b) | ||
596 | 6 | { | ||
597 | 7 | return 10 * (long long)*b; | ||
598 | 8 | } | ||
599 | 9 | |||
600 | 10 | /* { dg-final { scan-assembler "smull" } } */ | ||
601 | 0 | 11 | ||
602 | === added file 'gcc/testsuite/gcc.target/arm/wmul-12.c' | |||
603 | --- gcc/testsuite/gcc.target/arm/wmul-12.c 1970-01-01 00:00:00 +0000 | |||
604 | +++ gcc/testsuite/gcc.target/arm/wmul-12.c 2011-08-11 16:16:07 +0000 | |||
605 | @@ -0,0 +1,11 @@ | |||
606 | 1 | /* { dg-do compile } */ | ||
607 | 2 | /* { dg-options "-O2 -march=armv7-a" } */ | ||
608 | 3 | |||
609 | 4 | long long | ||
610 | 5 | foo (int *b, int *c) | ||
611 | 6 | { | ||
612 | 7 | int tmp = *b * *c; | ||
613 | 8 | return 10 + (long long)tmp; | ||
614 | 9 | } | ||
615 | 10 | |||
616 | 11 | /* { dg-final { scan-assembler "smlal" } } */ | ||
617 | 0 | 12 | ||
618 | === added file 'gcc/testsuite/gcc.target/arm/wmul-13.c' | |||
619 | --- gcc/testsuite/gcc.target/arm/wmul-13.c 1970-01-01 00:00:00 +0000 | |||
620 | +++ gcc/testsuite/gcc.target/arm/wmul-13.c 2011-08-11 16:16:07 +0000 | |||
621 | @@ -0,0 +1,10 @@ | |||
622 | 1 | /* { dg-do compile } */ | ||
623 | 2 | /* { dg-options "-O2 -march=armv7-a" } */ | ||
624 | 3 | |||
625 | 4 | long long | ||
626 | 5 | foo (int *a, int *b) | ||
627 | 6 | { | ||
628 | 7 | return *a + (long long)*b * 10; | ||
629 | 8 | } | ||
630 | 9 | |||
631 | 10 | /* { dg-final { scan-assembler "smlal" } } */ | ||
632 | 0 | 11 | ||
633 | === added file 'gcc/testsuite/gcc.target/arm/wmul-5.c' | |||
634 | --- gcc/testsuite/gcc.target/arm/wmul-5.c 1970-01-01 00:00:00 +0000 | |||
635 | +++ gcc/testsuite/gcc.target/arm/wmul-5.c 2011-08-11 16:16:07 +0000 | |||
636 | @@ -0,0 +1,10 @@ | |||
637 | 1 | /* { dg-do compile } */ | ||
638 | 2 | /* { dg-options "-O2 -march=armv7-a" } */ | ||
639 | 3 | |||
640 | 4 | long long | ||
641 | 5 | foo (long long a, char *b, char *c) | ||
642 | 6 | { | ||
643 | 7 | return a + *b * *c; | ||
644 | 8 | } | ||
645 | 9 | |||
646 | 10 | /* { dg-final { scan-assembler "umlal" } } */ | ||
647 | 0 | 11 | ||
648 | === added file 'gcc/testsuite/gcc.target/arm/wmul-6.c' | |||
649 | --- gcc/testsuite/gcc.target/arm/wmul-6.c 1970-01-01 00:00:00 +0000 | |||
650 | +++ gcc/testsuite/gcc.target/arm/wmul-6.c 2011-08-11 16:16:07 +0000 | |||
651 | @@ -0,0 +1,10 @@ | |||
652 | 1 | /* { dg-do compile } */ | ||
653 | 2 | /* { dg-options "-O2 -march=armv7-a" } */ | ||
654 | 3 | |||
655 | 4 | long long | ||
656 | 5 | foo (long long a, unsigned char *b, signed char *c) | ||
657 | 6 | { | ||
658 | 7 | return a + (long long)*b * (long long)*c; | ||
659 | 8 | } | ||
660 | 9 | |||
661 | 10 | /* { dg-final { scan-assembler "smlal" } } */ | ||
662 | 0 | 11 | ||
663 | === added file 'gcc/testsuite/gcc.target/arm/wmul-7.c' | |||
664 | --- gcc/testsuite/gcc.target/arm/wmul-7.c 1970-01-01 00:00:00 +0000 | |||
665 | +++ gcc/testsuite/gcc.target/arm/wmul-7.c 2011-08-11 16:16:07 +0000 | |||
666 | @@ -0,0 +1,10 @@ | |||
667 | 1 | /* { dg-do compile } */ | ||
668 | 2 | /* { dg-options "-O2 -march=armv7-a" } */ | ||
669 | 3 | |||
670 | 4 | unsigned long long | ||
671 | 5 | foo (unsigned long long a, unsigned char *b, unsigned short *c) | ||
672 | 6 | { | ||
673 | 7 | return a + *b * *c; | ||
674 | 8 | } | ||
675 | 9 | |||
676 | 10 | /* { dg-final { scan-assembler "umlal" } } */ | ||
677 | 0 | 11 | ||
678 | === added file 'gcc/testsuite/gcc.target/arm/wmul-8.c' | |||
679 | --- gcc/testsuite/gcc.target/arm/wmul-8.c 1970-01-01 00:00:00 +0000 | |||
680 | +++ gcc/testsuite/gcc.target/arm/wmul-8.c 2011-08-11 16:16:07 +0000 | |||
681 | @@ -0,0 +1,10 @@ | |||
682 | 1 | /* { dg-do compile } */ | ||
683 | 2 | /* { dg-options "-O2 -march=armv7-a" } */ | ||
684 | 3 | |||
685 | 4 | long long | ||
686 | 5 | foo (long long a, int *b, int *c) | ||
687 | 6 | { | ||
688 | 7 | return a + *b * *c; | ||
689 | 8 | } | ||
690 | 9 | |||
691 | 10 | /* { dg-final { scan-assembler "smlal" } } */ | ||
692 | 0 | 11 | ||
693 | === added file 'gcc/testsuite/gcc.target/arm/wmul-9.c' | |||
694 | --- gcc/testsuite/gcc.target/arm/wmul-9.c 1970-01-01 00:00:00 +0000 | |||
695 | +++ gcc/testsuite/gcc.target/arm/wmul-9.c 2011-08-11 16:16:07 +0000 | |||
696 | @@ -0,0 +1,10 @@ | |||
697 | 1 | /* { dg-do compile } */ | ||
698 | 2 | /* { dg-options "-O2 -march=armv7-a" } */ | ||
699 | 3 | |||
700 | 4 | long long | ||
701 | 5 | foo (long long a, short *b, char *c) | ||
702 | 6 | { | ||
703 | 7 | return a + *b * *c; | ||
704 | 8 | } | ||
705 | 9 | |||
706 | 10 | /* { dg-final { scan-assembler "smlalbb" } } */ | ||
707 | 0 | 11 | ||
708 | === added file 'gcc/testsuite/gcc.target/arm/wmul-bitfield-1.c' | |||
709 | --- gcc/testsuite/gcc.target/arm/wmul-bitfield-1.c 1970-01-01 00:00:00 +0000 | |||
710 | +++ gcc/testsuite/gcc.target/arm/wmul-bitfield-1.c 2011-08-11 16:16:07 +0000 | |||
711 | @@ -0,0 +1,17 @@ | |||
712 | 1 | /* { dg-do compile } */ | ||
713 | 2 | /* { dg-options "-O2 -march=armv7-a" } */ | ||
714 | 3 | |||
715 | 4 | struct bf | ||
716 | 5 | { | ||
717 | 6 | int a : 3; | ||
718 | 7 | int b : 15; | ||
719 | 8 | int c : 3; | ||
720 | 9 | }; | ||
721 | 10 | |||
722 | 11 | long long | ||
723 | 12 | foo (long long a, struct bf b, struct bf c) | ||
724 | 13 | { | ||
725 | 14 | return a + b.b * c.b; | ||
726 | 15 | } | ||
727 | 16 | |||
728 | 17 | /* { dg-final { scan-assembler "smlalbb" } } */ | ||
729 | 0 | 18 | ||
730 | === added file 'gcc/testsuite/gcc.target/arm/wmul-bitfield-2.c' | |||
731 | --- gcc/testsuite/gcc.target/arm/wmul-bitfield-2.c 1970-01-01 00:00:00 +0000 | |||
732 | +++ gcc/testsuite/gcc.target/arm/wmul-bitfield-2.c 2011-08-11 16:16:07 +0000 | |||
733 | @@ -0,0 +1,17 @@ | |||
734 | 1 | /* { dg-do compile } */ | ||
735 | 2 | /* { dg-options "-O2 -march=armv7-a" } */ | ||
736 | 3 | |||
737 | 4 | struct bf | ||
738 | 5 | { | ||
739 | 6 | int a : 3; | ||
740 | 7 | unsigned int b : 15; | ||
741 | 8 | int c : 3; | ||
742 | 9 | }; | ||
743 | 10 | |||
744 | 11 | long long | ||
745 | 12 | foo (long long a, struct bf b, struct bf c) | ||
746 | 13 | { | ||
747 | 14 | return a + b.b * c.c; | ||
748 | 15 | } | ||
749 | 16 | |||
750 | 17 | /* { dg-final { scan-assembler "smlalbb" } } */ | ||
751 | 0 | 18 | ||
752 | === modified file 'gcc/tree-cfg.c' | |||
753 | --- gcc/tree-cfg.c 2011-07-01 09:19:21 +0000 | |||
754 | +++ gcc/tree-cfg.c 2011-08-11 16:16:07 +0000 | |||
755 | @@ -3574,7 +3574,7 @@ | |||
756 | 3574 | case WIDEN_MULT_EXPR: | 3574 | case WIDEN_MULT_EXPR: |
757 | 3575 | if (TREE_CODE (lhs_type) != INTEGER_TYPE) | 3575 | if (TREE_CODE (lhs_type) != INTEGER_TYPE) |
758 | 3576 | return true; | 3576 | return true; |
760 | 3577 | return ((2 * TYPE_PRECISION (rhs1_type) != TYPE_PRECISION (lhs_type)) | 3577 | return ((2 * TYPE_PRECISION (rhs1_type) > TYPE_PRECISION (lhs_type)) |
761 | 3578 | || (TYPE_PRECISION (rhs1_type) != TYPE_PRECISION (rhs2_type))); | 3578 | || (TYPE_PRECISION (rhs1_type) != TYPE_PRECISION (rhs2_type))); |
762 | 3579 | 3579 | ||
763 | 3580 | case WIDEN_SUM_EXPR: | 3580 | case WIDEN_SUM_EXPR: |
764 | @@ -3667,7 +3667,7 @@ | |||
765 | 3667 | && !FIXED_POINT_TYPE_P (rhs1_type)) | 3667 | && !FIXED_POINT_TYPE_P (rhs1_type)) |
766 | 3668 | || !useless_type_conversion_p (rhs1_type, rhs2_type) | 3668 | || !useless_type_conversion_p (rhs1_type, rhs2_type) |
767 | 3669 | || !useless_type_conversion_p (lhs_type, rhs3_type) | 3669 | || !useless_type_conversion_p (lhs_type, rhs3_type) |
769 | 3670 | || 2 * TYPE_PRECISION (rhs1_type) != TYPE_PRECISION (lhs_type) | 3670 | || 2 * TYPE_PRECISION (rhs1_type) > TYPE_PRECISION (lhs_type) |
770 | 3671 | || TYPE_PRECISION (rhs1_type) != TYPE_PRECISION (rhs2_type)) | 3671 | || TYPE_PRECISION (rhs1_type) != TYPE_PRECISION (rhs2_type)) |
771 | 3672 | { | 3672 | { |
772 | 3673 | error ("type mismatch in widening multiply-accumulate expression"); | 3673 | error ("type mismatch in widening multiply-accumulate expression"); |
773 | 3674 | 3674 | ||
774 | === modified file 'gcc/tree-ssa-math-opts.c' | |||
775 | --- gcc/tree-ssa-math-opts.c 2011-03-11 16:36:16 +0000 | |||
776 | +++ gcc/tree-ssa-math-opts.c 2011-08-11 16:16:07 +0000 | |||
777 | @@ -1266,39 +1266,67 @@ | |||
778 | 1266 | } | 1266 | } |
779 | 1267 | }; | 1267 | }; |
780 | 1268 | 1268 | ||
782 | 1269 | /* Return true if RHS is a suitable operand for a widening multiplication. | 1269 | /* Build a gimple assignment to cast VAL to TARGET. Insert the statement |
783 | 1270 | prior to GSI's current position, and return the fresh SSA name. */ | ||
784 | 1271 | |||
785 | 1272 | static tree | ||
786 | 1273 | build_and_insert_cast (gimple_stmt_iterator *gsi, location_t loc, | ||
787 | 1274 | tree target, tree val) | ||
788 | 1275 | { | ||
789 | 1276 | tree result = make_ssa_name (target, NULL); | ||
790 | 1277 | gimple stmt = gimple_build_assign_with_ops (CONVERT_EXPR, result, val, NULL); | ||
791 | 1278 | gimple_set_location (stmt, loc); | ||
792 | 1279 | gsi_insert_before (gsi, stmt, GSI_SAME_STMT); | ||
793 | 1280 | return result; | ||
794 | 1281 | } | ||
795 | 1282 | |||
796 | 1283 | /* Return true if RHS is a suitable operand for a widening multiplication, | ||
797 | 1284 | assuming a target type of TYPE. | ||
798 | 1270 | There are two cases: | 1285 | There are two cases: |
799 | 1271 | 1286 | ||
802 | 1272 | - RHS makes some value twice as wide. Store that value in *NEW_RHS_OUT | 1287 | - RHS makes some value at least twice as wide. Store that value |
803 | 1273 | if so, and store its type in *TYPE_OUT. | 1288 | in *NEW_RHS_OUT if so, and store its type in *TYPE_OUT. |
804 | 1274 | 1289 | ||
805 | 1275 | - RHS is an integer constant. Store that value in *NEW_RHS_OUT if so, | 1290 | - RHS is an integer constant. Store that value in *NEW_RHS_OUT if so, |
806 | 1276 | but leave *TYPE_OUT untouched. */ | 1291 | but leave *TYPE_OUT untouched. */ |
807 | 1277 | 1292 | ||
808 | 1278 | static bool | 1293 | static bool |
810 | 1279 | is_widening_mult_rhs_p (tree rhs, tree *type_out, tree *new_rhs_out) | 1294 | is_widening_mult_rhs_p (tree type, tree rhs, tree *type_out, |
811 | 1295 | tree *new_rhs_out) | ||
812 | 1280 | { | 1296 | { |
813 | 1281 | gimple stmt; | 1297 | gimple stmt; |
815 | 1282 | tree type, type1, rhs1; | 1298 | tree type1, rhs1; |
816 | 1283 | enum tree_code rhs_code; | 1299 | enum tree_code rhs_code; |
817 | 1284 | 1300 | ||
818 | 1285 | if (TREE_CODE (rhs) == SSA_NAME) | 1301 | if (TREE_CODE (rhs) == SSA_NAME) |
819 | 1286 | { | 1302 | { |
820 | 1287 | type = TREE_TYPE (rhs); | ||
821 | 1288 | stmt = SSA_NAME_DEF_STMT (rhs); | 1303 | stmt = SSA_NAME_DEF_STMT (rhs); |
832 | 1289 | if (!is_gimple_assign (stmt)) | 1304 | if (is_gimple_assign (stmt)) |
833 | 1290 | return false; | 1305 | { |
834 | 1291 | 1306 | rhs_code = gimple_assign_rhs_code (stmt); | |
835 | 1292 | rhs_code = gimple_assign_rhs_code (stmt); | 1307 | if (TREE_CODE (type) == INTEGER_TYPE |
836 | 1293 | if (TREE_CODE (type) == INTEGER_TYPE | 1308 | ? !CONVERT_EXPR_CODE_P (rhs_code) |
837 | 1294 | ? !CONVERT_EXPR_CODE_P (rhs_code) | 1309 | : rhs_code != FIXED_CONVERT_EXPR) |
838 | 1295 | : rhs_code != FIXED_CONVERT_EXPR) | 1310 | rhs1 = rhs; |
839 | 1296 | return false; | 1311 | else |
840 | 1297 | 1312 | { | |
841 | 1298 | rhs1 = gimple_assign_rhs1 (stmt); | 1313 | rhs1 = gimple_assign_rhs1 (stmt); |
842 | 1314 | |||
843 | 1315 | if (TREE_CODE (rhs1) == INTEGER_CST) | ||
844 | 1316 | { | ||
845 | 1317 | *new_rhs_out = rhs1; | ||
846 | 1318 | *type_out = NULL; | ||
847 | 1319 | return true; | ||
848 | 1320 | } | ||
849 | 1321 | } | ||
850 | 1322 | } | ||
851 | 1323 | else | ||
852 | 1324 | rhs1 = rhs; | ||
853 | 1325 | |||
854 | 1299 | type1 = TREE_TYPE (rhs1); | 1326 | type1 = TREE_TYPE (rhs1); |
855 | 1327 | |||
856 | 1300 | if (TREE_CODE (type1) != TREE_CODE (type) | 1328 | if (TREE_CODE (type1) != TREE_CODE (type) |
858 | 1301 | || TYPE_PRECISION (type1) * 2 != TYPE_PRECISION (type)) | 1329 | || TYPE_PRECISION (type1) * 2 > TYPE_PRECISION (type)) |
859 | 1302 | return false; | 1330 | return false; |
860 | 1303 | 1331 | ||
861 | 1304 | *new_rhs_out = rhs1; | 1332 | *new_rhs_out = rhs1; |
862 | @@ -1316,28 +1344,27 @@ | |||
863 | 1316 | return false; | 1344 | return false; |
864 | 1317 | } | 1345 | } |
865 | 1318 | 1346 | ||
871 | 1319 | /* Return true if STMT performs a widening multiplication. If so, | 1347 | /* Return true if STMT performs a widening multiplication, assuming the |
872 | 1320 | store the unwidened types of the operands in *TYPE1_OUT and *TYPE2_OUT | 1348 | output type is TYPE. If so, store the unwidened types of the operands |
873 | 1321 | respectively. Also fill *RHS1_OUT and *RHS2_OUT such that converting | 1349 | in *TYPE1_OUT and *TYPE2_OUT respectively. Also fill *RHS1_OUT and |
874 | 1322 | those operands to types *TYPE1_OUT and *TYPE2_OUT would give the | 1350 | *RHS2_OUT such that converting those operands to types *TYPE1_OUT |
875 | 1323 | operands of the multiplication. */ | 1351 | and *TYPE2_OUT would give the operands of the multiplication. */ |
876 | 1324 | 1352 | ||
877 | 1325 | static bool | 1353 | static bool |
879 | 1326 | is_widening_mult_p (gimple stmt, | 1354 | is_widening_mult_p (tree type, gimple stmt, |
880 | 1327 | tree *type1_out, tree *rhs1_out, | 1355 | tree *type1_out, tree *rhs1_out, |
881 | 1328 | tree *type2_out, tree *rhs2_out) | 1356 | tree *type2_out, tree *rhs2_out) |
882 | 1329 | { | 1357 | { |
883 | 1330 | tree type; | ||
884 | 1331 | |||
885 | 1332 | type = TREE_TYPE (gimple_assign_lhs (stmt)); | ||
886 | 1333 | if (TREE_CODE (type) != INTEGER_TYPE | 1358 | if (TREE_CODE (type) != INTEGER_TYPE |
887 | 1334 | && TREE_CODE (type) != FIXED_POINT_TYPE) | 1359 | && TREE_CODE (type) != FIXED_POINT_TYPE) |
888 | 1335 | return false; | 1360 | return false; |
889 | 1336 | 1361 | ||
891 | 1337 | if (!is_widening_mult_rhs_p (gimple_assign_rhs1 (stmt), type1_out, rhs1_out)) | 1362 | if (!is_widening_mult_rhs_p (type, gimple_assign_rhs1 (stmt), type1_out, |
892 | 1363 | rhs1_out)) | ||
893 | 1338 | return false; | 1364 | return false; |
894 | 1339 | 1365 | ||
896 | 1340 | if (!is_widening_mult_rhs_p (gimple_assign_rhs2 (stmt), type2_out, rhs2_out)) | 1366 | if (!is_widening_mult_rhs_p (type, gimple_assign_rhs2 (stmt), type2_out, |
897 | 1367 | rhs2_out)) | ||
898 | 1341 | return false; | 1368 | return false; |
899 | 1342 | 1369 | ||
900 | 1343 | if (*type1_out == NULL) | 1370 | if (*type1_out == NULL) |
901 | @@ -1354,6 +1381,18 @@ | |||
902 | 1354 | *type2_out = *type1_out; | 1381 | *type2_out = *type1_out; |
903 | 1355 | } | 1382 | } |
904 | 1356 | 1383 | ||
905 | 1384 | /* Ensure that the larger of the two operands comes first. */ | ||
906 | 1385 | if (TYPE_PRECISION (*type1_out) < TYPE_PRECISION (*type2_out)) | ||
907 | 1386 | { | ||
908 | 1387 | tree tmp; | ||
909 | 1388 | tmp = *type1_out; | ||
910 | 1389 | *type1_out = *type2_out; | ||
911 | 1390 | *type2_out = tmp; | ||
912 | 1391 | tmp = *rhs1_out; | ||
913 | 1392 | *rhs1_out = *rhs2_out; | ||
914 | 1393 | *rhs2_out = tmp; | ||
915 | 1394 | } | ||
916 | 1395 | |||
917 | 1357 | return true; | 1396 | return true; |
918 | 1358 | } | 1397 | } |
919 | 1359 | 1398 | ||
920 | @@ -1362,31 +1401,100 @@ | |||
921 | 1362 | value is true iff we converted the statement. */ | 1401 | value is true iff we converted the statement. */ |
922 | 1363 | 1402 | ||
923 | 1364 | static bool | 1403 | static bool |
925 | 1365 | convert_mult_to_widen (gimple stmt) | 1404 | convert_mult_to_widen (gimple stmt, gimple_stmt_iterator *gsi) |
926 | 1366 | { | 1405 | { |
928 | 1367 | tree lhs, rhs1, rhs2, type, type1, type2; | 1406 | tree lhs, rhs1, rhs2, type, type1, type2, tmp = NULL; |
929 | 1368 | enum insn_code handler; | 1407 | enum insn_code handler; |
930 | 1408 | enum machine_mode to_mode, from_mode, actual_mode; | ||
931 | 1409 | optab op; | ||
932 | 1410 | int actual_precision; | ||
933 | 1411 | location_t loc = gimple_location (stmt); | ||
934 | 1412 | bool from_unsigned1, from_unsigned2; | ||
935 | 1369 | 1413 | ||
936 | 1370 | lhs = gimple_assign_lhs (stmt); | 1414 | lhs = gimple_assign_lhs (stmt); |
937 | 1371 | type = TREE_TYPE (lhs); | 1415 | type = TREE_TYPE (lhs); |
938 | 1372 | if (TREE_CODE (type) != INTEGER_TYPE) | 1416 | if (TREE_CODE (type) != INTEGER_TYPE) |
939 | 1373 | return false; | 1417 | return false; |
940 | 1374 | 1418 | ||
942 | 1375 | if (!is_widening_mult_p (stmt, &type1, &rhs1, &type2, &rhs2)) | 1419 | if (!is_widening_mult_p (type, stmt, &type1, &rhs1, &type2, &rhs2)) |
943 | 1376 | return false; | 1420 | return false; |
944 | 1377 | 1421 | ||
949 | 1378 | if (TYPE_UNSIGNED (type1) && TYPE_UNSIGNED (type2)) | 1422 | to_mode = TYPE_MODE (type); |
950 | 1379 | handler = optab_handler (umul_widen_optab, TYPE_MODE (type)); | 1423 | from_mode = TYPE_MODE (type1); |
951 | 1380 | else if (!TYPE_UNSIGNED (type1) && !TYPE_UNSIGNED (type2)) | 1424 | from_unsigned1 = TYPE_UNSIGNED (type1); |
952 | 1381 | handler = optab_handler (smul_widen_optab, TYPE_MODE (type)); | 1425 | from_unsigned2 = TYPE_UNSIGNED (type2); |
953 | 1426 | |||
954 | 1427 | if (from_unsigned1 && from_unsigned2) | ||
955 | 1428 | op = umul_widen_optab; | ||
956 | 1429 | else if (!from_unsigned1 && !from_unsigned2) | ||
957 | 1430 | op = smul_widen_optab; | ||
958 | 1382 | else | 1431 | else |
960 | 1383 | handler = optab_handler (usmul_widen_optab, TYPE_MODE (type)); | 1432 | op = usmul_widen_optab; |
961 | 1433 | |||
962 | 1434 | handler = find_widening_optab_handler_and_mode (op, to_mode, from_mode, | ||
963 | 1435 | 0, &actual_mode); | ||
964 | 1384 | 1436 | ||
965 | 1385 | if (handler == CODE_FOR_nothing) | 1437 | if (handler == CODE_FOR_nothing) |
970 | 1386 | return false; | 1438 | { |
971 | 1387 | 1439 | if (op != smul_widen_optab) | |
972 | 1388 | gimple_assign_set_rhs1 (stmt, fold_convert (type1, rhs1)); | 1440 | { |
973 | 1389 | gimple_assign_set_rhs2 (stmt, fold_convert (type2, rhs2)); | 1441 | /* We can use a signed multiply with unsigned types as long as |
974 | 1442 | there is a wider mode to use, or it is the smaller of the two | ||
975 | 1443 | types that is unsigned. Note that type1 >= type2, always. */ | ||
976 | 1444 | if ((TYPE_UNSIGNED (type1) | ||
977 | 1445 | && TYPE_PRECISION (type1) == GET_MODE_PRECISION (from_mode)) | ||
978 | 1446 | || (TYPE_UNSIGNED (type2) | ||
979 | 1447 | && TYPE_PRECISION (type2) == GET_MODE_PRECISION (from_mode))) | ||
980 | 1448 | { | ||
981 | 1449 | from_mode = GET_MODE_WIDER_MODE (from_mode); | ||
982 | 1450 | if (GET_MODE_SIZE (to_mode) <= GET_MODE_SIZE (from_mode)) | ||
983 | 1451 | return false; | ||
984 | 1452 | } | ||
985 | 1453 | |||
986 | 1454 | op = smul_widen_optab; | ||
987 | 1455 | handler = find_widening_optab_handler_and_mode (op, to_mode, | ||
988 | 1456 | from_mode, 0, | ||
989 | 1457 | &actual_mode); | ||
990 | 1458 | |||
991 | 1459 | if (handler == CODE_FOR_nothing) | ||
992 | 1460 | return false; | ||
993 | 1461 | |||
994 | 1462 | from_unsigned1 = from_unsigned2 = false; | ||
995 | 1463 | } | ||
996 | 1464 | else | ||
997 | 1465 | return false; | ||
998 | 1466 | } | ||
999 | 1467 | |||
1000 | 1468 | /* Ensure that the inputs to the handler are in the correct precison | ||
1001 | 1469 | for the opcode. This will be the full mode size. */ | ||
1002 | 1470 | actual_precision = GET_MODE_PRECISION (actual_mode); | ||
1003 | 1471 | if (actual_precision != TYPE_PRECISION (type1) | ||
1004 | 1472 | || from_unsigned1 != TYPE_UNSIGNED (type1)) | ||
1005 | 1473 | { | ||
1006 | 1474 | tmp = create_tmp_var (build_nonstandard_integer_type | ||
1007 | 1475 | (actual_precision, from_unsigned1), | ||
1008 | 1476 | NULL); | ||
1009 | 1477 | rhs1 = build_and_insert_cast (gsi, loc, tmp, rhs1); | ||
1010 | 1478 | } | ||
1011 | 1479 | if (actual_precision != TYPE_PRECISION (type2) | ||
1012 | 1480 | || from_unsigned2 != TYPE_UNSIGNED (type2)) | ||
1013 | 1481 | { | ||
1014 | 1482 | /* Reuse the same type info, if possible. */ | ||
1015 | 1483 | if (!tmp || from_unsigned1 != from_unsigned2) | ||
1016 | 1484 | tmp = create_tmp_var (build_nonstandard_integer_type | ||
1017 | 1485 | (actual_precision, from_unsigned2), | ||
1018 | 1486 | NULL); | ||
1019 | 1487 | rhs2 = build_and_insert_cast (gsi, loc, tmp, rhs2); | ||
1020 | 1488 | } | ||
1021 | 1489 | |||
1022 | 1490 | /* Handle constants. */ | ||
1023 | 1491 | if (TREE_CODE (rhs1) == INTEGER_CST) | ||
1024 | 1492 | rhs1 = fold_convert (type1, rhs1); | ||
1025 | 1493 | if (TREE_CODE (rhs2) == INTEGER_CST) | ||
1026 | 1494 | rhs2 = fold_convert (type2, rhs2); | ||
1027 | 1495 | |||
1028 | 1496 | gimple_assign_set_rhs1 (stmt, rhs1); | ||
1029 | 1497 | gimple_assign_set_rhs2 (stmt, rhs2); | ||
1030 | 1390 | gimple_assign_set_rhs_code (stmt, WIDEN_MULT_EXPR); | 1498 | gimple_assign_set_rhs_code (stmt, WIDEN_MULT_EXPR); |
1031 | 1391 | update_stmt (stmt); | 1499 | update_stmt (stmt); |
1032 | 1392 | return true; | 1500 | return true; |
1033 | @@ -1403,11 +1511,17 @@ | |||
1034 | 1403 | enum tree_code code) | 1511 | enum tree_code code) |
1035 | 1404 | { | 1512 | { |
1036 | 1405 | gimple rhs1_stmt = NULL, rhs2_stmt = NULL; | 1513 | gimple rhs1_stmt = NULL, rhs2_stmt = NULL; |
1038 | 1406 | tree type, type1, type2; | 1514 | gimple conv1_stmt = NULL, conv2_stmt = NULL, conv_stmt; |
1039 | 1515 | tree type, type1, type2, optype, tmp = NULL; | ||
1040 | 1407 | tree lhs, rhs1, rhs2, mult_rhs1, mult_rhs2, add_rhs; | 1516 | tree lhs, rhs1, rhs2, mult_rhs1, mult_rhs2, add_rhs; |
1041 | 1408 | enum tree_code rhs1_code = ERROR_MARK, rhs2_code = ERROR_MARK; | 1517 | enum tree_code rhs1_code = ERROR_MARK, rhs2_code = ERROR_MARK; |
1042 | 1409 | optab this_optab; | 1518 | optab this_optab; |
1043 | 1410 | enum tree_code wmult_code; | 1519 | enum tree_code wmult_code; |
1044 | 1520 | enum insn_code handler; | ||
1045 | 1521 | enum machine_mode to_mode, from_mode, actual_mode; | ||
1046 | 1522 | location_t loc = gimple_location (stmt); | ||
1047 | 1523 | int actual_precision; | ||
1048 | 1524 | bool from_unsigned1, from_unsigned2; | ||
1049 | 1411 | 1525 | ||
1050 | 1412 | lhs = gimple_assign_lhs (stmt); | 1526 | lhs = gimple_assign_lhs (stmt); |
1051 | 1413 | type = TREE_TYPE (lhs); | 1527 | type = TREE_TYPE (lhs); |
1052 | @@ -1429,8 +1543,6 @@ | |||
1053 | 1429 | if (is_gimple_assign (rhs1_stmt)) | 1543 | if (is_gimple_assign (rhs1_stmt)) |
1054 | 1430 | rhs1_code = gimple_assign_rhs_code (rhs1_stmt); | 1544 | rhs1_code = gimple_assign_rhs_code (rhs1_stmt); |
1055 | 1431 | } | 1545 | } |
1056 | 1432 | else | ||
1057 | 1433 | return false; | ||
1058 | 1434 | 1546 | ||
1059 | 1435 | if (TREE_CODE (rhs2) == SSA_NAME) | 1547 | if (TREE_CODE (rhs2) == SSA_NAME) |
1060 | 1436 | { | 1548 | { |
1061 | @@ -1438,57 +1550,160 @@ | |||
1062 | 1438 | if (is_gimple_assign (rhs2_stmt)) | 1550 | if (is_gimple_assign (rhs2_stmt)) |
1063 | 1439 | rhs2_code = gimple_assign_rhs_code (rhs2_stmt); | 1551 | rhs2_code = gimple_assign_rhs_code (rhs2_stmt); |
1064 | 1440 | } | 1552 | } |
1103 | 1441 | else | 1553 | |
1104 | 1442 | return false; | 1554 | /* Allow for one conversion statement between the multiply |
1105 | 1443 | 1555 | and addition/subtraction statement. If there are more than | |
1106 | 1444 | if (code == PLUS_EXPR && rhs1_code == MULT_EXPR) | 1556 | one conversions then we assume they would invalidate this |
1107 | 1445 | { | 1557 | transformation. If that's not the case then they should have |
1108 | 1446 | if (!is_widening_mult_p (rhs1_stmt, &type1, &mult_rhs1, | 1558 | been folded before now. */ |
1109 | 1447 | &type2, &mult_rhs2)) | 1559 | if (CONVERT_EXPR_CODE_P (rhs1_code)) |
1110 | 1448 | return false; | 1560 | { |
1111 | 1449 | add_rhs = rhs2; | 1561 | conv1_stmt = rhs1_stmt; |
1112 | 1450 | } | 1562 | rhs1 = gimple_assign_rhs1 (rhs1_stmt); |
1113 | 1451 | else if (rhs2_code == MULT_EXPR) | 1563 | if (TREE_CODE (rhs1) == SSA_NAME) |
1114 | 1452 | { | 1564 | { |
1115 | 1453 | if (!is_widening_mult_p (rhs2_stmt, &type1, &mult_rhs1, | 1565 | rhs1_stmt = SSA_NAME_DEF_STMT (rhs1); |
1116 | 1454 | &type2, &mult_rhs2)) | 1566 | if (is_gimple_assign (rhs1_stmt)) |
1117 | 1455 | return false; | 1567 | rhs1_code = gimple_assign_rhs_code (rhs1_stmt); |
1118 | 1456 | add_rhs = rhs1; | 1568 | } |
1119 | 1457 | } | 1569 | else |
1120 | 1458 | else if (code == PLUS_EXPR && rhs1_code == WIDEN_MULT_EXPR) | 1570 | return false; |
1121 | 1459 | { | 1571 | } |
1122 | 1460 | mult_rhs1 = gimple_assign_rhs1 (rhs1_stmt); | 1572 | if (CONVERT_EXPR_CODE_P (rhs2_code)) |
1123 | 1461 | mult_rhs2 = gimple_assign_rhs2 (rhs1_stmt); | 1573 | { |
1124 | 1462 | type1 = TREE_TYPE (mult_rhs1); | 1574 | conv2_stmt = rhs2_stmt; |
1125 | 1463 | type2 = TREE_TYPE (mult_rhs2); | 1575 | rhs2 = gimple_assign_rhs1 (rhs2_stmt); |
1126 | 1464 | add_rhs = rhs2; | 1576 | if (TREE_CODE (rhs2) == SSA_NAME) |
1127 | 1465 | } | 1577 | { |
1128 | 1466 | else if (rhs2_code == WIDEN_MULT_EXPR) | 1578 | rhs2_stmt = SSA_NAME_DEF_STMT (rhs2); |
1129 | 1467 | { | 1579 | if (is_gimple_assign (rhs2_stmt)) |
1130 | 1468 | mult_rhs1 = gimple_assign_rhs1 (rhs2_stmt); | 1580 | rhs2_code = gimple_assign_rhs_code (rhs2_stmt); |
1131 | 1469 | mult_rhs2 = gimple_assign_rhs2 (rhs2_stmt); | 1581 | } |
1132 | 1470 | type1 = TREE_TYPE (mult_rhs1); | 1582 | else |
1133 | 1471 | type2 = TREE_TYPE (mult_rhs2); | 1583 | return false; |
1134 | 1472 | add_rhs = rhs1; | 1584 | } |
1135 | 1473 | } | 1585 | |
1136 | 1474 | else | 1586 | /* If code is WIDEN_MULT_EXPR then it would seem unnecessary to call |
1137 | 1475 | return false; | 1587 | is_widening_mult_p, but we still need the rhs returns. |
1138 | 1476 | 1588 | ||
1139 | 1477 | if (TYPE_UNSIGNED (type1) != TYPE_UNSIGNED (type2)) | 1589 | It might also appear that it would be sufficient to use the existing |
1140 | 1478 | return false; | 1590 | operands of the widening multiply, but that would limit the choice of |
1141 | 1591 | multiply-and-accumulate instructions. */ | ||
1142 | 1592 | if (code == PLUS_EXPR | ||
1143 | 1593 | && (rhs1_code == MULT_EXPR || rhs1_code == WIDEN_MULT_EXPR)) | ||
1144 | 1594 | { | ||
1145 | 1595 | if (!is_widening_mult_p (type, rhs1_stmt, &type1, &mult_rhs1, | ||
1146 | 1596 | &type2, &mult_rhs2)) | ||
1147 | 1597 | return false; | ||
1148 | 1598 | add_rhs = rhs2; | ||
1149 | 1599 | conv_stmt = conv1_stmt; | ||
1150 | 1600 | } | ||
1151 | 1601 | else if (rhs2_code == MULT_EXPR || rhs2_code == WIDEN_MULT_EXPR) | ||
1152 | 1602 | { | ||
1153 | 1603 | if (!is_widening_mult_p (type, rhs2_stmt, &type1, &mult_rhs1, | ||
1154 | 1604 | &type2, &mult_rhs2)) | ||
1155 | 1605 | return false; | ||
1156 | 1606 | add_rhs = rhs1; | ||
1157 | 1607 | conv_stmt = conv2_stmt; | ||
1158 | 1608 | } | ||
1159 | 1609 | else | ||
1160 | 1610 | return false; | ||
1161 | 1611 | |||
1162 | 1612 | to_mode = TYPE_MODE (type); | ||
1163 | 1613 | from_mode = TYPE_MODE (type1); | ||
1164 | 1614 | from_unsigned1 = TYPE_UNSIGNED (type1); | ||
1165 | 1615 | from_unsigned2 = TYPE_UNSIGNED (type2); | ||
1166 | 1616 | |||
1167 | 1617 | /* There's no such thing as a mixed sign madd yet, so use a wider mode. */ | ||
1168 | 1618 | if (from_unsigned1 != from_unsigned2) | ||
1169 | 1619 | { | ||
1170 | 1620 | /* We can use a signed multiply with unsigned types as long as | ||
1171 | 1621 | there is a wider mode to use, or it is the smaller of the two | ||
1172 | 1622 | types that is unsigned. Note that type1 >= type2, always. */ | ||
1173 | 1623 | if ((from_unsigned1 | ||
1174 | 1624 | && TYPE_PRECISION (type1) == GET_MODE_PRECISION (from_mode)) | ||
1175 | 1625 | || (from_unsigned2 | ||
1176 | 1626 | && TYPE_PRECISION (type2) == GET_MODE_PRECISION (from_mode))) | ||
1177 | 1627 | { | ||
1178 | 1628 | from_mode = GET_MODE_WIDER_MODE (from_mode); | ||
1179 | 1629 | if (GET_MODE_SIZE (from_mode) >= GET_MODE_SIZE (to_mode)) | ||
1180 | 1630 | return false; | ||
1181 | 1631 | } | ||
1182 | 1632 | |||
1183 | 1633 | from_unsigned1 = from_unsigned2 = false; | ||
1184 | 1634 | } | ||
1185 | 1635 | |||
1186 | 1636 | /* If there was a conversion between the multiply and addition | ||
1187 | 1637 | then we need to make sure it fits a multiply-and-accumulate. | ||
1188 | 1638 | The should be a single mode change which does not change the | ||
1189 | 1639 | value. */ | ||
1190 | 1640 | if (conv_stmt) | ||
1191 | 1641 | { | ||
1192 | 1642 | /* We use the original, unmodified data types for this. */ | ||
1193 | 1643 | tree from_type = TREE_TYPE (gimple_assign_rhs1 (conv_stmt)); | ||
1194 | 1644 | tree to_type = TREE_TYPE (gimple_assign_lhs (conv_stmt)); | ||
1195 | 1645 | int data_size = TYPE_PRECISION (type1) + TYPE_PRECISION (type2); | ||
1196 | 1646 | bool is_unsigned = TYPE_UNSIGNED (type1) && TYPE_UNSIGNED (type2); | ||
1197 | 1647 | |||
1198 | 1648 | if (TYPE_PRECISION (from_type) > TYPE_PRECISION (to_type)) | ||
1199 | 1649 | { | ||
1200 | 1650 | /* Conversion is a truncate. */ | ||
1201 | 1651 | if (TYPE_PRECISION (to_type) < data_size) | ||
1202 | 1652 | return false; | ||
1203 | 1653 | } | ||
1204 | 1654 | else if (TYPE_PRECISION (from_type) < TYPE_PRECISION (to_type)) | ||
1205 | 1655 | { | ||
1206 | 1656 | /* Conversion is an extend. Check it's the right sort. */ | ||
1207 | 1657 | if (TYPE_UNSIGNED (from_type) != is_unsigned | ||
1208 | 1658 | && !(is_unsigned && TYPE_PRECISION (from_type) > data_size)) | ||
1209 | 1659 | return false; | ||
1210 | 1660 | } | ||
1211 | 1661 | /* else convert is a no-op for our purposes. */ | ||
1212 | 1662 | } | ||
1213 | 1479 | 1663 | ||
1214 | 1480 | /* Verify that the machine can perform a widening multiply | 1664 | /* Verify that the machine can perform a widening multiply |
1215 | 1481 | accumulate in this mode/signedness combination, otherwise | 1665 | accumulate in this mode/signedness combination, otherwise |
1216 | 1482 | this transformation is likely to pessimize code. */ | 1666 | this transformation is likely to pessimize code. */ |
1219 | 1483 | this_optab = optab_for_tree_code (wmult_code, type1, optab_default); | 1667 | optype = build_nonstandard_integer_type (from_mode, from_unsigned1); |
1220 | 1484 | if (optab_handler (this_optab, TYPE_MODE (type)) == CODE_FOR_nothing) | 1668 | this_optab = optab_for_tree_code (wmult_code, optype, optab_default); |
1221 | 1669 | handler = find_widening_optab_handler_and_mode (this_optab, to_mode, | ||
1222 | 1670 | from_mode, 0, &actual_mode); | ||
1223 | 1671 | |||
1224 | 1672 | if (handler == CODE_FOR_nothing) | ||
1225 | 1485 | return false; | 1673 | return false; |
1226 | 1486 | 1674 | ||
1232 | 1487 | /* ??? May need some type verification here? */ | 1675 | /* Ensure that the inputs to the handler are in the correct precison |
1233 | 1488 | 1676 | for the opcode. This will be the full mode size. */ | |
1234 | 1489 | gimple_assign_set_rhs_with_ops_1 (gsi, wmult_code, | 1677 | actual_precision = GET_MODE_PRECISION (actual_mode); |
1235 | 1490 | fold_convert (type1, mult_rhs1), | 1678 | if (actual_precision != TYPE_PRECISION (type1) |
1236 | 1491 | fold_convert (type2, mult_rhs2), | 1679 | || from_unsigned1 != TYPE_UNSIGNED (type1)) |
1237 | 1680 | { | ||
1238 | 1681 | tmp = create_tmp_var (build_nonstandard_integer_type | ||
1239 | 1682 | (actual_precision, from_unsigned1), | ||
1240 | 1683 | NULL); | ||
1241 | 1684 | mult_rhs1 = build_and_insert_cast (gsi, loc, tmp, mult_rhs1); | ||
1242 | 1685 | } | ||
1243 | 1686 | if (actual_precision != TYPE_PRECISION (type2) | ||
1244 | 1687 | || from_unsigned2 != TYPE_UNSIGNED (type2)) | ||
1245 | 1688 | { | ||
1246 | 1689 | if (!tmp || from_unsigned1 != from_unsigned2) | ||
1247 | 1690 | tmp = create_tmp_var (build_nonstandard_integer_type | ||
1248 | 1691 | (actual_precision, from_unsigned2), | ||
1249 | 1692 | NULL); | ||
1250 | 1693 | mult_rhs2 = build_and_insert_cast (gsi, loc, tmp, mult_rhs2); | ||
1251 | 1694 | } | ||
1252 | 1695 | |||
1253 | 1696 | if (!useless_type_conversion_p (type, TREE_TYPE (add_rhs))) | ||
1254 | 1697 | add_rhs = build_and_insert_cast (gsi, loc, create_tmp_var (type, NULL), | ||
1255 | 1698 | add_rhs); | ||
1256 | 1699 | |||
1257 | 1700 | /* Handle constants. */ | ||
1258 | 1701 | if (TREE_CODE (mult_rhs1) == INTEGER_CST) | ||
1259 | 1702 | rhs1 = fold_convert (type1, mult_rhs1); | ||
1260 | 1703 | if (TREE_CODE (mult_rhs2) == INTEGER_CST) | ||
1261 | 1704 | rhs2 = fold_convert (type2, mult_rhs2); | ||
1262 | 1705 | |||
1263 | 1706 | gimple_assign_set_rhs_with_ops_1 (gsi, wmult_code, mult_rhs1, mult_rhs2, | ||
1264 | 1492 | add_rhs); | 1707 | add_rhs); |
1265 | 1493 | update_stmt (gsi_stmt (*gsi)); | 1708 | update_stmt (gsi_stmt (*gsi)); |
1266 | 1494 | return true; | 1709 | return true; |
1267 | @@ -1696,7 +1911,7 @@ | |||
1268 | 1696 | switch (code) | 1911 | switch (code) |
1269 | 1697 | { | 1912 | { |
1270 | 1698 | case MULT_EXPR: | 1913 | case MULT_EXPR: |
1272 | 1699 | if (!convert_mult_to_widen (stmt) | 1914 | if (!convert_mult_to_widen (stmt, &gsi) |
1273 | 1700 | && convert_mult_to_fma (stmt, | 1915 | && convert_mult_to_fma (stmt, |
1274 | 1701 | gimple_assign_rhs1 (stmt), | 1916 | gimple_assign_rhs1 (stmt), |
1275 | 1702 | gimple_assign_rhs2 (stmt))) | 1917 | gimple_assign_rhs2 (stmt))) |
cbuild has taken a snapshot of this branch at r106781 and queued it for build.
The snapshot is available at: ex.seabright. co.nz/snapshots /gcc-linaro- 4.6+bzr106781~ ams-codesourcer y~widening- multiplies- 4.6.tar. xdelta3. xz
http://
and will be built on the following builders:
a9-builder armv5-builder i686 x86_64
You can track the build queue at: ex.seabright. co.nz/helpers/ scheduler
http://
cbuild-snapshot: gcc-linaro- 4.6+bzr106781~ ams-codesourcer y~widening- multiplies- 4.6
cbuild-ancestor: lp:gcc-linaro/4.6+bzr106774
cbuild-state: check