annotate gcc/compare-elim.c @ 16:04ced10e8804

gcc 7
author kono
date Fri, 27 Oct 2017 22:46:09 +0900
parents 561a7518be6b
children 84e7813d76e9
Ignore whitespace changes - Everywhere: Within whitespace: At end of lines:
rev   line source
15
561a7518be6b update gcc-4.6
Nobuyasu Oshiro <dimolto@cr.ie.u-ryukyu.ac.jp>
parents:
diff changeset
1 /* Post-reload compare elimination.
16
kono
parents: 15
diff changeset
2 Copyright (C) 2010-2017 Free Software Foundation, Inc.
15
561a7518be6b update gcc-4.6
Nobuyasu Oshiro <dimolto@cr.ie.u-ryukyu.ac.jp>
parents:
diff changeset
3
561a7518be6b update gcc-4.6
Nobuyasu Oshiro <dimolto@cr.ie.u-ryukyu.ac.jp>
parents:
diff changeset
4 This file is part of GCC.
561a7518be6b update gcc-4.6
Nobuyasu Oshiro <dimolto@cr.ie.u-ryukyu.ac.jp>
parents:
diff changeset
5
561a7518be6b update gcc-4.6
Nobuyasu Oshiro <dimolto@cr.ie.u-ryukyu.ac.jp>
parents:
diff changeset
6 GCC is free software; you can redistribute it and/or modify it under
561a7518be6b update gcc-4.6
Nobuyasu Oshiro <dimolto@cr.ie.u-ryukyu.ac.jp>
parents:
diff changeset
7 the terms of the GNU General Public License as published by the Free
561a7518be6b update gcc-4.6
Nobuyasu Oshiro <dimolto@cr.ie.u-ryukyu.ac.jp>
parents:
diff changeset
8 Software Foundation; either version 3, or (at your option) any later
561a7518be6b update gcc-4.6
Nobuyasu Oshiro <dimolto@cr.ie.u-ryukyu.ac.jp>
parents:
diff changeset
9 version.
561a7518be6b update gcc-4.6
Nobuyasu Oshiro <dimolto@cr.ie.u-ryukyu.ac.jp>
parents:
diff changeset
10
561a7518be6b update gcc-4.6
Nobuyasu Oshiro <dimolto@cr.ie.u-ryukyu.ac.jp>
parents:
diff changeset
11 GCC is distributed in the hope that it will be useful, but WITHOUT ANY
561a7518be6b update gcc-4.6
Nobuyasu Oshiro <dimolto@cr.ie.u-ryukyu.ac.jp>
parents:
diff changeset
12 WARRANTY; without even the implied warranty of MERCHANTABILITY or
561a7518be6b update gcc-4.6
Nobuyasu Oshiro <dimolto@cr.ie.u-ryukyu.ac.jp>
parents:
diff changeset
13 FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License
561a7518be6b update gcc-4.6
Nobuyasu Oshiro <dimolto@cr.ie.u-ryukyu.ac.jp>
parents:
diff changeset
14 for more details.
561a7518be6b update gcc-4.6
Nobuyasu Oshiro <dimolto@cr.ie.u-ryukyu.ac.jp>
parents:
diff changeset
15
561a7518be6b update gcc-4.6
Nobuyasu Oshiro <dimolto@cr.ie.u-ryukyu.ac.jp>
parents:
diff changeset
16 You should have received a copy of the GNU General Public License
561a7518be6b update gcc-4.6
Nobuyasu Oshiro <dimolto@cr.ie.u-ryukyu.ac.jp>
parents:
diff changeset
17 along with GCC; see the file COPYING3. If not see
561a7518be6b update gcc-4.6
Nobuyasu Oshiro <dimolto@cr.ie.u-ryukyu.ac.jp>
parents:
diff changeset
18 <http://www.gnu.org/licenses/>. */
561a7518be6b update gcc-4.6
Nobuyasu Oshiro <dimolto@cr.ie.u-ryukyu.ac.jp>
parents:
diff changeset
19
561a7518be6b update gcc-4.6
Nobuyasu Oshiro <dimolto@cr.ie.u-ryukyu.ac.jp>
parents:
diff changeset
20 /* There is a set of targets whose general-purpose move or addition
561a7518be6b update gcc-4.6
Nobuyasu Oshiro <dimolto@cr.ie.u-ryukyu.ac.jp>
parents:
diff changeset
21 instructions clobber the flags. These targets cannot split their
561a7518be6b update gcc-4.6
Nobuyasu Oshiro <dimolto@cr.ie.u-ryukyu.ac.jp>
parents:
diff changeset
22 CBRANCH/CSTORE etc patterns before reload is complete, lest reload
561a7518be6b update gcc-4.6
Nobuyasu Oshiro <dimolto@cr.ie.u-ryukyu.ac.jp>
parents:
diff changeset
23 itself insert these instructions in between the flags setter and user.
561a7518be6b update gcc-4.6
Nobuyasu Oshiro <dimolto@cr.ie.u-ryukyu.ac.jp>
parents:
diff changeset
24 Because these targets cannot split the compare from the use, they
561a7518be6b update gcc-4.6
Nobuyasu Oshiro <dimolto@cr.ie.u-ryukyu.ac.jp>
parents:
diff changeset
25 cannot make use of the comparison elimination offered by the combine pass.
561a7518be6b update gcc-4.6
Nobuyasu Oshiro <dimolto@cr.ie.u-ryukyu.ac.jp>
parents:
diff changeset
26
561a7518be6b update gcc-4.6
Nobuyasu Oshiro <dimolto@cr.ie.u-ryukyu.ac.jp>
parents:
diff changeset
27 This is a small pass intended to provide comparison elimination similar to
561a7518be6b update gcc-4.6
Nobuyasu Oshiro <dimolto@cr.ie.u-ryukyu.ac.jp>
parents:
diff changeset
28 what is available via NOTICE_UPDATE_CC for cc0 targets. This should help
561a7518be6b update gcc-4.6
Nobuyasu Oshiro <dimolto@cr.ie.u-ryukyu.ac.jp>
parents:
diff changeset
29 encourage cc0 targets to convert to an explicit post-reload representation
561a7518be6b update gcc-4.6
Nobuyasu Oshiro <dimolto@cr.ie.u-ryukyu.ac.jp>
parents:
diff changeset
30 of the flags.
561a7518be6b update gcc-4.6
Nobuyasu Oshiro <dimolto@cr.ie.u-ryukyu.ac.jp>
parents:
diff changeset
31
561a7518be6b update gcc-4.6
Nobuyasu Oshiro <dimolto@cr.ie.u-ryukyu.ac.jp>
parents:
diff changeset
32 This pass assumes:
561a7518be6b update gcc-4.6
Nobuyasu Oshiro <dimolto@cr.ie.u-ryukyu.ac.jp>
parents:
diff changeset
33
561a7518be6b update gcc-4.6
Nobuyasu Oshiro <dimolto@cr.ie.u-ryukyu.ac.jp>
parents:
diff changeset
34 (0) CBRANCH/CSTORE etc have been split in pass_split_after_reload.
561a7518be6b update gcc-4.6
Nobuyasu Oshiro <dimolto@cr.ie.u-ryukyu.ac.jp>
parents:
diff changeset
35
561a7518be6b update gcc-4.6
Nobuyasu Oshiro <dimolto@cr.ie.u-ryukyu.ac.jp>
parents:
diff changeset
36 (1) All comparison patterns are represented as
561a7518be6b update gcc-4.6
Nobuyasu Oshiro <dimolto@cr.ie.u-ryukyu.ac.jp>
parents:
diff changeset
37
16
kono
parents: 15
diff changeset
38 [(set (reg:CC) (compare:CC (reg) (reg_or_immediate)))]
15
561a7518be6b update gcc-4.6
Nobuyasu Oshiro <dimolto@cr.ie.u-ryukyu.ac.jp>
parents:
diff changeset
39
561a7518be6b update gcc-4.6
Nobuyasu Oshiro <dimolto@cr.ie.u-ryukyu.ac.jp>
parents:
diff changeset
40 (2) All insn patterns that modify the flags are represented as
561a7518be6b update gcc-4.6
Nobuyasu Oshiro <dimolto@cr.ie.u-ryukyu.ac.jp>
parents:
diff changeset
41
561a7518be6b update gcc-4.6
Nobuyasu Oshiro <dimolto@cr.ie.u-ryukyu.ac.jp>
parents:
diff changeset
42 [(set (reg) (operation)
561a7518be6b update gcc-4.6
Nobuyasu Oshiro <dimolto@cr.ie.u-ryukyu.ac.jp>
parents:
diff changeset
43 (clobber (reg:CC))]
561a7518be6b update gcc-4.6
Nobuyasu Oshiro <dimolto@cr.ie.u-ryukyu.ac.jp>
parents:
diff changeset
44
561a7518be6b update gcc-4.6
Nobuyasu Oshiro <dimolto@cr.ie.u-ryukyu.ac.jp>
parents:
diff changeset
45 (3) If an insn of form (2) can usefully set the flags, there is
561a7518be6b update gcc-4.6
Nobuyasu Oshiro <dimolto@cr.ie.u-ryukyu.ac.jp>
parents:
diff changeset
46 another pattern of the form
561a7518be6b update gcc-4.6
Nobuyasu Oshiro <dimolto@cr.ie.u-ryukyu.ac.jp>
parents:
diff changeset
47
16
kono
parents: 15
diff changeset
48 [(set (reg:CCM) (compare:CCM (operation) (immediate)))
kono
parents: 15
diff changeset
49 (set (reg) (operation)]
kono
parents: 15
diff changeset
50
15
561a7518be6b update gcc-4.6
Nobuyasu Oshiro <dimolto@cr.ie.u-ryukyu.ac.jp>
parents:
diff changeset
51 The mode CCM will be chosen as if by SELECT_CC_MODE.
561a7518be6b update gcc-4.6
Nobuyasu Oshiro <dimolto@cr.ie.u-ryukyu.ac.jp>
parents:
diff changeset
52
561a7518be6b update gcc-4.6
Nobuyasu Oshiro <dimolto@cr.ie.u-ryukyu.ac.jp>
parents:
diff changeset
53 Note that unlike NOTICE_UPDATE_CC, we do not handle memory operands.
561a7518be6b update gcc-4.6
Nobuyasu Oshiro <dimolto@cr.ie.u-ryukyu.ac.jp>
parents:
diff changeset
54 This could be handled as a future enhancement.
561a7518be6b update gcc-4.6
Nobuyasu Oshiro <dimolto@cr.ie.u-ryukyu.ac.jp>
parents:
diff changeset
55 */
561a7518be6b update gcc-4.6
Nobuyasu Oshiro <dimolto@cr.ie.u-ryukyu.ac.jp>
parents:
diff changeset
56
561a7518be6b update gcc-4.6
Nobuyasu Oshiro <dimolto@cr.ie.u-ryukyu.ac.jp>
parents:
diff changeset
57 #include "config.h"
561a7518be6b update gcc-4.6
Nobuyasu Oshiro <dimolto@cr.ie.u-ryukyu.ac.jp>
parents:
diff changeset
58 #include "system.h"
561a7518be6b update gcc-4.6
Nobuyasu Oshiro <dimolto@cr.ie.u-ryukyu.ac.jp>
parents:
diff changeset
59 #include "coretypes.h"
16
kono
parents: 15
diff changeset
60 #include "backend.h"
kono
parents: 15
diff changeset
61 #include "target.h"
15
561a7518be6b update gcc-4.6
Nobuyasu Oshiro <dimolto@cr.ie.u-ryukyu.ac.jp>
parents:
diff changeset
62 #include "rtl.h"
16
kono
parents: 15
diff changeset
63 #include "df.h"
kono
parents: 15
diff changeset
64 #include "memmodel.h"
15
561a7518be6b update gcc-4.6
Nobuyasu Oshiro <dimolto@cr.ie.u-ryukyu.ac.jp>
parents:
diff changeset
65 #include "tm_p.h"
561a7518be6b update gcc-4.6
Nobuyasu Oshiro <dimolto@cr.ie.u-ryukyu.ac.jp>
parents:
diff changeset
66 #include "insn-config.h"
561a7518be6b update gcc-4.6
Nobuyasu Oshiro <dimolto@cr.ie.u-ryukyu.ac.jp>
parents:
diff changeset
67 #include "recog.h"
16
kono
parents: 15
diff changeset
68 #include "emit-rtl.h"
kono
parents: 15
diff changeset
69 #include "cfgrtl.h"
15
561a7518be6b update gcc-4.6
Nobuyasu Oshiro <dimolto@cr.ie.u-ryukyu.ac.jp>
parents:
diff changeset
70 #include "tree-pass.h"
561a7518be6b update gcc-4.6
Nobuyasu Oshiro <dimolto@cr.ie.u-ryukyu.ac.jp>
parents:
diff changeset
71 #include "domwalk.h"
561a7518be6b update gcc-4.6
Nobuyasu Oshiro <dimolto@cr.ie.u-ryukyu.ac.jp>
parents:
diff changeset
72
561a7518be6b update gcc-4.6
Nobuyasu Oshiro <dimolto@cr.ie.u-ryukyu.ac.jp>
parents:
diff changeset
73
561a7518be6b update gcc-4.6
Nobuyasu Oshiro <dimolto@cr.ie.u-ryukyu.ac.jp>
parents:
diff changeset
74 /* These structures describe a comparison and how it is used. */
561a7518be6b update gcc-4.6
Nobuyasu Oshiro <dimolto@cr.ie.u-ryukyu.ac.jp>
parents:
diff changeset
75
561a7518be6b update gcc-4.6
Nobuyasu Oshiro <dimolto@cr.ie.u-ryukyu.ac.jp>
parents:
diff changeset
76 /* The choice of maximum 3 uses comes from wanting to eliminate the two
561a7518be6b update gcc-4.6
Nobuyasu Oshiro <dimolto@cr.ie.u-ryukyu.ac.jp>
parents:
diff changeset
77 duplicate compares from a three-way branch on the sign of a value.
561a7518be6b update gcc-4.6
Nobuyasu Oshiro <dimolto@cr.ie.u-ryukyu.ac.jp>
parents:
diff changeset
78 This is also sufficient to eliminate the duplicate compare against the
561a7518be6b update gcc-4.6
Nobuyasu Oshiro <dimolto@cr.ie.u-ryukyu.ac.jp>
parents:
diff changeset
79 high-part of a double-word comparison. */
561a7518be6b update gcc-4.6
Nobuyasu Oshiro <dimolto@cr.ie.u-ryukyu.ac.jp>
parents:
diff changeset
80 #define MAX_CMP_USE 3
561a7518be6b update gcc-4.6
Nobuyasu Oshiro <dimolto@cr.ie.u-ryukyu.ac.jp>
parents:
diff changeset
81
561a7518be6b update gcc-4.6
Nobuyasu Oshiro <dimolto@cr.ie.u-ryukyu.ac.jp>
parents:
diff changeset
82 struct comparison_use
561a7518be6b update gcc-4.6
Nobuyasu Oshiro <dimolto@cr.ie.u-ryukyu.ac.jp>
parents:
diff changeset
83 {
561a7518be6b update gcc-4.6
Nobuyasu Oshiro <dimolto@cr.ie.u-ryukyu.ac.jp>
parents:
diff changeset
84 /* The instruction in which the result of the compare is used. */
16
kono
parents: 15
diff changeset
85 rtx_insn *insn;
15
561a7518be6b update gcc-4.6
Nobuyasu Oshiro <dimolto@cr.ie.u-ryukyu.ac.jp>
parents:
diff changeset
86 /* The location of the flags register within the use. */
561a7518be6b update gcc-4.6
Nobuyasu Oshiro <dimolto@cr.ie.u-ryukyu.ac.jp>
parents:
diff changeset
87 rtx *loc;
561a7518be6b update gcc-4.6
Nobuyasu Oshiro <dimolto@cr.ie.u-ryukyu.ac.jp>
parents:
diff changeset
88 /* The comparison code applied against the flags register. */
561a7518be6b update gcc-4.6
Nobuyasu Oshiro <dimolto@cr.ie.u-ryukyu.ac.jp>
parents:
diff changeset
89 enum rtx_code code;
561a7518be6b update gcc-4.6
Nobuyasu Oshiro <dimolto@cr.ie.u-ryukyu.ac.jp>
parents:
diff changeset
90 };
561a7518be6b update gcc-4.6
Nobuyasu Oshiro <dimolto@cr.ie.u-ryukyu.ac.jp>
parents:
diff changeset
91
561a7518be6b update gcc-4.6
Nobuyasu Oshiro <dimolto@cr.ie.u-ryukyu.ac.jp>
parents:
diff changeset
92 struct comparison
561a7518be6b update gcc-4.6
Nobuyasu Oshiro <dimolto@cr.ie.u-ryukyu.ac.jp>
parents:
diff changeset
93 {
561a7518be6b update gcc-4.6
Nobuyasu Oshiro <dimolto@cr.ie.u-ryukyu.ac.jp>
parents:
diff changeset
94 /* The comparison instruction. */
16
kono
parents: 15
diff changeset
95 rtx_insn *insn;
15
561a7518be6b update gcc-4.6
Nobuyasu Oshiro <dimolto@cr.ie.u-ryukyu.ac.jp>
parents:
diff changeset
96
561a7518be6b update gcc-4.6
Nobuyasu Oshiro <dimolto@cr.ie.u-ryukyu.ac.jp>
parents:
diff changeset
97 /* The insn prior to the comparison insn that clobbers the flags. */
16
kono
parents: 15
diff changeset
98 rtx_insn *prev_clobber;
15
561a7518be6b update gcc-4.6
Nobuyasu Oshiro <dimolto@cr.ie.u-ryukyu.ac.jp>
parents:
diff changeset
99
561a7518be6b update gcc-4.6
Nobuyasu Oshiro <dimolto@cr.ie.u-ryukyu.ac.jp>
parents:
diff changeset
100 /* The two values being compared. These will be either REGs or
561a7518be6b update gcc-4.6
Nobuyasu Oshiro <dimolto@cr.ie.u-ryukyu.ac.jp>
parents:
diff changeset
101 constants. */
561a7518be6b update gcc-4.6
Nobuyasu Oshiro <dimolto@cr.ie.u-ryukyu.ac.jp>
parents:
diff changeset
102 rtx in_a, in_b;
561a7518be6b update gcc-4.6
Nobuyasu Oshiro <dimolto@cr.ie.u-ryukyu.ac.jp>
parents:
diff changeset
103
16
kono
parents: 15
diff changeset
104 /* The REG_EH_REGION of the comparison. */
kono
parents: 15
diff changeset
105 rtx eh_note;
kono
parents: 15
diff changeset
106
15
561a7518be6b update gcc-4.6
Nobuyasu Oshiro <dimolto@cr.ie.u-ryukyu.ac.jp>
parents:
diff changeset
107 /* Information about how this comparison is used. */
561a7518be6b update gcc-4.6
Nobuyasu Oshiro <dimolto@cr.ie.u-ryukyu.ac.jp>
parents:
diff changeset
108 struct comparison_use uses[MAX_CMP_USE];
561a7518be6b update gcc-4.6
Nobuyasu Oshiro <dimolto@cr.ie.u-ryukyu.ac.jp>
parents:
diff changeset
109
561a7518be6b update gcc-4.6
Nobuyasu Oshiro <dimolto@cr.ie.u-ryukyu.ac.jp>
parents:
diff changeset
110 /* The original CC_MODE for this comparison. */
16
kono
parents: 15
diff changeset
111 machine_mode orig_mode;
15
561a7518be6b update gcc-4.6
Nobuyasu Oshiro <dimolto@cr.ie.u-ryukyu.ac.jp>
parents:
diff changeset
112
561a7518be6b update gcc-4.6
Nobuyasu Oshiro <dimolto@cr.ie.u-ryukyu.ac.jp>
parents:
diff changeset
113 /* The number of uses identified for this comparison. */
561a7518be6b update gcc-4.6
Nobuyasu Oshiro <dimolto@cr.ie.u-ryukyu.ac.jp>
parents:
diff changeset
114 unsigned short n_uses;
561a7518be6b update gcc-4.6
Nobuyasu Oshiro <dimolto@cr.ie.u-ryukyu.ac.jp>
parents:
diff changeset
115
561a7518be6b update gcc-4.6
Nobuyasu Oshiro <dimolto@cr.ie.u-ryukyu.ac.jp>
parents:
diff changeset
116 /* True if not all uses of this comparison have been identified.
561a7518be6b update gcc-4.6
Nobuyasu Oshiro <dimolto@cr.ie.u-ryukyu.ac.jp>
parents:
diff changeset
117 This can happen either for overflowing the array above, or if
561a7518be6b update gcc-4.6
Nobuyasu Oshiro <dimolto@cr.ie.u-ryukyu.ac.jp>
parents:
diff changeset
118 the flags register is used in some unusual context. */
561a7518be6b update gcc-4.6
Nobuyasu Oshiro <dimolto@cr.ie.u-ryukyu.ac.jp>
parents:
diff changeset
119 bool missing_uses;
561a7518be6b update gcc-4.6
Nobuyasu Oshiro <dimolto@cr.ie.u-ryukyu.ac.jp>
parents:
diff changeset
120
561a7518be6b update gcc-4.6
Nobuyasu Oshiro <dimolto@cr.ie.u-ryukyu.ac.jp>
parents:
diff changeset
121 /* True if its inputs are still valid at the end of the block. */
561a7518be6b update gcc-4.6
Nobuyasu Oshiro <dimolto@cr.ie.u-ryukyu.ac.jp>
parents:
diff changeset
122 bool inputs_valid;
561a7518be6b update gcc-4.6
Nobuyasu Oshiro <dimolto@cr.ie.u-ryukyu.ac.jp>
parents:
diff changeset
123 };
561a7518be6b update gcc-4.6
Nobuyasu Oshiro <dimolto@cr.ie.u-ryukyu.ac.jp>
parents:
diff changeset
124
16
kono
parents: 15
diff changeset
125 static vec<comparison *> all_compares;
15
561a7518be6b update gcc-4.6
Nobuyasu Oshiro <dimolto@cr.ie.u-ryukyu.ac.jp>
parents:
diff changeset
126
561a7518be6b update gcc-4.6
Nobuyasu Oshiro <dimolto@cr.ie.u-ryukyu.ac.jp>
parents:
diff changeset
127 /* Look for a "conforming" comparison, as defined above. If valid, return
561a7518be6b update gcc-4.6
Nobuyasu Oshiro <dimolto@cr.ie.u-ryukyu.ac.jp>
parents:
diff changeset
128 the rtx for the COMPARE itself. */
561a7518be6b update gcc-4.6
Nobuyasu Oshiro <dimolto@cr.ie.u-ryukyu.ac.jp>
parents:
diff changeset
129
561a7518be6b update gcc-4.6
Nobuyasu Oshiro <dimolto@cr.ie.u-ryukyu.ac.jp>
parents:
diff changeset
130 static rtx
16
kono
parents: 15
diff changeset
131 conforming_compare (rtx_insn *insn)
15
561a7518be6b update gcc-4.6
Nobuyasu Oshiro <dimolto@cr.ie.u-ryukyu.ac.jp>
parents:
diff changeset
132 {
561a7518be6b update gcc-4.6
Nobuyasu Oshiro <dimolto@cr.ie.u-ryukyu.ac.jp>
parents:
diff changeset
133 rtx set, src, dest;
561a7518be6b update gcc-4.6
Nobuyasu Oshiro <dimolto@cr.ie.u-ryukyu.ac.jp>
parents:
diff changeset
134
561a7518be6b update gcc-4.6
Nobuyasu Oshiro <dimolto@cr.ie.u-ryukyu.ac.jp>
parents:
diff changeset
135 set = single_set (insn);
561a7518be6b update gcc-4.6
Nobuyasu Oshiro <dimolto@cr.ie.u-ryukyu.ac.jp>
parents:
diff changeset
136 if (set == NULL)
561a7518be6b update gcc-4.6
Nobuyasu Oshiro <dimolto@cr.ie.u-ryukyu.ac.jp>
parents:
diff changeset
137 return NULL;
561a7518be6b update gcc-4.6
Nobuyasu Oshiro <dimolto@cr.ie.u-ryukyu.ac.jp>
parents:
diff changeset
138
561a7518be6b update gcc-4.6
Nobuyasu Oshiro <dimolto@cr.ie.u-ryukyu.ac.jp>
parents:
diff changeset
139 src = SET_SRC (set);
561a7518be6b update gcc-4.6
Nobuyasu Oshiro <dimolto@cr.ie.u-ryukyu.ac.jp>
parents:
diff changeset
140 if (GET_CODE (src) != COMPARE)
561a7518be6b update gcc-4.6
Nobuyasu Oshiro <dimolto@cr.ie.u-ryukyu.ac.jp>
parents:
diff changeset
141 return NULL;
561a7518be6b update gcc-4.6
Nobuyasu Oshiro <dimolto@cr.ie.u-ryukyu.ac.jp>
parents:
diff changeset
142
561a7518be6b update gcc-4.6
Nobuyasu Oshiro <dimolto@cr.ie.u-ryukyu.ac.jp>
parents:
diff changeset
143 dest = SET_DEST (set);
561a7518be6b update gcc-4.6
Nobuyasu Oshiro <dimolto@cr.ie.u-ryukyu.ac.jp>
parents:
diff changeset
144 if (!REG_P (dest) || REGNO (dest) != targetm.flags_regnum)
561a7518be6b update gcc-4.6
Nobuyasu Oshiro <dimolto@cr.ie.u-ryukyu.ac.jp>
parents:
diff changeset
145 return NULL;
561a7518be6b update gcc-4.6
Nobuyasu Oshiro <dimolto@cr.ie.u-ryukyu.ac.jp>
parents:
diff changeset
146
16
kono
parents: 15
diff changeset
147 if (!REG_P (XEXP (src, 0)))
kono
parents: 15
diff changeset
148 return NULL;
kono
parents: 15
diff changeset
149
kono
parents: 15
diff changeset
150 if (CONSTANT_P (XEXP (src, 1)) || REG_P (XEXP (src, 1)))
15
561a7518be6b update gcc-4.6
Nobuyasu Oshiro <dimolto@cr.ie.u-ryukyu.ac.jp>
parents:
diff changeset
151 return src;
561a7518be6b update gcc-4.6
Nobuyasu Oshiro <dimolto@cr.ie.u-ryukyu.ac.jp>
parents:
diff changeset
152
16
kono
parents: 15
diff changeset
153 if (GET_CODE (XEXP (src, 1)) == UNSPEC)
kono
parents: 15
diff changeset
154 {
kono
parents: 15
diff changeset
155 for (int i = 0; i < XVECLEN (XEXP (src, 1), 0); i++)
kono
parents: 15
diff changeset
156 if (!REG_P (XVECEXP (XEXP (src, 1), 0, i)))
kono
parents: 15
diff changeset
157 return NULL;
kono
parents: 15
diff changeset
158 return src;
kono
parents: 15
diff changeset
159 }
kono
parents: 15
diff changeset
160
15
561a7518be6b update gcc-4.6
Nobuyasu Oshiro <dimolto@cr.ie.u-ryukyu.ac.jp>
parents:
diff changeset
161 return NULL;
561a7518be6b update gcc-4.6
Nobuyasu Oshiro <dimolto@cr.ie.u-ryukyu.ac.jp>
parents:
diff changeset
162 }
561a7518be6b update gcc-4.6
Nobuyasu Oshiro <dimolto@cr.ie.u-ryukyu.ac.jp>
parents:
diff changeset
163
561a7518be6b update gcc-4.6
Nobuyasu Oshiro <dimolto@cr.ie.u-ryukyu.ac.jp>
parents:
diff changeset
164 /* Look for a pattern of the "correct" form for an insn with a flags clobber
561a7518be6b update gcc-4.6
Nobuyasu Oshiro <dimolto@cr.ie.u-ryukyu.ac.jp>
parents:
diff changeset
165 for which we may be able to eliminate a compare later. We're not looking
561a7518be6b update gcc-4.6
Nobuyasu Oshiro <dimolto@cr.ie.u-ryukyu.ac.jp>
parents:
diff changeset
166 to validate any inputs at this time, merely see that the basic shape is
561a7518be6b update gcc-4.6
Nobuyasu Oshiro <dimolto@cr.ie.u-ryukyu.ac.jp>
parents:
diff changeset
167 correct. The term "arithmetic" may be somewhat misleading... */
561a7518be6b update gcc-4.6
Nobuyasu Oshiro <dimolto@cr.ie.u-ryukyu.ac.jp>
parents:
diff changeset
168
561a7518be6b update gcc-4.6
Nobuyasu Oshiro <dimolto@cr.ie.u-ryukyu.ac.jp>
parents:
diff changeset
169 static bool
16
kono
parents: 15
diff changeset
170 arithmetic_flags_clobber_p (rtx_insn *insn)
15
561a7518be6b update gcc-4.6
Nobuyasu Oshiro <dimolto@cr.ie.u-ryukyu.ac.jp>
parents:
diff changeset
171 {
561a7518be6b update gcc-4.6
Nobuyasu Oshiro <dimolto@cr.ie.u-ryukyu.ac.jp>
parents:
diff changeset
172 rtx pat, x;
561a7518be6b update gcc-4.6
Nobuyasu Oshiro <dimolto@cr.ie.u-ryukyu.ac.jp>
parents:
diff changeset
173
561a7518be6b update gcc-4.6
Nobuyasu Oshiro <dimolto@cr.ie.u-ryukyu.ac.jp>
parents:
diff changeset
174 if (!NONJUMP_INSN_P (insn))
561a7518be6b update gcc-4.6
Nobuyasu Oshiro <dimolto@cr.ie.u-ryukyu.ac.jp>
parents:
diff changeset
175 return false;
561a7518be6b update gcc-4.6
Nobuyasu Oshiro <dimolto@cr.ie.u-ryukyu.ac.jp>
parents:
diff changeset
176 pat = PATTERN (insn);
16
kono
parents: 15
diff changeset
177 if (asm_noperands (pat) >= 0)
15
561a7518be6b update gcc-4.6
Nobuyasu Oshiro <dimolto@cr.ie.u-ryukyu.ac.jp>
parents:
diff changeset
178 return false;
561a7518be6b update gcc-4.6
Nobuyasu Oshiro <dimolto@cr.ie.u-ryukyu.ac.jp>
parents:
diff changeset
179
561a7518be6b update gcc-4.6
Nobuyasu Oshiro <dimolto@cr.ie.u-ryukyu.ac.jp>
parents:
diff changeset
180 if (GET_CODE (pat) == PARALLEL && XVECLEN (pat, 0) == 2)
561a7518be6b update gcc-4.6
Nobuyasu Oshiro <dimolto@cr.ie.u-ryukyu.ac.jp>
parents:
diff changeset
181 {
561a7518be6b update gcc-4.6
Nobuyasu Oshiro <dimolto@cr.ie.u-ryukyu.ac.jp>
parents:
diff changeset
182 x = XVECEXP (pat, 0, 0);
561a7518be6b update gcc-4.6
Nobuyasu Oshiro <dimolto@cr.ie.u-ryukyu.ac.jp>
parents:
diff changeset
183 if (GET_CODE (x) != SET)
561a7518be6b update gcc-4.6
Nobuyasu Oshiro <dimolto@cr.ie.u-ryukyu.ac.jp>
parents:
diff changeset
184 return false;
561a7518be6b update gcc-4.6
Nobuyasu Oshiro <dimolto@cr.ie.u-ryukyu.ac.jp>
parents:
diff changeset
185 x = SET_DEST (x);
561a7518be6b update gcc-4.6
Nobuyasu Oshiro <dimolto@cr.ie.u-ryukyu.ac.jp>
parents:
diff changeset
186 if (!REG_P (x))
561a7518be6b update gcc-4.6
Nobuyasu Oshiro <dimolto@cr.ie.u-ryukyu.ac.jp>
parents:
diff changeset
187 return false;
561a7518be6b update gcc-4.6
Nobuyasu Oshiro <dimolto@cr.ie.u-ryukyu.ac.jp>
parents:
diff changeset
188
561a7518be6b update gcc-4.6
Nobuyasu Oshiro <dimolto@cr.ie.u-ryukyu.ac.jp>
parents:
diff changeset
189 x = XVECEXP (pat, 0, 1);
561a7518be6b update gcc-4.6
Nobuyasu Oshiro <dimolto@cr.ie.u-ryukyu.ac.jp>
parents:
diff changeset
190 if (GET_CODE (x) == CLOBBER)
561a7518be6b update gcc-4.6
Nobuyasu Oshiro <dimolto@cr.ie.u-ryukyu.ac.jp>
parents:
diff changeset
191 {
561a7518be6b update gcc-4.6
Nobuyasu Oshiro <dimolto@cr.ie.u-ryukyu.ac.jp>
parents:
diff changeset
192 x = XEXP (x, 0);
561a7518be6b update gcc-4.6
Nobuyasu Oshiro <dimolto@cr.ie.u-ryukyu.ac.jp>
parents:
diff changeset
193 if (REG_P (x) && REGNO (x) == targetm.flags_regnum)
561a7518be6b update gcc-4.6
Nobuyasu Oshiro <dimolto@cr.ie.u-ryukyu.ac.jp>
parents:
diff changeset
194 return true;
561a7518be6b update gcc-4.6
Nobuyasu Oshiro <dimolto@cr.ie.u-ryukyu.ac.jp>
parents:
diff changeset
195 }
561a7518be6b update gcc-4.6
Nobuyasu Oshiro <dimolto@cr.ie.u-ryukyu.ac.jp>
parents:
diff changeset
196 }
561a7518be6b update gcc-4.6
Nobuyasu Oshiro <dimolto@cr.ie.u-ryukyu.ac.jp>
parents:
diff changeset
197
561a7518be6b update gcc-4.6
Nobuyasu Oshiro <dimolto@cr.ie.u-ryukyu.ac.jp>
parents:
diff changeset
198 return false;
561a7518be6b update gcc-4.6
Nobuyasu Oshiro <dimolto@cr.ie.u-ryukyu.ac.jp>
parents:
diff changeset
199 }
561a7518be6b update gcc-4.6
Nobuyasu Oshiro <dimolto@cr.ie.u-ryukyu.ac.jp>
parents:
diff changeset
200
561a7518be6b update gcc-4.6
Nobuyasu Oshiro <dimolto@cr.ie.u-ryukyu.ac.jp>
parents:
diff changeset
201 /* Look for uses of FLAGS in INSN. If we find one we can analyze, record
561a7518be6b update gcc-4.6
Nobuyasu Oshiro <dimolto@cr.ie.u-ryukyu.ac.jp>
parents:
diff changeset
202 it in CMP; otherwise indicate that we've missed a use. */
561a7518be6b update gcc-4.6
Nobuyasu Oshiro <dimolto@cr.ie.u-ryukyu.ac.jp>
parents:
diff changeset
203
561a7518be6b update gcc-4.6
Nobuyasu Oshiro <dimolto@cr.ie.u-ryukyu.ac.jp>
parents:
diff changeset
204 static void
16
kono
parents: 15
diff changeset
205 find_flags_uses_in_insn (struct comparison *cmp, rtx_insn *insn)
15
561a7518be6b update gcc-4.6
Nobuyasu Oshiro <dimolto@cr.ie.u-ryukyu.ac.jp>
parents:
diff changeset
206 {
16
kono
parents: 15
diff changeset
207 df_ref use;
15
561a7518be6b update gcc-4.6
Nobuyasu Oshiro <dimolto@cr.ie.u-ryukyu.ac.jp>
parents:
diff changeset
208
561a7518be6b update gcc-4.6
Nobuyasu Oshiro <dimolto@cr.ie.u-ryukyu.ac.jp>
parents:
diff changeset
209 /* If we've already lost track of uses, don't bother collecting more. */
561a7518be6b update gcc-4.6
Nobuyasu Oshiro <dimolto@cr.ie.u-ryukyu.ac.jp>
parents:
diff changeset
210 if (cmp->missing_uses)
561a7518be6b update gcc-4.6
Nobuyasu Oshiro <dimolto@cr.ie.u-ryukyu.ac.jp>
parents:
diff changeset
211 return;
561a7518be6b update gcc-4.6
Nobuyasu Oshiro <dimolto@cr.ie.u-ryukyu.ac.jp>
parents:
diff changeset
212
561a7518be6b update gcc-4.6
Nobuyasu Oshiro <dimolto@cr.ie.u-ryukyu.ac.jp>
parents:
diff changeset
213 /* Find a USE of the flags register. */
16
kono
parents: 15
diff changeset
214 FOR_EACH_INSN_USE (use, insn)
15
561a7518be6b update gcc-4.6
Nobuyasu Oshiro <dimolto@cr.ie.u-ryukyu.ac.jp>
parents:
diff changeset
215 if (DF_REF_REGNO (use) == targetm.flags_regnum)
561a7518be6b update gcc-4.6
Nobuyasu Oshiro <dimolto@cr.ie.u-ryukyu.ac.jp>
parents:
diff changeset
216 {
561a7518be6b update gcc-4.6
Nobuyasu Oshiro <dimolto@cr.ie.u-ryukyu.ac.jp>
parents:
diff changeset
217 rtx x, *loc;
561a7518be6b update gcc-4.6
Nobuyasu Oshiro <dimolto@cr.ie.u-ryukyu.ac.jp>
parents:
diff changeset
218
561a7518be6b update gcc-4.6
Nobuyasu Oshiro <dimolto@cr.ie.u-ryukyu.ac.jp>
parents:
diff changeset
219 /* If this is an unusual use, quit. */
561a7518be6b update gcc-4.6
Nobuyasu Oshiro <dimolto@cr.ie.u-ryukyu.ac.jp>
parents:
diff changeset
220 if (DF_REF_TYPE (use) != DF_REF_REG_USE)
561a7518be6b update gcc-4.6
Nobuyasu Oshiro <dimolto@cr.ie.u-ryukyu.ac.jp>
parents:
diff changeset
221 goto fail;
561a7518be6b update gcc-4.6
Nobuyasu Oshiro <dimolto@cr.ie.u-ryukyu.ac.jp>
parents:
diff changeset
222
561a7518be6b update gcc-4.6
Nobuyasu Oshiro <dimolto@cr.ie.u-ryukyu.ac.jp>
parents:
diff changeset
223 /* If we've run out of slots to record uses, quit. */
561a7518be6b update gcc-4.6
Nobuyasu Oshiro <dimolto@cr.ie.u-ryukyu.ac.jp>
parents:
diff changeset
224 if (cmp->n_uses == MAX_CMP_USE)
561a7518be6b update gcc-4.6
Nobuyasu Oshiro <dimolto@cr.ie.u-ryukyu.ac.jp>
parents:
diff changeset
225 goto fail;
561a7518be6b update gcc-4.6
Nobuyasu Oshiro <dimolto@cr.ie.u-ryukyu.ac.jp>
parents:
diff changeset
226
561a7518be6b update gcc-4.6
Nobuyasu Oshiro <dimolto@cr.ie.u-ryukyu.ac.jp>
parents:
diff changeset
227 /* Unfortunately the location of the flags register, while present
561a7518be6b update gcc-4.6
Nobuyasu Oshiro <dimolto@cr.ie.u-ryukyu.ac.jp>
parents:
diff changeset
228 in the reference structure, doesn't help. We need to find the
561a7518be6b update gcc-4.6
Nobuyasu Oshiro <dimolto@cr.ie.u-ryukyu.ac.jp>
parents:
diff changeset
229 comparison code that is outer to the actual flags use. */
561a7518be6b update gcc-4.6
Nobuyasu Oshiro <dimolto@cr.ie.u-ryukyu.ac.jp>
parents:
diff changeset
230 loc = DF_REF_LOC (use);
561a7518be6b update gcc-4.6
Nobuyasu Oshiro <dimolto@cr.ie.u-ryukyu.ac.jp>
parents:
diff changeset
231 x = PATTERN (insn);
561a7518be6b update gcc-4.6
Nobuyasu Oshiro <dimolto@cr.ie.u-ryukyu.ac.jp>
parents:
diff changeset
232 if (GET_CODE (x) == PARALLEL)
561a7518be6b update gcc-4.6
Nobuyasu Oshiro <dimolto@cr.ie.u-ryukyu.ac.jp>
parents:
diff changeset
233 x = XVECEXP (x, 0, 0);
561a7518be6b update gcc-4.6
Nobuyasu Oshiro <dimolto@cr.ie.u-ryukyu.ac.jp>
parents:
diff changeset
234 x = SET_SRC (x);
561a7518be6b update gcc-4.6
Nobuyasu Oshiro <dimolto@cr.ie.u-ryukyu.ac.jp>
parents:
diff changeset
235 if (GET_CODE (x) == IF_THEN_ELSE)
561a7518be6b update gcc-4.6
Nobuyasu Oshiro <dimolto@cr.ie.u-ryukyu.ac.jp>
parents:
diff changeset
236 x = XEXP (x, 0);
561a7518be6b update gcc-4.6
Nobuyasu Oshiro <dimolto@cr.ie.u-ryukyu.ac.jp>
parents:
diff changeset
237 if (COMPARISON_P (x)
561a7518be6b update gcc-4.6
Nobuyasu Oshiro <dimolto@cr.ie.u-ryukyu.ac.jp>
parents:
diff changeset
238 && loc == &XEXP (x, 0)
561a7518be6b update gcc-4.6
Nobuyasu Oshiro <dimolto@cr.ie.u-ryukyu.ac.jp>
parents:
diff changeset
239 && XEXP (x, 1) == const0_rtx)
561a7518be6b update gcc-4.6
Nobuyasu Oshiro <dimolto@cr.ie.u-ryukyu.ac.jp>
parents:
diff changeset
240 {
561a7518be6b update gcc-4.6
Nobuyasu Oshiro <dimolto@cr.ie.u-ryukyu.ac.jp>
parents:
diff changeset
241 /* We've found a use of the flags that we understand. */
561a7518be6b update gcc-4.6
Nobuyasu Oshiro <dimolto@cr.ie.u-ryukyu.ac.jp>
parents:
diff changeset
242 struct comparison_use *cuse = &cmp->uses[cmp->n_uses++];
561a7518be6b update gcc-4.6
Nobuyasu Oshiro <dimolto@cr.ie.u-ryukyu.ac.jp>
parents:
diff changeset
243 cuse->insn = insn;
561a7518be6b update gcc-4.6
Nobuyasu Oshiro <dimolto@cr.ie.u-ryukyu.ac.jp>
parents:
diff changeset
244 cuse->loc = loc;
561a7518be6b update gcc-4.6
Nobuyasu Oshiro <dimolto@cr.ie.u-ryukyu.ac.jp>
parents:
diff changeset
245 cuse->code = GET_CODE (x);
561a7518be6b update gcc-4.6
Nobuyasu Oshiro <dimolto@cr.ie.u-ryukyu.ac.jp>
parents:
diff changeset
246 }
561a7518be6b update gcc-4.6
Nobuyasu Oshiro <dimolto@cr.ie.u-ryukyu.ac.jp>
parents:
diff changeset
247 else
561a7518be6b update gcc-4.6
Nobuyasu Oshiro <dimolto@cr.ie.u-ryukyu.ac.jp>
parents:
diff changeset
248 goto fail;
561a7518be6b update gcc-4.6
Nobuyasu Oshiro <dimolto@cr.ie.u-ryukyu.ac.jp>
parents:
diff changeset
249 }
561a7518be6b update gcc-4.6
Nobuyasu Oshiro <dimolto@cr.ie.u-ryukyu.ac.jp>
parents:
diff changeset
250 return;
561a7518be6b update gcc-4.6
Nobuyasu Oshiro <dimolto@cr.ie.u-ryukyu.ac.jp>
parents:
diff changeset
251
561a7518be6b update gcc-4.6
Nobuyasu Oshiro <dimolto@cr.ie.u-ryukyu.ac.jp>
parents:
diff changeset
252 fail:
561a7518be6b update gcc-4.6
Nobuyasu Oshiro <dimolto@cr.ie.u-ryukyu.ac.jp>
parents:
diff changeset
253 /* We failed to recognize this use of the flags register. */
561a7518be6b update gcc-4.6
Nobuyasu Oshiro <dimolto@cr.ie.u-ryukyu.ac.jp>
parents:
diff changeset
254 cmp->missing_uses = true;
561a7518be6b update gcc-4.6
Nobuyasu Oshiro <dimolto@cr.ie.u-ryukyu.ac.jp>
parents:
diff changeset
255 }
561a7518be6b update gcc-4.6
Nobuyasu Oshiro <dimolto@cr.ie.u-ryukyu.ac.jp>
parents:
diff changeset
256
16
kono
parents: 15
diff changeset
257 class find_comparison_dom_walker : public dom_walker
kono
parents: 15
diff changeset
258 {
kono
parents: 15
diff changeset
259 public:
kono
parents: 15
diff changeset
260 find_comparison_dom_walker (cdi_direction direction)
kono
parents: 15
diff changeset
261 : dom_walker (direction) {}
kono
parents: 15
diff changeset
262
kono
parents: 15
diff changeset
263 virtual edge before_dom_children (basic_block);
kono
parents: 15
diff changeset
264 };
kono
parents: 15
diff changeset
265
kono
parents: 15
diff changeset
266 /* Return true if conforming COMPARE with EH_NOTE is redundant with comparison
kono
parents: 15
diff changeset
267 CMP and can thus be eliminated. */
kono
parents: 15
diff changeset
268
kono
parents: 15
diff changeset
269 static bool
kono
parents: 15
diff changeset
270 can_eliminate_compare (rtx compare, rtx eh_note, struct comparison *cmp)
kono
parents: 15
diff changeset
271 {
kono
parents: 15
diff changeset
272 /* Take care that it's in the same EH region. */
kono
parents: 15
diff changeset
273 if (cfun->can_throw_non_call_exceptions
kono
parents: 15
diff changeset
274 && !rtx_equal_p (eh_note, cmp->eh_note))
kono
parents: 15
diff changeset
275 return false;
kono
parents: 15
diff changeset
276
kono
parents: 15
diff changeset
277 /* Make sure the compare is redundant with the previous. */
kono
parents: 15
diff changeset
278 if (!rtx_equal_p (XEXP (compare, 0), cmp->in_a)
kono
parents: 15
diff changeset
279 || !rtx_equal_p (XEXP (compare, 1), cmp->in_b))
kono
parents: 15
diff changeset
280 return false;
kono
parents: 15
diff changeset
281
kono
parents: 15
diff changeset
282 /* New mode must be compatible with the previous compare mode. */
kono
parents: 15
diff changeset
283 machine_mode new_mode
kono
parents: 15
diff changeset
284 = targetm.cc_modes_compatible (GET_MODE (compare), cmp->orig_mode);
kono
parents: 15
diff changeset
285
kono
parents: 15
diff changeset
286 if (new_mode == VOIDmode)
kono
parents: 15
diff changeset
287 return false;
kono
parents: 15
diff changeset
288
kono
parents: 15
diff changeset
289 if (cmp->orig_mode != new_mode)
kono
parents: 15
diff changeset
290 {
kono
parents: 15
diff changeset
291 /* Generate new comparison for substitution. */
kono
parents: 15
diff changeset
292 rtx flags = gen_rtx_REG (new_mode, targetm.flags_regnum);
kono
parents: 15
diff changeset
293 rtx x = gen_rtx_COMPARE (new_mode, cmp->in_a, cmp->in_b);
kono
parents: 15
diff changeset
294 x = gen_rtx_SET (flags, x);
kono
parents: 15
diff changeset
295
kono
parents: 15
diff changeset
296 if (!validate_change (cmp->insn, &PATTERN (cmp->insn), x, false))
kono
parents: 15
diff changeset
297 return false;
kono
parents: 15
diff changeset
298
kono
parents: 15
diff changeset
299 cmp->orig_mode = new_mode;
kono
parents: 15
diff changeset
300 }
kono
parents: 15
diff changeset
301
kono
parents: 15
diff changeset
302 return true;
kono
parents: 15
diff changeset
303 }
kono
parents: 15
diff changeset
304
15
561a7518be6b update gcc-4.6
Nobuyasu Oshiro <dimolto@cr.ie.u-ryukyu.ac.jp>
parents:
diff changeset
305 /* Identify comparison instructions within BB. If the flags from the last
561a7518be6b update gcc-4.6
Nobuyasu Oshiro <dimolto@cr.ie.u-ryukyu.ac.jp>
parents:
diff changeset
306 compare in the BB is live at the end of the block, install the compare
16
kono
parents: 15
diff changeset
307 in BB->AUX. Called via dom_walker.walk (). */
15
561a7518be6b update gcc-4.6
Nobuyasu Oshiro <dimolto@cr.ie.u-ryukyu.ac.jp>
parents:
diff changeset
308
16
kono
parents: 15
diff changeset
309 edge
kono
parents: 15
diff changeset
310 find_comparison_dom_walker::before_dom_children (basic_block bb)
15
561a7518be6b update gcc-4.6
Nobuyasu Oshiro <dimolto@cr.ie.u-ryukyu.ac.jp>
parents:
diff changeset
311 {
561a7518be6b update gcc-4.6
Nobuyasu Oshiro <dimolto@cr.ie.u-ryukyu.ac.jp>
parents:
diff changeset
312 struct comparison *last_cmp;
16
kono
parents: 15
diff changeset
313 rtx_insn *insn, *next, *last_clobber;
15
561a7518be6b update gcc-4.6
Nobuyasu Oshiro <dimolto@cr.ie.u-ryukyu.ac.jp>
parents:
diff changeset
314 bool last_cmp_valid;
16
kono
parents: 15
diff changeset
315 bool need_purge = false;
15
561a7518be6b update gcc-4.6
Nobuyasu Oshiro <dimolto@cr.ie.u-ryukyu.ac.jp>
parents:
diff changeset
316 bitmap killed;
561a7518be6b update gcc-4.6
Nobuyasu Oshiro <dimolto@cr.ie.u-ryukyu.ac.jp>
parents:
diff changeset
317
561a7518be6b update gcc-4.6
Nobuyasu Oshiro <dimolto@cr.ie.u-ryukyu.ac.jp>
parents:
diff changeset
318 killed = BITMAP_ALLOC (NULL);
561a7518be6b update gcc-4.6
Nobuyasu Oshiro <dimolto@cr.ie.u-ryukyu.ac.jp>
parents:
diff changeset
319
561a7518be6b update gcc-4.6
Nobuyasu Oshiro <dimolto@cr.ie.u-ryukyu.ac.jp>
parents:
diff changeset
320 /* The last comparison that was made. Will be reset to NULL
561a7518be6b update gcc-4.6
Nobuyasu Oshiro <dimolto@cr.ie.u-ryukyu.ac.jp>
parents:
diff changeset
321 once the flags are clobbered. */
561a7518be6b update gcc-4.6
Nobuyasu Oshiro <dimolto@cr.ie.u-ryukyu.ac.jp>
parents:
diff changeset
322 last_cmp = NULL;
561a7518be6b update gcc-4.6
Nobuyasu Oshiro <dimolto@cr.ie.u-ryukyu.ac.jp>
parents:
diff changeset
323
561a7518be6b update gcc-4.6
Nobuyasu Oshiro <dimolto@cr.ie.u-ryukyu.ac.jp>
parents:
diff changeset
324 /* True iff the last comparison has not been clobbered, nor
561a7518be6b update gcc-4.6
Nobuyasu Oshiro <dimolto@cr.ie.u-ryukyu.ac.jp>
parents:
diff changeset
325 have its inputs. Used to eliminate duplicate compares. */
561a7518be6b update gcc-4.6
Nobuyasu Oshiro <dimolto@cr.ie.u-ryukyu.ac.jp>
parents:
diff changeset
326 last_cmp_valid = false;
561a7518be6b update gcc-4.6
Nobuyasu Oshiro <dimolto@cr.ie.u-ryukyu.ac.jp>
parents:
diff changeset
327
561a7518be6b update gcc-4.6
Nobuyasu Oshiro <dimolto@cr.ie.u-ryukyu.ac.jp>
parents:
diff changeset
328 /* The last insn that clobbered the flags, if that insn is of
561a7518be6b update gcc-4.6
Nobuyasu Oshiro <dimolto@cr.ie.u-ryukyu.ac.jp>
parents:
diff changeset
329 a form that may be valid for eliminating a following compare.
561a7518be6b update gcc-4.6
Nobuyasu Oshiro <dimolto@cr.ie.u-ryukyu.ac.jp>
parents:
diff changeset
330 To be reset to NULL once the flags are set otherwise. */
561a7518be6b update gcc-4.6
Nobuyasu Oshiro <dimolto@cr.ie.u-ryukyu.ac.jp>
parents:
diff changeset
331 last_clobber = NULL;
561a7518be6b update gcc-4.6
Nobuyasu Oshiro <dimolto@cr.ie.u-ryukyu.ac.jp>
parents:
diff changeset
332
561a7518be6b update gcc-4.6
Nobuyasu Oshiro <dimolto@cr.ie.u-ryukyu.ac.jp>
parents:
diff changeset
333 /* Propagate the last live comparison throughout the extended basic block. */
561a7518be6b update gcc-4.6
Nobuyasu Oshiro <dimolto@cr.ie.u-ryukyu.ac.jp>
parents:
diff changeset
334 if (single_pred_p (bb))
561a7518be6b update gcc-4.6
Nobuyasu Oshiro <dimolto@cr.ie.u-ryukyu.ac.jp>
parents:
diff changeset
335 {
561a7518be6b update gcc-4.6
Nobuyasu Oshiro <dimolto@cr.ie.u-ryukyu.ac.jp>
parents:
diff changeset
336 last_cmp = (struct comparison *) single_pred (bb)->aux;
561a7518be6b update gcc-4.6
Nobuyasu Oshiro <dimolto@cr.ie.u-ryukyu.ac.jp>
parents:
diff changeset
337 if (last_cmp)
561a7518be6b update gcc-4.6
Nobuyasu Oshiro <dimolto@cr.ie.u-ryukyu.ac.jp>
parents:
diff changeset
338 last_cmp_valid = last_cmp->inputs_valid;
561a7518be6b update gcc-4.6
Nobuyasu Oshiro <dimolto@cr.ie.u-ryukyu.ac.jp>
parents:
diff changeset
339 }
561a7518be6b update gcc-4.6
Nobuyasu Oshiro <dimolto@cr.ie.u-ryukyu.ac.jp>
parents:
diff changeset
340
561a7518be6b update gcc-4.6
Nobuyasu Oshiro <dimolto@cr.ie.u-ryukyu.ac.jp>
parents:
diff changeset
341 for (insn = BB_HEAD (bb); insn; insn = next)
561a7518be6b update gcc-4.6
Nobuyasu Oshiro <dimolto@cr.ie.u-ryukyu.ac.jp>
parents:
diff changeset
342 {
561a7518be6b update gcc-4.6
Nobuyasu Oshiro <dimolto@cr.ie.u-ryukyu.ac.jp>
parents:
diff changeset
343 rtx src;
561a7518be6b update gcc-4.6
Nobuyasu Oshiro <dimolto@cr.ie.u-ryukyu.ac.jp>
parents:
diff changeset
344
16
kono
parents: 15
diff changeset
345 next = (insn == BB_END (bb) ? NULL : NEXT_INSN (insn));
15
561a7518be6b update gcc-4.6
Nobuyasu Oshiro <dimolto@cr.ie.u-ryukyu.ac.jp>
parents:
diff changeset
346 if (!NONDEBUG_INSN_P (insn))
561a7518be6b update gcc-4.6
Nobuyasu Oshiro <dimolto@cr.ie.u-ryukyu.ac.jp>
parents:
diff changeset
347 continue;
561a7518be6b update gcc-4.6
Nobuyasu Oshiro <dimolto@cr.ie.u-ryukyu.ac.jp>
parents:
diff changeset
348
561a7518be6b update gcc-4.6
Nobuyasu Oshiro <dimolto@cr.ie.u-ryukyu.ac.jp>
parents:
diff changeset
349 /* Compute the set of registers modified by this instruction. */
561a7518be6b update gcc-4.6
Nobuyasu Oshiro <dimolto@cr.ie.u-ryukyu.ac.jp>
parents:
diff changeset
350 bitmap_clear (killed);
561a7518be6b update gcc-4.6
Nobuyasu Oshiro <dimolto@cr.ie.u-ryukyu.ac.jp>
parents:
diff changeset
351 df_simulate_find_defs (insn, killed);
561a7518be6b update gcc-4.6
Nobuyasu Oshiro <dimolto@cr.ie.u-ryukyu.ac.jp>
parents:
diff changeset
352
561a7518be6b update gcc-4.6
Nobuyasu Oshiro <dimolto@cr.ie.u-ryukyu.ac.jp>
parents:
diff changeset
353 src = conforming_compare (insn);
561a7518be6b update gcc-4.6
Nobuyasu Oshiro <dimolto@cr.ie.u-ryukyu.ac.jp>
parents:
diff changeset
354 if (src)
561a7518be6b update gcc-4.6
Nobuyasu Oshiro <dimolto@cr.ie.u-ryukyu.ac.jp>
parents:
diff changeset
355 {
16
kono
parents: 15
diff changeset
356 rtx eh_note = NULL;
kono
parents: 15
diff changeset
357
kono
parents: 15
diff changeset
358 if (cfun->can_throw_non_call_exceptions)
kono
parents: 15
diff changeset
359 eh_note = find_reg_note (insn, REG_EH_REGION, NULL);
kono
parents: 15
diff changeset
360
kono
parents: 15
diff changeset
361 if (last_cmp_valid && can_eliminate_compare (src, eh_note, last_cmp))
15
561a7518be6b update gcc-4.6
Nobuyasu Oshiro <dimolto@cr.ie.u-ryukyu.ac.jp>
parents:
diff changeset
362 {
16
kono
parents: 15
diff changeset
363 if (eh_note)
kono
parents: 15
diff changeset
364 need_purge = true;
15
561a7518be6b update gcc-4.6
Nobuyasu Oshiro <dimolto@cr.ie.u-ryukyu.ac.jp>
parents:
diff changeset
365 delete_insn (insn);
561a7518be6b update gcc-4.6
Nobuyasu Oshiro <dimolto@cr.ie.u-ryukyu.ac.jp>
parents:
diff changeset
366 continue;
561a7518be6b update gcc-4.6
Nobuyasu Oshiro <dimolto@cr.ie.u-ryukyu.ac.jp>
parents:
diff changeset
367 }
561a7518be6b update gcc-4.6
Nobuyasu Oshiro <dimolto@cr.ie.u-ryukyu.ac.jp>
parents:
diff changeset
368
16
kono
parents: 15
diff changeset
369 last_cmp = XCNEW (struct comparison);
15
561a7518be6b update gcc-4.6
Nobuyasu Oshiro <dimolto@cr.ie.u-ryukyu.ac.jp>
parents:
diff changeset
370 last_cmp->insn = insn;
561a7518be6b update gcc-4.6
Nobuyasu Oshiro <dimolto@cr.ie.u-ryukyu.ac.jp>
parents:
diff changeset
371 last_cmp->prev_clobber = last_clobber;
561a7518be6b update gcc-4.6
Nobuyasu Oshiro <dimolto@cr.ie.u-ryukyu.ac.jp>
parents:
diff changeset
372 last_cmp->in_a = XEXP (src, 0);
561a7518be6b update gcc-4.6
Nobuyasu Oshiro <dimolto@cr.ie.u-ryukyu.ac.jp>
parents:
diff changeset
373 last_cmp->in_b = XEXP (src, 1);
16
kono
parents: 15
diff changeset
374 last_cmp->eh_note = eh_note;
kono
parents: 15
diff changeset
375 last_cmp->orig_mode = GET_MODE (src);
kono
parents: 15
diff changeset
376 all_compares.safe_push (last_cmp);
15
561a7518be6b update gcc-4.6
Nobuyasu Oshiro <dimolto@cr.ie.u-ryukyu.ac.jp>
parents:
diff changeset
377
561a7518be6b update gcc-4.6
Nobuyasu Oshiro <dimolto@cr.ie.u-ryukyu.ac.jp>
parents:
diff changeset
378 /* It's unusual, but be prepared for comparison patterns that
561a7518be6b update gcc-4.6
Nobuyasu Oshiro <dimolto@cr.ie.u-ryukyu.ac.jp>
parents:
diff changeset
379 also clobber an input, or perhaps a scratch. */
561a7518be6b update gcc-4.6
Nobuyasu Oshiro <dimolto@cr.ie.u-ryukyu.ac.jp>
parents:
diff changeset
380 last_clobber = NULL;
561a7518be6b update gcc-4.6
Nobuyasu Oshiro <dimolto@cr.ie.u-ryukyu.ac.jp>
parents:
diff changeset
381 last_cmp_valid = true;
561a7518be6b update gcc-4.6
Nobuyasu Oshiro <dimolto@cr.ie.u-ryukyu.ac.jp>
parents:
diff changeset
382 }
561a7518be6b update gcc-4.6
Nobuyasu Oshiro <dimolto@cr.ie.u-ryukyu.ac.jp>
parents:
diff changeset
383
16
kono
parents: 15
diff changeset
384 else
15
561a7518be6b update gcc-4.6
Nobuyasu Oshiro <dimolto@cr.ie.u-ryukyu.ac.jp>
parents:
diff changeset
385 {
16
kono
parents: 15
diff changeset
386 /* Notice if this instruction uses the flags register. */
kono
parents: 15
diff changeset
387 if (last_cmp)
kono
parents: 15
diff changeset
388 find_flags_uses_in_insn (last_cmp, insn);
15
561a7518be6b update gcc-4.6
Nobuyasu Oshiro <dimolto@cr.ie.u-ryukyu.ac.jp>
parents:
diff changeset
389
16
kono
parents: 15
diff changeset
390 /* Notice if this instruction kills the flags register. */
kono
parents: 15
diff changeset
391 if (bitmap_bit_p (killed, targetm.flags_regnum))
kono
parents: 15
diff changeset
392 {
kono
parents: 15
diff changeset
393 /* See if this insn could be the "clobber" that eliminates
kono
parents: 15
diff changeset
394 a future comparison. */
kono
parents: 15
diff changeset
395 last_clobber = (arithmetic_flags_clobber_p (insn) ? insn : NULL);
kono
parents: 15
diff changeset
396
kono
parents: 15
diff changeset
397 /* In either case, the previous compare is no longer valid. */
kono
parents: 15
diff changeset
398 last_cmp = NULL;
kono
parents: 15
diff changeset
399 last_cmp_valid = false;
kono
parents: 15
diff changeset
400 }
15
561a7518be6b update gcc-4.6
Nobuyasu Oshiro <dimolto@cr.ie.u-ryukyu.ac.jp>
parents:
diff changeset
401 }
561a7518be6b update gcc-4.6
Nobuyasu Oshiro <dimolto@cr.ie.u-ryukyu.ac.jp>
parents:
diff changeset
402
561a7518be6b update gcc-4.6
Nobuyasu Oshiro <dimolto@cr.ie.u-ryukyu.ac.jp>
parents:
diff changeset
403 /* Notice if any of the inputs to the comparison have changed. */
561a7518be6b update gcc-4.6
Nobuyasu Oshiro <dimolto@cr.ie.u-ryukyu.ac.jp>
parents:
diff changeset
404 if (last_cmp_valid
561a7518be6b update gcc-4.6
Nobuyasu Oshiro <dimolto@cr.ie.u-ryukyu.ac.jp>
parents:
diff changeset
405 && (bitmap_bit_p (killed, REGNO (last_cmp->in_a))
561a7518be6b update gcc-4.6
Nobuyasu Oshiro <dimolto@cr.ie.u-ryukyu.ac.jp>
parents:
diff changeset
406 || (REG_P (last_cmp->in_b)
561a7518be6b update gcc-4.6
Nobuyasu Oshiro <dimolto@cr.ie.u-ryukyu.ac.jp>
parents:
diff changeset
407 && bitmap_bit_p (killed, REGNO (last_cmp->in_b)))))
561a7518be6b update gcc-4.6
Nobuyasu Oshiro <dimolto@cr.ie.u-ryukyu.ac.jp>
parents:
diff changeset
408 last_cmp_valid = false;
561a7518be6b update gcc-4.6
Nobuyasu Oshiro <dimolto@cr.ie.u-ryukyu.ac.jp>
parents:
diff changeset
409 }
561a7518be6b update gcc-4.6
Nobuyasu Oshiro <dimolto@cr.ie.u-ryukyu.ac.jp>
parents:
diff changeset
410
561a7518be6b update gcc-4.6
Nobuyasu Oshiro <dimolto@cr.ie.u-ryukyu.ac.jp>
parents:
diff changeset
411 BITMAP_FREE (killed);
561a7518be6b update gcc-4.6
Nobuyasu Oshiro <dimolto@cr.ie.u-ryukyu.ac.jp>
parents:
diff changeset
412
561a7518be6b update gcc-4.6
Nobuyasu Oshiro <dimolto@cr.ie.u-ryukyu.ac.jp>
parents:
diff changeset
413 /* Remember the live comparison for subsequent members of
561a7518be6b update gcc-4.6
Nobuyasu Oshiro <dimolto@cr.ie.u-ryukyu.ac.jp>
parents:
diff changeset
414 the extended basic block. */
561a7518be6b update gcc-4.6
Nobuyasu Oshiro <dimolto@cr.ie.u-ryukyu.ac.jp>
parents:
diff changeset
415 if (last_cmp)
561a7518be6b update gcc-4.6
Nobuyasu Oshiro <dimolto@cr.ie.u-ryukyu.ac.jp>
parents:
diff changeset
416 {
561a7518be6b update gcc-4.6
Nobuyasu Oshiro <dimolto@cr.ie.u-ryukyu.ac.jp>
parents:
diff changeset
417 bb->aux = last_cmp;
561a7518be6b update gcc-4.6
Nobuyasu Oshiro <dimolto@cr.ie.u-ryukyu.ac.jp>
parents:
diff changeset
418 last_cmp->inputs_valid = last_cmp_valid;
561a7518be6b update gcc-4.6
Nobuyasu Oshiro <dimolto@cr.ie.u-ryukyu.ac.jp>
parents:
diff changeset
419
561a7518be6b update gcc-4.6
Nobuyasu Oshiro <dimolto@cr.ie.u-ryukyu.ac.jp>
parents:
diff changeset
420 /* Look to see if the flags register is live outgoing here, and
561a7518be6b update gcc-4.6
Nobuyasu Oshiro <dimolto@cr.ie.u-ryukyu.ac.jp>
parents:
diff changeset
421 incoming to any successor not part of the extended basic block. */
16
kono
parents: 15
diff changeset
422 if (bitmap_bit_p (df_get_live_out (bb), targetm.flags_regnum))
15
561a7518be6b update gcc-4.6
Nobuyasu Oshiro <dimolto@cr.ie.u-ryukyu.ac.jp>
parents:
diff changeset
423 {
561a7518be6b update gcc-4.6
Nobuyasu Oshiro <dimolto@cr.ie.u-ryukyu.ac.jp>
parents:
diff changeset
424 edge e;
561a7518be6b update gcc-4.6
Nobuyasu Oshiro <dimolto@cr.ie.u-ryukyu.ac.jp>
parents:
diff changeset
425 edge_iterator ei;
561a7518be6b update gcc-4.6
Nobuyasu Oshiro <dimolto@cr.ie.u-ryukyu.ac.jp>
parents:
diff changeset
426
561a7518be6b update gcc-4.6
Nobuyasu Oshiro <dimolto@cr.ie.u-ryukyu.ac.jp>
parents:
diff changeset
427 FOR_EACH_EDGE (e, ei, bb->succs)
561a7518be6b update gcc-4.6
Nobuyasu Oshiro <dimolto@cr.ie.u-ryukyu.ac.jp>
parents:
diff changeset
428 {
561a7518be6b update gcc-4.6
Nobuyasu Oshiro <dimolto@cr.ie.u-ryukyu.ac.jp>
parents:
diff changeset
429 basic_block dest = e->dest;
16
kono
parents: 15
diff changeset
430 if (bitmap_bit_p (df_get_live_in (bb), targetm.flags_regnum)
15
561a7518be6b update gcc-4.6
Nobuyasu Oshiro <dimolto@cr.ie.u-ryukyu.ac.jp>
parents:
diff changeset
431 && !single_pred_p (dest))
561a7518be6b update gcc-4.6
Nobuyasu Oshiro <dimolto@cr.ie.u-ryukyu.ac.jp>
parents:
diff changeset
432 {
561a7518be6b update gcc-4.6
Nobuyasu Oshiro <dimolto@cr.ie.u-ryukyu.ac.jp>
parents:
diff changeset
433 last_cmp->missing_uses = true;
561a7518be6b update gcc-4.6
Nobuyasu Oshiro <dimolto@cr.ie.u-ryukyu.ac.jp>
parents:
diff changeset
434 break;
561a7518be6b update gcc-4.6
Nobuyasu Oshiro <dimolto@cr.ie.u-ryukyu.ac.jp>
parents:
diff changeset
435 }
561a7518be6b update gcc-4.6
Nobuyasu Oshiro <dimolto@cr.ie.u-ryukyu.ac.jp>
parents:
diff changeset
436 }
561a7518be6b update gcc-4.6
Nobuyasu Oshiro <dimolto@cr.ie.u-ryukyu.ac.jp>
parents:
diff changeset
437 }
561a7518be6b update gcc-4.6
Nobuyasu Oshiro <dimolto@cr.ie.u-ryukyu.ac.jp>
parents:
diff changeset
438 }
16
kono
parents: 15
diff changeset
439
kono
parents: 15
diff changeset
440 /* If we deleted a compare with a REG_EH_REGION note, we may need to
kono
parents: 15
diff changeset
441 remove EH edges. */
kono
parents: 15
diff changeset
442 if (need_purge)
kono
parents: 15
diff changeset
443 purge_dead_edges (bb);
kono
parents: 15
diff changeset
444
kono
parents: 15
diff changeset
445 return NULL;
15
561a7518be6b update gcc-4.6
Nobuyasu Oshiro <dimolto@cr.ie.u-ryukyu.ac.jp>
parents:
diff changeset
446 }
561a7518be6b update gcc-4.6
Nobuyasu Oshiro <dimolto@cr.ie.u-ryukyu.ac.jp>
parents:
diff changeset
447
561a7518be6b update gcc-4.6
Nobuyasu Oshiro <dimolto@cr.ie.u-ryukyu.ac.jp>
parents:
diff changeset
448 /* Find all comparisons in the function. */
561a7518be6b update gcc-4.6
Nobuyasu Oshiro <dimolto@cr.ie.u-ryukyu.ac.jp>
parents:
diff changeset
449
561a7518be6b update gcc-4.6
Nobuyasu Oshiro <dimolto@cr.ie.u-ryukyu.ac.jp>
parents:
diff changeset
450 static void
561a7518be6b update gcc-4.6
Nobuyasu Oshiro <dimolto@cr.ie.u-ryukyu.ac.jp>
parents:
diff changeset
451 find_comparisons (void)
561a7518be6b update gcc-4.6
Nobuyasu Oshiro <dimolto@cr.ie.u-ryukyu.ac.jp>
parents:
diff changeset
452 {
561a7518be6b update gcc-4.6
Nobuyasu Oshiro <dimolto@cr.ie.u-ryukyu.ac.jp>
parents:
diff changeset
453 calculate_dominance_info (CDI_DOMINATORS);
561a7518be6b update gcc-4.6
Nobuyasu Oshiro <dimolto@cr.ie.u-ryukyu.ac.jp>
parents:
diff changeset
454
16
kono
parents: 15
diff changeset
455 find_comparison_dom_walker (CDI_DOMINATORS)
kono
parents: 15
diff changeset
456 .walk (cfun->cfg->x_entry_block_ptr);
15
561a7518be6b update gcc-4.6
Nobuyasu Oshiro <dimolto@cr.ie.u-ryukyu.ac.jp>
parents:
diff changeset
457
561a7518be6b update gcc-4.6
Nobuyasu Oshiro <dimolto@cr.ie.u-ryukyu.ac.jp>
parents:
diff changeset
458 clear_aux_for_blocks ();
561a7518be6b update gcc-4.6
Nobuyasu Oshiro <dimolto@cr.ie.u-ryukyu.ac.jp>
parents:
diff changeset
459 free_dominance_info (CDI_DOMINATORS);
561a7518be6b update gcc-4.6
Nobuyasu Oshiro <dimolto@cr.ie.u-ryukyu.ac.jp>
parents:
diff changeset
460 }
561a7518be6b update gcc-4.6
Nobuyasu Oshiro <dimolto@cr.ie.u-ryukyu.ac.jp>
parents:
diff changeset
461
561a7518be6b update gcc-4.6
Nobuyasu Oshiro <dimolto@cr.ie.u-ryukyu.ac.jp>
parents:
diff changeset
462 /* Select an alternate CC_MODE for a comparison insn comparing A and B.
561a7518be6b update gcc-4.6
Nobuyasu Oshiro <dimolto@cr.ie.u-ryukyu.ac.jp>
parents:
diff changeset
463 Note that inputs are almost certainly different than the IN_A and IN_B
561a7518be6b update gcc-4.6
Nobuyasu Oshiro <dimolto@cr.ie.u-ryukyu.ac.jp>
parents:
diff changeset
464 stored in CMP -- we're called while attempting to eliminate the compare
561a7518be6b update gcc-4.6
Nobuyasu Oshiro <dimolto@cr.ie.u-ryukyu.ac.jp>
parents:
diff changeset
465 after all. Return the new FLAGS rtx if successful, else return NULL.
561a7518be6b update gcc-4.6
Nobuyasu Oshiro <dimolto@cr.ie.u-ryukyu.ac.jp>
parents:
diff changeset
466 Note that this function may start a change group. */
561a7518be6b update gcc-4.6
Nobuyasu Oshiro <dimolto@cr.ie.u-ryukyu.ac.jp>
parents:
diff changeset
467
561a7518be6b update gcc-4.6
Nobuyasu Oshiro <dimolto@cr.ie.u-ryukyu.ac.jp>
parents:
diff changeset
468 static rtx
561a7518be6b update gcc-4.6
Nobuyasu Oshiro <dimolto@cr.ie.u-ryukyu.ac.jp>
parents:
diff changeset
469 maybe_select_cc_mode (struct comparison *cmp, rtx a ATTRIBUTE_UNUSED,
561a7518be6b update gcc-4.6
Nobuyasu Oshiro <dimolto@cr.ie.u-ryukyu.ac.jp>
parents:
diff changeset
470 rtx b ATTRIBUTE_UNUSED)
561a7518be6b update gcc-4.6
Nobuyasu Oshiro <dimolto@cr.ie.u-ryukyu.ac.jp>
parents:
diff changeset
471 {
16
kono
parents: 15
diff changeset
472 machine_mode sel_mode;
15
561a7518be6b update gcc-4.6
Nobuyasu Oshiro <dimolto@cr.ie.u-ryukyu.ac.jp>
parents:
diff changeset
473 const int n = cmp->n_uses;
561a7518be6b update gcc-4.6
Nobuyasu Oshiro <dimolto@cr.ie.u-ryukyu.ac.jp>
parents:
diff changeset
474 rtx flags = NULL;
561a7518be6b update gcc-4.6
Nobuyasu Oshiro <dimolto@cr.ie.u-ryukyu.ac.jp>
parents:
diff changeset
475
561a7518be6b update gcc-4.6
Nobuyasu Oshiro <dimolto@cr.ie.u-ryukyu.ac.jp>
parents:
diff changeset
476 #ifndef SELECT_CC_MODE
561a7518be6b update gcc-4.6
Nobuyasu Oshiro <dimolto@cr.ie.u-ryukyu.ac.jp>
parents:
diff changeset
477 /* Minimize code differences when this target macro is undefined. */
561a7518be6b update gcc-4.6
Nobuyasu Oshiro <dimolto@cr.ie.u-ryukyu.ac.jp>
parents:
diff changeset
478 return NULL;
561a7518be6b update gcc-4.6
Nobuyasu Oshiro <dimolto@cr.ie.u-ryukyu.ac.jp>
parents:
diff changeset
479 #define SELECT_CC_MODE(A,B,C) (gcc_unreachable (), VOIDmode)
561a7518be6b update gcc-4.6
Nobuyasu Oshiro <dimolto@cr.ie.u-ryukyu.ac.jp>
parents:
diff changeset
480 #endif
561a7518be6b update gcc-4.6
Nobuyasu Oshiro <dimolto@cr.ie.u-ryukyu.ac.jp>
parents:
diff changeset
481
561a7518be6b update gcc-4.6
Nobuyasu Oshiro <dimolto@cr.ie.u-ryukyu.ac.jp>
parents:
diff changeset
482 /* If we don't have access to all of the uses, we can't validate. */
561a7518be6b update gcc-4.6
Nobuyasu Oshiro <dimolto@cr.ie.u-ryukyu.ac.jp>
parents:
diff changeset
483 if (cmp->missing_uses || n == 0)
561a7518be6b update gcc-4.6
Nobuyasu Oshiro <dimolto@cr.ie.u-ryukyu.ac.jp>
parents:
diff changeset
484 return NULL;
561a7518be6b update gcc-4.6
Nobuyasu Oshiro <dimolto@cr.ie.u-ryukyu.ac.jp>
parents:
diff changeset
485
561a7518be6b update gcc-4.6
Nobuyasu Oshiro <dimolto@cr.ie.u-ryukyu.ac.jp>
parents:
diff changeset
486 /* Find a new mode that works for all of the uses. Special case the
561a7518be6b update gcc-4.6
Nobuyasu Oshiro <dimolto@cr.ie.u-ryukyu.ac.jp>
parents:
diff changeset
487 common case of exactly one use. */
561a7518be6b update gcc-4.6
Nobuyasu Oshiro <dimolto@cr.ie.u-ryukyu.ac.jp>
parents:
diff changeset
488 if (n == 1)
561a7518be6b update gcc-4.6
Nobuyasu Oshiro <dimolto@cr.ie.u-ryukyu.ac.jp>
parents:
diff changeset
489 {
561a7518be6b update gcc-4.6
Nobuyasu Oshiro <dimolto@cr.ie.u-ryukyu.ac.jp>
parents:
diff changeset
490 sel_mode = SELECT_CC_MODE (cmp->uses[0].code, a, b);
561a7518be6b update gcc-4.6
Nobuyasu Oshiro <dimolto@cr.ie.u-ryukyu.ac.jp>
parents:
diff changeset
491 if (sel_mode != cmp->orig_mode)
561a7518be6b update gcc-4.6
Nobuyasu Oshiro <dimolto@cr.ie.u-ryukyu.ac.jp>
parents:
diff changeset
492 {
561a7518be6b update gcc-4.6
Nobuyasu Oshiro <dimolto@cr.ie.u-ryukyu.ac.jp>
parents:
diff changeset
493 flags = gen_rtx_REG (sel_mode, targetm.flags_regnum);
561a7518be6b update gcc-4.6
Nobuyasu Oshiro <dimolto@cr.ie.u-ryukyu.ac.jp>
parents:
diff changeset
494 validate_change (cmp->uses[0].insn, cmp->uses[0].loc, flags, true);
561a7518be6b update gcc-4.6
Nobuyasu Oshiro <dimolto@cr.ie.u-ryukyu.ac.jp>
parents:
diff changeset
495 }
561a7518be6b update gcc-4.6
Nobuyasu Oshiro <dimolto@cr.ie.u-ryukyu.ac.jp>
parents:
diff changeset
496 }
561a7518be6b update gcc-4.6
Nobuyasu Oshiro <dimolto@cr.ie.u-ryukyu.ac.jp>
parents:
diff changeset
497 else
561a7518be6b update gcc-4.6
Nobuyasu Oshiro <dimolto@cr.ie.u-ryukyu.ac.jp>
parents:
diff changeset
498 {
561a7518be6b update gcc-4.6
Nobuyasu Oshiro <dimolto@cr.ie.u-ryukyu.ac.jp>
parents:
diff changeset
499 int i;
561a7518be6b update gcc-4.6
Nobuyasu Oshiro <dimolto@cr.ie.u-ryukyu.ac.jp>
parents:
diff changeset
500
561a7518be6b update gcc-4.6
Nobuyasu Oshiro <dimolto@cr.ie.u-ryukyu.ac.jp>
parents:
diff changeset
501 sel_mode = SELECT_CC_MODE (cmp->uses[0].code, a, b);
561a7518be6b update gcc-4.6
Nobuyasu Oshiro <dimolto@cr.ie.u-ryukyu.ac.jp>
parents:
diff changeset
502 for (i = 1; i < n; ++i)
561a7518be6b update gcc-4.6
Nobuyasu Oshiro <dimolto@cr.ie.u-ryukyu.ac.jp>
parents:
diff changeset
503 {
16
kono
parents: 15
diff changeset
504 machine_mode new_mode = SELECT_CC_MODE (cmp->uses[i].code, a, b);
15
561a7518be6b update gcc-4.6
Nobuyasu Oshiro <dimolto@cr.ie.u-ryukyu.ac.jp>
parents:
diff changeset
505 if (new_mode != sel_mode)
561a7518be6b update gcc-4.6
Nobuyasu Oshiro <dimolto@cr.ie.u-ryukyu.ac.jp>
parents:
diff changeset
506 {
561a7518be6b update gcc-4.6
Nobuyasu Oshiro <dimolto@cr.ie.u-ryukyu.ac.jp>
parents:
diff changeset
507 sel_mode = targetm.cc_modes_compatible (sel_mode, new_mode);
561a7518be6b update gcc-4.6
Nobuyasu Oshiro <dimolto@cr.ie.u-ryukyu.ac.jp>
parents:
diff changeset
508 if (sel_mode == VOIDmode)
561a7518be6b update gcc-4.6
Nobuyasu Oshiro <dimolto@cr.ie.u-ryukyu.ac.jp>
parents:
diff changeset
509 return NULL;
561a7518be6b update gcc-4.6
Nobuyasu Oshiro <dimolto@cr.ie.u-ryukyu.ac.jp>
parents:
diff changeset
510 }
561a7518be6b update gcc-4.6
Nobuyasu Oshiro <dimolto@cr.ie.u-ryukyu.ac.jp>
parents:
diff changeset
511 }
16
kono
parents: 15
diff changeset
512
15
561a7518be6b update gcc-4.6
Nobuyasu Oshiro <dimolto@cr.ie.u-ryukyu.ac.jp>
parents:
diff changeset
513 if (sel_mode != cmp->orig_mode)
561a7518be6b update gcc-4.6
Nobuyasu Oshiro <dimolto@cr.ie.u-ryukyu.ac.jp>
parents:
diff changeset
514 {
561a7518be6b update gcc-4.6
Nobuyasu Oshiro <dimolto@cr.ie.u-ryukyu.ac.jp>
parents:
diff changeset
515 flags = gen_rtx_REG (sel_mode, targetm.flags_regnum);
561a7518be6b update gcc-4.6
Nobuyasu Oshiro <dimolto@cr.ie.u-ryukyu.ac.jp>
parents:
diff changeset
516 for (i = 0; i < n; ++i)
561a7518be6b update gcc-4.6
Nobuyasu Oshiro <dimolto@cr.ie.u-ryukyu.ac.jp>
parents:
diff changeset
517 validate_change (cmp->uses[i].insn, cmp->uses[i].loc, flags, true);
561a7518be6b update gcc-4.6
Nobuyasu Oshiro <dimolto@cr.ie.u-ryukyu.ac.jp>
parents:
diff changeset
518 }
561a7518be6b update gcc-4.6
Nobuyasu Oshiro <dimolto@cr.ie.u-ryukyu.ac.jp>
parents:
diff changeset
519 }
561a7518be6b update gcc-4.6
Nobuyasu Oshiro <dimolto@cr.ie.u-ryukyu.ac.jp>
parents:
diff changeset
520
561a7518be6b update gcc-4.6
Nobuyasu Oshiro <dimolto@cr.ie.u-ryukyu.ac.jp>
parents:
diff changeset
521 return flags;
561a7518be6b update gcc-4.6
Nobuyasu Oshiro <dimolto@cr.ie.u-ryukyu.ac.jp>
parents:
diff changeset
522 }
561a7518be6b update gcc-4.6
Nobuyasu Oshiro <dimolto@cr.ie.u-ryukyu.ac.jp>
parents:
diff changeset
523
16
kono
parents: 15
diff changeset
524 /* Return a register RTX holding the same value at START as REG at END, or
kono
parents: 15
diff changeset
525 NULL_RTX if there is none. */
kono
parents: 15
diff changeset
526
kono
parents: 15
diff changeset
527 static rtx
kono
parents: 15
diff changeset
528 equivalent_reg_at_start (rtx reg, rtx_insn *end, rtx_insn *start)
kono
parents: 15
diff changeset
529 {
kono
parents: 15
diff changeset
530 machine_mode orig_mode = GET_MODE (reg);
kono
parents: 15
diff changeset
531 rtx_insn *bb_head = BB_HEAD (BLOCK_FOR_INSN (end));
kono
parents: 15
diff changeset
532
kono
parents: 15
diff changeset
533 for (rtx_insn *insn = PREV_INSN (end);
kono
parents: 15
diff changeset
534 insn != start;
kono
parents: 15
diff changeset
535 insn = PREV_INSN (insn))
kono
parents: 15
diff changeset
536 {
kono
parents: 15
diff changeset
537 const int abnormal_flags
kono
parents: 15
diff changeset
538 = (DF_REF_CONDITIONAL | DF_REF_PARTIAL | DF_REF_MAY_CLOBBER
kono
parents: 15
diff changeset
539 | DF_REF_MUST_CLOBBER | DF_REF_SIGN_EXTRACT
kono
parents: 15
diff changeset
540 | DF_REF_ZERO_EXTRACT | DF_REF_STRICT_LOW_PART
kono
parents: 15
diff changeset
541 | DF_REF_PRE_POST_MODIFY);
kono
parents: 15
diff changeset
542 df_ref def;
kono
parents: 15
diff changeset
543
kono
parents: 15
diff changeset
544 /* Note that the BB_HEAD is always either a note or a label, but in
kono
parents: 15
diff changeset
545 any case it means that REG is defined outside the block. */
kono
parents: 15
diff changeset
546 if (insn == bb_head)
kono
parents: 15
diff changeset
547 return NULL_RTX;
kono
parents: 15
diff changeset
548 if (NOTE_P (insn) || DEBUG_INSN_P (insn))
kono
parents: 15
diff changeset
549 continue;
kono
parents: 15
diff changeset
550
kono
parents: 15
diff changeset
551 /* Find a possible def of REG in INSN. */
kono
parents: 15
diff changeset
552 FOR_EACH_INSN_DEF (def, insn)
kono
parents: 15
diff changeset
553 if (DF_REF_REGNO (def) == REGNO (reg))
kono
parents: 15
diff changeset
554 break;
kono
parents: 15
diff changeset
555
kono
parents: 15
diff changeset
556 /* No definitions of REG; continue searching. */
kono
parents: 15
diff changeset
557 if (def == NULL)
kono
parents: 15
diff changeset
558 continue;
kono
parents: 15
diff changeset
559
kono
parents: 15
diff changeset
560 /* Bail if this is not a totally normal set of REG. */
kono
parents: 15
diff changeset
561 if (DF_REF_IS_ARTIFICIAL (def))
kono
parents: 15
diff changeset
562 return NULL_RTX;
kono
parents: 15
diff changeset
563 if (DF_REF_FLAGS (def) & abnormal_flags)
kono
parents: 15
diff changeset
564 return NULL_RTX;
kono
parents: 15
diff changeset
565
kono
parents: 15
diff changeset
566 /* We've found an insn between the compare and the clobber that sets
kono
parents: 15
diff changeset
567 REG. Given that pass_cprop_hardreg has not yet run, we still find
kono
parents: 15
diff changeset
568 situations in which we can usefully look through a copy insn. */
kono
parents: 15
diff changeset
569 rtx x = single_set (insn);
kono
parents: 15
diff changeset
570 if (x == NULL_RTX)
kono
parents: 15
diff changeset
571 return NULL_RTX;
kono
parents: 15
diff changeset
572 reg = SET_SRC (x);
kono
parents: 15
diff changeset
573 if (!REG_P (reg))
kono
parents: 15
diff changeset
574 return NULL_RTX;
kono
parents: 15
diff changeset
575 }
kono
parents: 15
diff changeset
576
kono
parents: 15
diff changeset
577 if (GET_MODE (reg) != orig_mode)
kono
parents: 15
diff changeset
578 return NULL_RTX;
kono
parents: 15
diff changeset
579
kono
parents: 15
diff changeset
580 return reg;
kono
parents: 15
diff changeset
581 }
kono
parents: 15
diff changeset
582
kono
parents: 15
diff changeset
583 /* Return true if it is okay to merge the comparison CMP_INSN with
kono
parents: 15
diff changeset
584 the instruction ARITH_INSN. Both instructions are assumed to be in the
kono
parents: 15
diff changeset
585 same basic block with ARITH_INSN appearing before CMP_INSN. This checks
kono
parents: 15
diff changeset
586 that there are no uses or defs of the condition flags or control flow
kono
parents: 15
diff changeset
587 changes between the two instructions. */
kono
parents: 15
diff changeset
588
kono
parents: 15
diff changeset
589 static bool
kono
parents: 15
diff changeset
590 can_merge_compare_into_arith (rtx_insn *cmp_insn, rtx_insn *arith_insn)
kono
parents: 15
diff changeset
591 {
kono
parents: 15
diff changeset
592 for (rtx_insn *insn = PREV_INSN (cmp_insn);
kono
parents: 15
diff changeset
593 insn && insn != arith_insn;
kono
parents: 15
diff changeset
594 insn = PREV_INSN (insn))
kono
parents: 15
diff changeset
595 {
kono
parents: 15
diff changeset
596 if (!NONDEBUG_INSN_P (insn))
kono
parents: 15
diff changeset
597 continue;
kono
parents: 15
diff changeset
598 /* Bail if there are jumps or calls in between. */
kono
parents: 15
diff changeset
599 if (!NONJUMP_INSN_P (insn))
kono
parents: 15
diff changeset
600 return false;
kono
parents: 15
diff changeset
601
kono
parents: 15
diff changeset
602 /* Bail on old-style asm statements because they lack
kono
parents: 15
diff changeset
603 data flow information. */
kono
parents: 15
diff changeset
604 if (GET_CODE (PATTERN (insn)) == ASM_INPUT)
kono
parents: 15
diff changeset
605 return false;
kono
parents: 15
diff changeset
606
kono
parents: 15
diff changeset
607 df_ref ref;
kono
parents: 15
diff changeset
608 /* Find a USE of the flags register. */
kono
parents: 15
diff changeset
609 FOR_EACH_INSN_USE (ref, insn)
kono
parents: 15
diff changeset
610 if (DF_REF_REGNO (ref) == targetm.flags_regnum)
kono
parents: 15
diff changeset
611 return false;
kono
parents: 15
diff changeset
612
kono
parents: 15
diff changeset
613 /* Find a DEF of the flags register. */
kono
parents: 15
diff changeset
614 FOR_EACH_INSN_DEF (ref, insn)
kono
parents: 15
diff changeset
615 if (DF_REF_REGNO (ref) == targetm.flags_regnum)
kono
parents: 15
diff changeset
616 return false;
kono
parents: 15
diff changeset
617 }
kono
parents: 15
diff changeset
618 return true;
kono
parents: 15
diff changeset
619 }
kono
parents: 15
diff changeset
620
kono
parents: 15
diff changeset
621 /* Given two SET expressions, SET_A and SET_B determine whether they form
kono
parents: 15
diff changeset
622 a recognizable pattern when emitted in parallel. Return that parallel
kono
parents: 15
diff changeset
623 if so. Otherwise return NULL. */
kono
parents: 15
diff changeset
624
kono
parents: 15
diff changeset
625 static rtx
kono
parents: 15
diff changeset
626 try_validate_parallel (rtx set_a, rtx set_b)
kono
parents: 15
diff changeset
627 {
kono
parents: 15
diff changeset
628 rtx par
kono
parents: 15
diff changeset
629 = gen_rtx_PARALLEL (VOIDmode, gen_rtvec (2, set_a, set_b));
kono
parents: 15
diff changeset
630
kono
parents: 15
diff changeset
631 rtx_insn *insn;
kono
parents: 15
diff changeset
632 insn = gen_rtx_INSN (VOIDmode, 0, 0, 0, par, 0, -1, 0);
kono
parents: 15
diff changeset
633
kono
parents: 15
diff changeset
634 return recog_memoized (insn) > 0 ? par : NULL_RTX;
kono
parents: 15
diff changeset
635 }
kono
parents: 15
diff changeset
636
kono
parents: 15
diff changeset
637 /* For a comparison instruction described by CMP check if it compares a
kono
parents: 15
diff changeset
638 register with zero i.e. it is of the form CC := CMP R1, 0.
kono
parents: 15
diff changeset
639 If it is, find the instruction defining R1 (say I1) and try to create a
kono
parents: 15
diff changeset
640 PARALLEL consisting of I1 and the comparison, representing a flag-setting
kono
parents: 15
diff changeset
641 arithmetic instruction. Example:
kono
parents: 15
diff changeset
642 I1: R1 := R2 + R3
kono
parents: 15
diff changeset
643 <instructions that don't read the condition register>
kono
parents: 15
diff changeset
644 I2: CC := CMP R1 0
kono
parents: 15
diff changeset
645 I2 can be merged with I1 into:
kono
parents: 15
diff changeset
646 I1: { R1 := R2 + R3 ; CC := CMP (R2 + R3) 0 }
kono
parents: 15
diff changeset
647 This catches cases where R1 is used between I1 and I2 and therefore
kono
parents: 15
diff changeset
648 combine and other RTL optimisations will not try to propagate it into
kono
parents: 15
diff changeset
649 I2. Return true if we succeeded in merging CMP. */
kono
parents: 15
diff changeset
650
kono
parents: 15
diff changeset
651 static bool
kono
parents: 15
diff changeset
652 try_merge_compare (struct comparison *cmp)
kono
parents: 15
diff changeset
653 {
kono
parents: 15
diff changeset
654 rtx_insn *cmp_insn = cmp->insn;
kono
parents: 15
diff changeset
655
kono
parents: 15
diff changeset
656 if (!REG_P (cmp->in_a) || cmp->in_b != const0_rtx)
kono
parents: 15
diff changeset
657 return false;
kono
parents: 15
diff changeset
658 rtx in_a = cmp->in_a;
kono
parents: 15
diff changeset
659 df_ref use;
kono
parents: 15
diff changeset
660
kono
parents: 15
diff changeset
661 FOR_EACH_INSN_USE (use, cmp_insn)
kono
parents: 15
diff changeset
662 if (DF_REF_REGNO (use) == REGNO (in_a))
kono
parents: 15
diff changeset
663 break;
kono
parents: 15
diff changeset
664 if (!use)
kono
parents: 15
diff changeset
665 return false;
kono
parents: 15
diff changeset
666
kono
parents: 15
diff changeset
667 /* Validate the data flow information before attempting to
kono
parents: 15
diff changeset
668 find the instruction that defines in_a. */
kono
parents: 15
diff changeset
669
kono
parents: 15
diff changeset
670 struct df_link *ref_chain;
kono
parents: 15
diff changeset
671 ref_chain = DF_REF_CHAIN (use);
kono
parents: 15
diff changeset
672 if (!ref_chain || !ref_chain->ref
kono
parents: 15
diff changeset
673 || !DF_REF_INSN_INFO (ref_chain->ref) || ref_chain->next != NULL)
kono
parents: 15
diff changeset
674 return false;
kono
parents: 15
diff changeset
675
kono
parents: 15
diff changeset
676 rtx_insn *def_insn = DF_REF_INSN (ref_chain->ref);
kono
parents: 15
diff changeset
677 /* We found the insn that defines in_a. Only consider the cases where
kono
parents: 15
diff changeset
678 it is in the same block as the comparison. */
kono
parents: 15
diff changeset
679 if (BLOCK_FOR_INSN (cmp_insn) != BLOCK_FOR_INSN (def_insn))
kono
parents: 15
diff changeset
680 return false;
kono
parents: 15
diff changeset
681
kono
parents: 15
diff changeset
682 rtx set = single_set (def_insn);
kono
parents: 15
diff changeset
683 if (!set)
kono
parents: 15
diff changeset
684 return false;
kono
parents: 15
diff changeset
685
kono
parents: 15
diff changeset
686 if (!can_merge_compare_into_arith (cmp_insn, def_insn))
kono
parents: 15
diff changeset
687 return false;
kono
parents: 15
diff changeset
688
kono
parents: 15
diff changeset
689 rtx src = SET_SRC (set);
kono
parents: 15
diff changeset
690 rtx flags = maybe_select_cc_mode (cmp, src, CONST0_RTX (GET_MODE (src)));
kono
parents: 15
diff changeset
691 if (!flags)
kono
parents: 15
diff changeset
692 {
kono
parents: 15
diff changeset
693 /* We may already have a change group going through maybe_select_cc_mode.
kono
parents: 15
diff changeset
694 Discard it properly. */
kono
parents: 15
diff changeset
695 cancel_changes (0);
kono
parents: 15
diff changeset
696 return false;
kono
parents: 15
diff changeset
697 }
kono
parents: 15
diff changeset
698
kono
parents: 15
diff changeset
699 rtx flag_set
kono
parents: 15
diff changeset
700 = gen_rtx_SET (flags, gen_rtx_COMPARE (GET_MODE (flags),
kono
parents: 15
diff changeset
701 copy_rtx (src),
kono
parents: 15
diff changeset
702 CONST0_RTX (GET_MODE (src))));
kono
parents: 15
diff changeset
703 rtx arith_set = copy_rtx (PATTERN (def_insn));
kono
parents: 15
diff changeset
704 rtx par = try_validate_parallel (flag_set, arith_set);
kono
parents: 15
diff changeset
705 if (!par)
kono
parents: 15
diff changeset
706 {
kono
parents: 15
diff changeset
707 /* We may already have a change group going through maybe_select_cc_mode.
kono
parents: 15
diff changeset
708 Discard it properly. */
kono
parents: 15
diff changeset
709 cancel_changes (0);
kono
parents: 15
diff changeset
710 return false;
kono
parents: 15
diff changeset
711 }
kono
parents: 15
diff changeset
712 if (!apply_change_group ())
kono
parents: 15
diff changeset
713 return false;
kono
parents: 15
diff changeset
714 emit_insn_after (par, def_insn);
kono
parents: 15
diff changeset
715 delete_insn (def_insn);
kono
parents: 15
diff changeset
716 delete_insn (cmp->insn);
kono
parents: 15
diff changeset
717 return true;
kono
parents: 15
diff changeset
718 }
kono
parents: 15
diff changeset
719
15
561a7518be6b update gcc-4.6
Nobuyasu Oshiro <dimolto@cr.ie.u-ryukyu.ac.jp>
parents:
diff changeset
720 /* Attempt to replace a comparison with a prior arithmetic insn that can
561a7518be6b update gcc-4.6
Nobuyasu Oshiro <dimolto@cr.ie.u-ryukyu.ac.jp>
parents:
diff changeset
721 compute the same flags value as the comparison itself. Return true if
561a7518be6b update gcc-4.6
Nobuyasu Oshiro <dimolto@cr.ie.u-ryukyu.ac.jp>
parents:
diff changeset
722 successful, having made all rtl modifications necessary. */
561a7518be6b update gcc-4.6
Nobuyasu Oshiro <dimolto@cr.ie.u-ryukyu.ac.jp>
parents:
diff changeset
723
561a7518be6b update gcc-4.6
Nobuyasu Oshiro <dimolto@cr.ie.u-ryukyu.ac.jp>
parents:
diff changeset
724 static bool
561a7518be6b update gcc-4.6
Nobuyasu Oshiro <dimolto@cr.ie.u-ryukyu.ac.jp>
parents:
diff changeset
725 try_eliminate_compare (struct comparison *cmp)
561a7518be6b update gcc-4.6
Nobuyasu Oshiro <dimolto@cr.ie.u-ryukyu.ac.jp>
parents:
diff changeset
726 {
16
kono
parents: 15
diff changeset
727 rtx flags, in_a, in_b, cmp_src;
15
561a7518be6b update gcc-4.6
Nobuyasu Oshiro <dimolto@cr.ie.u-ryukyu.ac.jp>
parents:
diff changeset
728
16
kono
parents: 15
diff changeset
729 if (try_merge_compare (cmp))
kono
parents: 15
diff changeset
730 return true;
kono
parents: 15
diff changeset
731
kono
parents: 15
diff changeset
732 /* We must have found an interesting "clobber" preceding the compare. */
kono
parents: 15
diff changeset
733 if (cmp->prev_clobber == NULL)
15
561a7518be6b update gcc-4.6
Nobuyasu Oshiro <dimolto@cr.ie.u-ryukyu.ac.jp>
parents:
diff changeset
734 return false;
561a7518be6b update gcc-4.6
Nobuyasu Oshiro <dimolto@cr.ie.u-ryukyu.ac.jp>
parents:
diff changeset
735
561a7518be6b update gcc-4.6
Nobuyasu Oshiro <dimolto@cr.ie.u-ryukyu.ac.jp>
parents:
diff changeset
736 /* Verify that IN_A is not clobbered in between CMP and PREV_CLOBBER.
561a7518be6b update gcc-4.6
Nobuyasu Oshiro <dimolto@cr.ie.u-ryukyu.ac.jp>
parents:
diff changeset
737 Given that this target requires this pass, we can assume that most
561a7518be6b update gcc-4.6
Nobuyasu Oshiro <dimolto@cr.ie.u-ryukyu.ac.jp>
parents:
diff changeset
738 insns do clobber the flags, and so the distance between the compare
561a7518be6b update gcc-4.6
Nobuyasu Oshiro <dimolto@cr.ie.u-ryukyu.ac.jp>
parents:
diff changeset
739 and the clobber is likely to be small. */
561a7518be6b update gcc-4.6
Nobuyasu Oshiro <dimolto@cr.ie.u-ryukyu.ac.jp>
parents:
diff changeset
740 /* ??? This is one point at which one could argue that DF_REF_CHAIN would
561a7518be6b update gcc-4.6
Nobuyasu Oshiro <dimolto@cr.ie.u-ryukyu.ac.jp>
parents:
diff changeset
741 be useful, but it is thought to be too heavy-weight a solution here. */
16
kono
parents: 15
diff changeset
742 in_a = equivalent_reg_at_start (cmp->in_a, cmp->insn, cmp->prev_clobber);
kono
parents: 15
diff changeset
743 if (!in_a)
kono
parents: 15
diff changeset
744 return false;
15
561a7518be6b update gcc-4.6
Nobuyasu Oshiro <dimolto@cr.ie.u-ryukyu.ac.jp>
parents:
diff changeset
745
16
kono
parents: 15
diff changeset
746 /* Likewise for IN_B if need be. */
kono
parents: 15
diff changeset
747 if (CONSTANT_P (cmp->in_b))
kono
parents: 15
diff changeset
748 in_b = cmp->in_b;
kono
parents: 15
diff changeset
749 else if (REG_P (cmp->in_b))
kono
parents: 15
diff changeset
750 {
kono
parents: 15
diff changeset
751 in_b = equivalent_reg_at_start (cmp->in_b, cmp->insn, cmp->prev_clobber);
kono
parents: 15
diff changeset
752 if (!in_b)
15
561a7518be6b update gcc-4.6
Nobuyasu Oshiro <dimolto@cr.ie.u-ryukyu.ac.jp>
parents:
diff changeset
753 return false;
561a7518be6b update gcc-4.6
Nobuyasu Oshiro <dimolto@cr.ie.u-ryukyu.ac.jp>
parents:
diff changeset
754 }
16
kono
parents: 15
diff changeset
755 else if (GET_CODE (cmp->in_b) == UNSPEC)
kono
parents: 15
diff changeset
756 {
kono
parents: 15
diff changeset
757 const int len = XVECLEN (cmp->in_b, 0);
kono
parents: 15
diff changeset
758 rtvec v = rtvec_alloc (len);
kono
parents: 15
diff changeset
759 for (int i = 0; i < len; i++)
kono
parents: 15
diff changeset
760 {
kono
parents: 15
diff changeset
761 rtx r = equivalent_reg_at_start (XVECEXP (cmp->in_b, 0, i),
kono
parents: 15
diff changeset
762 cmp->insn, cmp->prev_clobber);
kono
parents: 15
diff changeset
763 if (!r)
kono
parents: 15
diff changeset
764 return false;
kono
parents: 15
diff changeset
765 RTVEC_ELT (v, i) = r;
kono
parents: 15
diff changeset
766 }
kono
parents: 15
diff changeset
767 in_b = gen_rtx_UNSPEC (GET_MODE (cmp->in_b), v, XINT (cmp->in_b, 1));
kono
parents: 15
diff changeset
768 }
kono
parents: 15
diff changeset
769 else
kono
parents: 15
diff changeset
770 gcc_unreachable ();
15
561a7518be6b update gcc-4.6
Nobuyasu Oshiro <dimolto@cr.ie.u-ryukyu.ac.jp>
parents:
diff changeset
771
561a7518be6b update gcc-4.6
Nobuyasu Oshiro <dimolto@cr.ie.u-ryukyu.ac.jp>
parents:
diff changeset
772 /* We've reached PREV_CLOBBER without finding a modification of IN_A.
561a7518be6b update gcc-4.6
Nobuyasu Oshiro <dimolto@cr.ie.u-ryukyu.ac.jp>
parents:
diff changeset
773 Validate that PREV_CLOBBER itself does in fact refer to IN_A. Do
561a7518be6b update gcc-4.6
Nobuyasu Oshiro <dimolto@cr.ie.u-ryukyu.ac.jp>
parents:
diff changeset
774 recall that we've already validated the shape of PREV_CLOBBER. */
16
kono
parents: 15
diff changeset
775 rtx_insn *insn = cmp->prev_clobber;
kono
parents: 15
diff changeset
776
kono
parents: 15
diff changeset
777 rtx x = XVECEXP (PATTERN (insn), 0, 0);
kono
parents: 15
diff changeset
778 if (rtx_equal_p (SET_DEST (x), in_a))
kono
parents: 15
diff changeset
779 cmp_src = SET_SRC (x);
kono
parents: 15
diff changeset
780
kono
parents: 15
diff changeset
781 /* Also check operations with implicit extensions, e.g.:
kono
parents: 15
diff changeset
782 [(set (reg:DI)
kono
parents: 15
diff changeset
783 (zero_extend:DI (plus:SI (reg:SI) (reg:SI))))
kono
parents: 15
diff changeset
784 (set (reg:CCZ flags)
kono
parents: 15
diff changeset
785 (compare:CCZ (plus:SI (reg:SI) (reg:SI))
kono
parents: 15
diff changeset
786 (const_int 0)))] */
kono
parents: 15
diff changeset
787 else if (REG_P (SET_DEST (x))
kono
parents: 15
diff changeset
788 && REG_P (in_a)
kono
parents: 15
diff changeset
789 && REGNO (SET_DEST (x)) == REGNO (in_a)
kono
parents: 15
diff changeset
790 && (GET_CODE (SET_SRC (x)) == ZERO_EXTEND
kono
parents: 15
diff changeset
791 || GET_CODE (SET_SRC (x)) == SIGN_EXTEND)
kono
parents: 15
diff changeset
792 && GET_MODE (XEXP (SET_SRC (x), 0)) == GET_MODE (in_a))
kono
parents: 15
diff changeset
793 cmp_src = XEXP (SET_SRC (x), 0);
kono
parents: 15
diff changeset
794
kono
parents: 15
diff changeset
795 /* Also check fully redundant comparisons, e.g.:
kono
parents: 15
diff changeset
796 [(set (reg:SI)
kono
parents: 15
diff changeset
797 (minus:SI (reg:SI) (reg:SI))))
kono
parents: 15
diff changeset
798 (set (reg:CC flags)
kono
parents: 15
diff changeset
799 (compare:CC (reg:SI) (reg:SI)))] */
kono
parents: 15
diff changeset
800 else if (REG_P (in_b)
kono
parents: 15
diff changeset
801 && GET_CODE (SET_SRC (x)) == MINUS
kono
parents: 15
diff changeset
802 && rtx_equal_p (XEXP (SET_SRC (x), 0), in_a)
kono
parents: 15
diff changeset
803 && rtx_equal_p (XEXP (SET_SRC (x), 1), in_b))
kono
parents: 15
diff changeset
804 cmp_src = in_a;
kono
parents: 15
diff changeset
805
kono
parents: 15
diff changeset
806 else
15
561a7518be6b update gcc-4.6
Nobuyasu Oshiro <dimolto@cr.ie.u-ryukyu.ac.jp>
parents:
diff changeset
807 return false;
16
kono
parents: 15
diff changeset
808
15
561a7518be6b update gcc-4.6
Nobuyasu Oshiro <dimolto@cr.ie.u-ryukyu.ac.jp>
parents:
diff changeset
809 /* Determine if we ought to use a different CC_MODE here. */
16
kono
parents: 15
diff changeset
810 flags = maybe_select_cc_mode (cmp, cmp_src, in_b);
15
561a7518be6b update gcc-4.6
Nobuyasu Oshiro <dimolto@cr.ie.u-ryukyu.ac.jp>
parents:
diff changeset
811 if (flags == NULL)
561a7518be6b update gcc-4.6
Nobuyasu Oshiro <dimolto@cr.ie.u-ryukyu.ac.jp>
parents:
diff changeset
812 flags = gen_rtx_REG (cmp->orig_mode, targetm.flags_regnum);
561a7518be6b update gcc-4.6
Nobuyasu Oshiro <dimolto@cr.ie.u-ryukyu.ac.jp>
parents:
diff changeset
813
561a7518be6b update gcc-4.6
Nobuyasu Oshiro <dimolto@cr.ie.u-ryukyu.ac.jp>
parents:
diff changeset
814 /* Generate a new comparison for installation in the setter. */
16
kono
parents: 15
diff changeset
815 rtx y = copy_rtx (cmp_src);
kono
parents: 15
diff changeset
816 y = gen_rtx_COMPARE (GET_MODE (flags), y, in_b);
kono
parents: 15
diff changeset
817 y = gen_rtx_SET (flags, y);
15
561a7518be6b update gcc-4.6
Nobuyasu Oshiro <dimolto@cr.ie.u-ryukyu.ac.jp>
parents:
diff changeset
818
16
kono
parents: 15
diff changeset
819 /* Canonicalize instruction to:
kono
parents: 15
diff changeset
820 [(set (reg:CCM) (compare:CCM (operation) (immediate)))
kono
parents: 15
diff changeset
821 (set (reg) (operation)] */
kono
parents: 15
diff changeset
822
kono
parents: 15
diff changeset
823 rtvec v = rtvec_alloc (2);
kono
parents: 15
diff changeset
824 RTVEC_ELT (v, 0) = y;
kono
parents: 15
diff changeset
825 RTVEC_ELT (v, 1) = x;
kono
parents: 15
diff changeset
826
kono
parents: 15
diff changeset
827 rtx pat = gen_rtx_PARALLEL (VOIDmode, v);
kono
parents: 15
diff changeset
828
15
561a7518be6b update gcc-4.6
Nobuyasu Oshiro <dimolto@cr.ie.u-ryukyu.ac.jp>
parents:
diff changeset
829 /* Succeed if the new instruction is valid. Note that we may have started
561a7518be6b update gcc-4.6
Nobuyasu Oshiro <dimolto@cr.ie.u-ryukyu.ac.jp>
parents:
diff changeset
830 a change group within maybe_select_cc_mode, therefore we must continue. */
16
kono
parents: 15
diff changeset
831 validate_change (insn, &PATTERN (insn), pat, true);
kono
parents: 15
diff changeset
832
15
561a7518be6b update gcc-4.6
Nobuyasu Oshiro <dimolto@cr.ie.u-ryukyu.ac.jp>
parents:
diff changeset
833 if (!apply_change_group ())
561a7518be6b update gcc-4.6
Nobuyasu Oshiro <dimolto@cr.ie.u-ryukyu.ac.jp>
parents:
diff changeset
834 return false;
16
kono
parents: 15
diff changeset
835
15
561a7518be6b update gcc-4.6
Nobuyasu Oshiro <dimolto@cr.ie.u-ryukyu.ac.jp>
parents:
diff changeset
836 /* Success. Delete the compare insn... */
561a7518be6b update gcc-4.6
Nobuyasu Oshiro <dimolto@cr.ie.u-ryukyu.ac.jp>
parents:
diff changeset
837 delete_insn (cmp->insn);
561a7518be6b update gcc-4.6
Nobuyasu Oshiro <dimolto@cr.ie.u-ryukyu.ac.jp>
parents:
diff changeset
838
561a7518be6b update gcc-4.6
Nobuyasu Oshiro <dimolto@cr.ie.u-ryukyu.ac.jp>
parents:
diff changeset
839 /* ... and any notes that are now invalid due to multiple sets. */
561a7518be6b update gcc-4.6
Nobuyasu Oshiro <dimolto@cr.ie.u-ryukyu.ac.jp>
parents:
diff changeset
840 x = find_regno_note (insn, REG_UNUSED, targetm.flags_regnum);
561a7518be6b update gcc-4.6
Nobuyasu Oshiro <dimolto@cr.ie.u-ryukyu.ac.jp>
parents:
diff changeset
841 if (x)
561a7518be6b update gcc-4.6
Nobuyasu Oshiro <dimolto@cr.ie.u-ryukyu.ac.jp>
parents:
diff changeset
842 remove_note (insn, x);
561a7518be6b update gcc-4.6
Nobuyasu Oshiro <dimolto@cr.ie.u-ryukyu.ac.jp>
parents:
diff changeset
843 x = find_reg_note (insn, REG_EQUAL, NULL);
561a7518be6b update gcc-4.6
Nobuyasu Oshiro <dimolto@cr.ie.u-ryukyu.ac.jp>
parents:
diff changeset
844 if (x)
561a7518be6b update gcc-4.6
Nobuyasu Oshiro <dimolto@cr.ie.u-ryukyu.ac.jp>
parents:
diff changeset
845 remove_note (insn, x);
561a7518be6b update gcc-4.6
Nobuyasu Oshiro <dimolto@cr.ie.u-ryukyu.ac.jp>
parents:
diff changeset
846 x = find_reg_note (insn, REG_EQUIV, NULL);
561a7518be6b update gcc-4.6
Nobuyasu Oshiro <dimolto@cr.ie.u-ryukyu.ac.jp>
parents:
diff changeset
847 if (x)
561a7518be6b update gcc-4.6
Nobuyasu Oshiro <dimolto@cr.ie.u-ryukyu.ac.jp>
parents:
diff changeset
848 remove_note (insn, x);
561a7518be6b update gcc-4.6
Nobuyasu Oshiro <dimolto@cr.ie.u-ryukyu.ac.jp>
parents:
diff changeset
849
561a7518be6b update gcc-4.6
Nobuyasu Oshiro <dimolto@cr.ie.u-ryukyu.ac.jp>
parents:
diff changeset
850 return true;
561a7518be6b update gcc-4.6
Nobuyasu Oshiro <dimolto@cr.ie.u-ryukyu.ac.jp>
parents:
diff changeset
851 }
561a7518be6b update gcc-4.6
Nobuyasu Oshiro <dimolto@cr.ie.u-ryukyu.ac.jp>
parents:
diff changeset
852
561a7518be6b update gcc-4.6
Nobuyasu Oshiro <dimolto@cr.ie.u-ryukyu.ac.jp>
parents:
diff changeset
853 /* Main entry point to the pass. */
561a7518be6b update gcc-4.6
Nobuyasu Oshiro <dimolto@cr.ie.u-ryukyu.ac.jp>
parents:
diff changeset
854
561a7518be6b update gcc-4.6
Nobuyasu Oshiro <dimolto@cr.ie.u-ryukyu.ac.jp>
parents:
diff changeset
855 static unsigned int
561a7518be6b update gcc-4.6
Nobuyasu Oshiro <dimolto@cr.ie.u-ryukyu.ac.jp>
parents:
diff changeset
856 execute_compare_elim_after_reload (void)
561a7518be6b update gcc-4.6
Nobuyasu Oshiro <dimolto@cr.ie.u-ryukyu.ac.jp>
parents:
diff changeset
857 {
16
kono
parents: 15
diff changeset
858 df_chain_add_problem (DF_UD_CHAIN + DF_DU_CHAIN);
15
561a7518be6b update gcc-4.6
Nobuyasu Oshiro <dimolto@cr.ie.u-ryukyu.ac.jp>
parents:
diff changeset
859 df_analyze ();
561a7518be6b update gcc-4.6
Nobuyasu Oshiro <dimolto@cr.ie.u-ryukyu.ac.jp>
parents:
diff changeset
860
16
kono
parents: 15
diff changeset
861 gcc_checking_assert (!all_compares.exists ());
15
561a7518be6b update gcc-4.6
Nobuyasu Oshiro <dimolto@cr.ie.u-ryukyu.ac.jp>
parents:
diff changeset
862
561a7518be6b update gcc-4.6
Nobuyasu Oshiro <dimolto@cr.ie.u-ryukyu.ac.jp>
parents:
diff changeset
863 /* Locate all comparisons and their uses, and eliminate duplicates. */
561a7518be6b update gcc-4.6
Nobuyasu Oshiro <dimolto@cr.ie.u-ryukyu.ac.jp>
parents:
diff changeset
864 find_comparisons ();
16
kono
parents: 15
diff changeset
865 if (all_compares.exists ())
15
561a7518be6b update gcc-4.6
Nobuyasu Oshiro <dimolto@cr.ie.u-ryukyu.ac.jp>
parents:
diff changeset
866 {
561a7518be6b update gcc-4.6
Nobuyasu Oshiro <dimolto@cr.ie.u-ryukyu.ac.jp>
parents:
diff changeset
867 struct comparison *cmp;
561a7518be6b update gcc-4.6
Nobuyasu Oshiro <dimolto@cr.ie.u-ryukyu.ac.jp>
parents:
diff changeset
868 size_t i;
561a7518be6b update gcc-4.6
Nobuyasu Oshiro <dimolto@cr.ie.u-ryukyu.ac.jp>
parents:
diff changeset
869
561a7518be6b update gcc-4.6
Nobuyasu Oshiro <dimolto@cr.ie.u-ryukyu.ac.jp>
parents:
diff changeset
870 /* Eliminate comparisons that are redundant with flags computation. */
16
kono
parents: 15
diff changeset
871 FOR_EACH_VEC_ELT (all_compares, i, cmp)
15
561a7518be6b update gcc-4.6
Nobuyasu Oshiro <dimolto@cr.ie.u-ryukyu.ac.jp>
parents:
diff changeset
872 {
561a7518be6b update gcc-4.6
Nobuyasu Oshiro <dimolto@cr.ie.u-ryukyu.ac.jp>
parents:
diff changeset
873 try_eliminate_compare (cmp);
561a7518be6b update gcc-4.6
Nobuyasu Oshiro <dimolto@cr.ie.u-ryukyu.ac.jp>
parents:
diff changeset
874 XDELETE (cmp);
561a7518be6b update gcc-4.6
Nobuyasu Oshiro <dimolto@cr.ie.u-ryukyu.ac.jp>
parents:
diff changeset
875 }
561a7518be6b update gcc-4.6
Nobuyasu Oshiro <dimolto@cr.ie.u-ryukyu.ac.jp>
parents:
diff changeset
876
16
kono
parents: 15
diff changeset
877 all_compares.release ();
15
561a7518be6b update gcc-4.6
Nobuyasu Oshiro <dimolto@cr.ie.u-ryukyu.ac.jp>
parents:
diff changeset
878 }
561a7518be6b update gcc-4.6
Nobuyasu Oshiro <dimolto@cr.ie.u-ryukyu.ac.jp>
parents:
diff changeset
879
561a7518be6b update gcc-4.6
Nobuyasu Oshiro <dimolto@cr.ie.u-ryukyu.ac.jp>
parents:
diff changeset
880 return 0;
561a7518be6b update gcc-4.6
Nobuyasu Oshiro <dimolto@cr.ie.u-ryukyu.ac.jp>
parents:
diff changeset
881 }
561a7518be6b update gcc-4.6
Nobuyasu Oshiro <dimolto@cr.ie.u-ryukyu.ac.jp>
parents:
diff changeset
882
16
kono
parents: 15
diff changeset
883 namespace {
kono
parents: 15
diff changeset
884
kono
parents: 15
diff changeset
885 const pass_data pass_data_compare_elim_after_reload =
15
561a7518be6b update gcc-4.6
Nobuyasu Oshiro <dimolto@cr.ie.u-ryukyu.ac.jp>
parents:
diff changeset
886 {
16
kono
parents: 15
diff changeset
887 RTL_PASS, /* type */
kono
parents: 15
diff changeset
888 "cmpelim", /* name */
kono
parents: 15
diff changeset
889 OPTGROUP_NONE, /* optinfo_flags */
kono
parents: 15
diff changeset
890 TV_NONE, /* tv_id */
kono
parents: 15
diff changeset
891 0, /* properties_required */
kono
parents: 15
diff changeset
892 0, /* properties_provided */
kono
parents: 15
diff changeset
893 0, /* properties_destroyed */
kono
parents: 15
diff changeset
894 0, /* todo_flags_start */
kono
parents: 15
diff changeset
895 ( TODO_df_finish | TODO_df_verify ), /* todo_flags_finish */
kono
parents: 15
diff changeset
896 };
15
561a7518be6b update gcc-4.6
Nobuyasu Oshiro <dimolto@cr.ie.u-ryukyu.ac.jp>
parents:
diff changeset
897
16
kono
parents: 15
diff changeset
898 class pass_compare_elim_after_reload : public rtl_opt_pass
15
561a7518be6b update gcc-4.6
Nobuyasu Oshiro <dimolto@cr.ie.u-ryukyu.ac.jp>
parents:
diff changeset
899 {
16
kono
parents: 15
diff changeset
900 public:
kono
parents: 15
diff changeset
901 pass_compare_elim_after_reload (gcc::context *ctxt)
kono
parents: 15
diff changeset
902 : rtl_opt_pass (pass_data_compare_elim_after_reload, ctxt)
kono
parents: 15
diff changeset
903 {}
kono
parents: 15
diff changeset
904
kono
parents: 15
diff changeset
905 /* opt_pass methods: */
kono
parents: 15
diff changeset
906 virtual bool gate (function *)
kono
parents: 15
diff changeset
907 {
kono
parents: 15
diff changeset
908 /* Setting this target hook value is how a backend indicates the need. */
kono
parents: 15
diff changeset
909 if (targetm.flags_regnum == INVALID_REGNUM)
kono
parents: 15
diff changeset
910 return false;
kono
parents: 15
diff changeset
911 return flag_compare_elim_after_reload;
kono
parents: 15
diff changeset
912 }
kono
parents: 15
diff changeset
913
kono
parents: 15
diff changeset
914 virtual unsigned int execute (function *)
kono
parents: 15
diff changeset
915 {
kono
parents: 15
diff changeset
916 return execute_compare_elim_after_reload ();
kono
parents: 15
diff changeset
917 }
kono
parents: 15
diff changeset
918
kono
parents: 15
diff changeset
919 }; // class pass_compare_elim_after_reload
kono
parents: 15
diff changeset
920
kono
parents: 15
diff changeset
921 } // anon namespace
kono
parents: 15
diff changeset
922
kono
parents: 15
diff changeset
923 rtl_opt_pass *
kono
parents: 15
diff changeset
924 make_pass_compare_elim_after_reload (gcc::context *ctxt)
kono
parents: 15
diff changeset
925 {
kono
parents: 15
diff changeset
926 return new pass_compare_elim_after_reload (ctxt);
kono
parents: 15
diff changeset
927 }