comparison gcc/doc/match-and-simplify.texi @ 131:84e7813d76e9

gcc-8.2
author mir3636
date Thu, 25 Oct 2018 07:37:49 +0900
parents 04ced10e8804
children 1830386684a0
comparison
equal deleted inserted replaced
111:04ced10e8804 131:84e7813d76e9
1 @c Copyright (C) 2014-2017 Free Software Foundation, Inc. 1 @c Copyright (C) 2014-2018 Free Software Foundation, Inc.
2 @c Free Software Foundation, Inc. 2 @c Free Software Foundation, Inc.
3 @c This is part of the GCC manual. 3 @c This is part of the GCC manual.
4 @c For copying conditions, see the file gcc.texi. 4 @c For copying conditions, see the file gcc.texi.
5 5
6 @node Match and Simplify 6 @node Match and Simplify
203 #if GIMPLE 203 #if GIMPLE
204 (simplify 204 (simplify
205 (pointer_plus (addr@@2 @@0) INTEGER_CST_P@@1) 205 (pointer_plus (addr@@2 @@0) INTEGER_CST_P@@1)
206 (if (is_gimple_min_invariant (@@2))) 206 (if (is_gimple_min_invariant (@@2)))
207 @{ 207 @{
208 HOST_WIDE_INT off; 208 poly_int64 off;
209 tree base = get_addr_base_and_unit_offset (@@0, &off); 209 tree base = get_addr_base_and_unit_offset (@@0, &off);
210 off += tree_to_uhwi (@@1); 210 off += tree_to_uhwi (@@1);
211 /* Now with that we should be able to simply write 211 /* Now with that we should be able to simply write
212 (addr (mem_ref (addr @@base) (plus @@off @@1))) */ 212 (addr (mem_ref (addr @@base) (plus @@off @@1))) */
213 build1 (ADDR_EXPR, type, 213 build1 (ADDR_EXPR, type,
248 applied before matching, so for example constant operands always 248 applied before matching, so for example constant operands always
249 come second in commutative expressions. 249 come second in commutative expressions.
250 250
251 The second supported flag is @code{s} which tells the code 251 The second supported flag is @code{s} which tells the code
252 generator to fail the pattern if the expression marked with 252 generator to fail the pattern if the expression marked with
253 @code{s} does have more than one use. For example in 253 @code{s} does have more than one use and the simplification
254 results in an expression with more than one operator.
255 For example in
254 256
255 @smallexample 257 @smallexample
256 (simplify 258 (simplify
257 (pointer_plus (pointer_plus:s @@0 @@1) @@3) 259 (pointer_plus (pointer_plus:s @@0 @@1) @@3)
258 (pointer_plus @@0 (plus @@1 @@3))) 260 (pointer_plus @@0 (plus @@1 @@3)))
259 @end smallexample 261 @end smallexample
260 262
261 this avoids the association if @code{(pointer_plus @@0 @@1)} is 263 this avoids the association if @code{(pointer_plus @@0 @@1)} is
262 used outside of the matched expression and thus it would stay 264 used outside of the matched expression and thus it would stay
263 live and not trivially removed by dead code elimination. 265 live and not trivially removed by dead code elimination.
266 Now consider @code{((x + 3) + -3)} with the temporary
267 holding @code{(x + 3)} used elsewhere. This simplifies down
268 to @code{x} which is desirable and thus flagging with @code{s}
269 does not prevent the transform. Now consider @code{((x + 3) + 1)}
270 which simplifies to @code{(x + 4)}. Despite being flagged with
271 @code{s} the simplification will be performed. The
272 simplification of @code{((x + a) + 1)} to @code{(x + (a + 1))} will
273 not performed in this case though.
264 274
265 More features exist to avoid too much repetition. 275 More features exist to avoid too much repetition.
266 276
267 @smallexample 277 @smallexample
268 (for op (plus pointer_plus minus bit_ior bit_xor) 278 (for op (plus pointer_plus minus bit_ior bit_xor)