predicates.md (easy_fp_constant): Return 0 for SFmode and DFmode before reload when...
[gcc.git] / gcc / config / rs6000 / predicates.md
1 ;; Predicate definitions for POWER and PowerPC.
2 ;; Copyright (C) 2005 Free Software Foundation, Inc.
3 ;;
4 ;; This file is part of GCC.
5 ;;
6 ;; GCC is free software; you can redistribute it and/or modify
7 ;; it under the terms of the GNU General Public License as published by
8 ;; the Free Software Foundation; either version 2, or (at your option)
9 ;; any later version.
10 ;;
11 ;; GCC is distributed in the hope that it will be useful,
12 ;; but WITHOUT ANY WARRANTY; without even the implied warranty of
13 ;; MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
14 ;; GNU General Public License for more details.
15 ;;
16 ;; You should have received a copy of the GNU General Public License
17 ;; along with GCC; see the file COPYING. If not, write to
18 ;; the Free Software Foundation, 59 Temple Place - Suite 330,
19 ;; Boston, MA 02111-1307, USA.
20
21 ;; Return 1 for anything except PARALLEL.
22 (define_predicate "any_operand"
23 (match_code "const_int,const_double,const,symbol_ref,label_ref,subreg,reg,mem"))
24
25 ;; Return 1 for any PARALLEL.
26 (define_predicate "any_parallel_operand"
27 (match_code "parallel"))
28
29 ;; Return 1 if op is COUNT register.
30 (define_predicate "count_register_operand"
31 (and (match_code "reg")
32 (match_test "REGNO (op) == COUNT_REGISTER_REGNUM
33 || REGNO (op) > LAST_VIRTUAL_REGISTER")))
34
35 ;; Return 1 if op is an Altivec register.
36 (define_predicate "altivec_register_operand"
37 (and (match_code "reg")
38 (match_test "ALTIVEC_REGNO_P (REGNO (op))
39 || REGNO (op) > LAST_VIRTUAL_REGISTER")))
40
41 ;; Return 1 if op is XER register.
42 (define_predicate "xer_operand"
43 (and (match_code "reg")
44 (match_test "XER_REGNO_P (REGNO (op))")))
45
46 ;; Return 1 if op is a signed 8-bit constant integer.
47 ;; Integer multiplcation complete more quickly
48 (define_predicate "s8bit_cint_operand"
49 (and (match_code "const_int")
50 (match_test "INTVAL (op) >= -128 && INTVAL (op) <= 127")))
51
52 ;; Return 1 if op is a constant integer that can fit in a D field.
53 (define_predicate "short_cint_operand"
54 (and (match_code "const_int")
55 (match_test "CONST_OK_FOR_LETTER_P (INTVAL (op), 'I')")))
56
57 ;; Return 1 if op is a constant integer that can fit in an unsigned D field.
58 (define_predicate "u_short_cint_operand"
59 (and (match_code "const_int")
60 (match_test "CONST_OK_FOR_LETTER_P (INTVAL (op), 'K')")))
61
62 ;; Return 1 if op is a constant integer that cannot fit in a signed D field.
63 (define_predicate "non_short_cint_operand"
64 (and (match_code "const_int")
65 (match_test "(unsigned HOST_WIDE_INT)
66 (INTVAL (op) + 0x8000) >= 0x10000")))
67
68 ;; Return 1 if op is a positive constant integer that is an exact power of 2.
69 (define_predicate "exact_log2_cint_operand"
70 (and (match_code "const_int")
71 (match_test "INTVAL (op) > 0 && exact_log2 (INTVAL (op)) >= 0")))
72
73 ;; Return 1 if op is a register that is not special.
74 (define_predicate "gpc_reg_operand"
75 (and (match_code "reg,subreg")
76 (and (match_operand 0 "register_operand")
77 (match_test "GET_CODE (op) != REG
78 || (REGNO (op) >= ARG_POINTER_REGNUM
79 && !XER_REGNO_P (REGNO (op)))
80 || REGNO (op) < MQ_REGNO"))))
81
82 ;; Return 1 if op is a register that is a condition register field.
83 (define_predicate "cc_reg_operand"
84 (and (match_code "reg,subreg")
85 (and (match_operand 0 "register_operand")
86 (match_test "GET_CODE (op) != REG
87 || REGNO (op) > LAST_VIRTUAL_REGISTER
88 || CR_REGNO_P (REGNO (op))"))))
89
90 ;; Return 1 if op is a register that is a condition register field not cr0.
91 (define_predicate "cc_reg_not_cr0_operand"
92 (and (match_code "reg,subreg")
93 (and (match_operand 0 "register_operand")
94 (match_test "GET_CODE (op) != REG
95 || REGNO (op) > LAST_VIRTUAL_REGISTER
96 || CR_REGNO_NOT_CR0_P (REGNO (op))"))))
97
98 ;; Return 1 if op is a constant integer valid for D field
99 ;; or non-special register register.
100 (define_predicate "reg_or_short_operand"
101 (if_then_else (match_code "const_int")
102 (match_operand 0 "short_cint_operand")
103 (match_operand 0 "gpc_reg_operand")))
104
105 ;; Return 1 if op is a constant integer valid whose negation is valid for
106 ;; D field or non-special register register.
107 ;; Do not allow a constant zero because all patterns that call this
108 ;; predicate use "addic r1,r2,-const" to set carry when r2 is greater than
109 ;; or equal to const, which does not work for zero.
110 (define_predicate "reg_or_neg_short_operand"
111 (if_then_else (match_code "const_int")
112 (match_test "CONST_OK_FOR_LETTER_P (INTVAL (op), 'P')
113 && INTVAL (op) != 0")
114 (match_operand 0 "gpc_reg_operand")))
115
116 ;; Return 1 if op is a constant integer valid for DS field
117 ;; or non-special register.
118 (define_predicate "reg_or_aligned_short_operand"
119 (if_then_else (match_code "const_int")
120 (and (match_operand 0 "short_cint_operand")
121 (match_test "!(INTVAL (op) & 3)"))
122 (match_operand 0 "gpc_reg_operand")))
123
124 ;; Return 1 if op is a constant integer whose high-order 16 bits are zero
125 ;; or non-special register.
126 (define_predicate "reg_or_u_short_operand"
127 (if_then_else (match_code "const_int")
128 (match_operand 0 "u_short_cint_operand")
129 (match_operand 0 "gpc_reg_operand")))
130
131 ;; Return 1 if op is any constant integer
132 ;; or non-special register.
133 (define_predicate "reg_or_cint_operand"
134 (ior (match_code "const_int")
135 (match_operand 0 "gpc_reg_operand")))
136
137 ;; Return 1 if op is a 32-bit signed constant integer valid for arithmetic
138 ;; or non-special register.
139 (define_predicate "reg_or_arith_cint_operand"
140 (if_then_else (match_code "const_int")
141 (match_test "HOST_BITS_PER_WIDE_INT == 32
142 || ((unsigned HOST_WIDE_INT) (INTVAL (op) + 0x80000000)
143 < (unsigned HOST_WIDE_INT) 0x100000000ll)")
144 (match_operand 0 "gpc_reg_operand")))
145
146 ;; Return 1 if op is a 32-bit signed constant integer valid for 64-bit addition
147 ;; or non-special register.
148 (define_predicate "reg_or_add_cint64_operand"
149 (if_then_else (match_code "const_int")
150 (match_test "(HOST_BITS_PER_WIDE_INT == 32 && INTVAL (op) < 0x7fff8000)
151 || ((unsigned HOST_WIDE_INT) (INTVAL (op) + 0x80008000)
152 < (unsigned HOST_WIDE_INT) 0x100000000ll)")
153 (match_operand 0 "gpc_reg_operand")))
154
155 ;; Return 1 if op is a 32-bit constant integer valid for 64-bit subtraction
156 ;; or non-special register.
157 (define_predicate "reg_or_sub_cint64_operand"
158 (if_then_else (match_code "const_int")
159 (match_test "(HOST_BITS_PER_WIDE_INT == 32 && INTVAL (op) < 0x7fff8000)
160 || ((unsigned HOST_WIDE_INT) ((- INTVAL (op)) + 0x80008000)
161 < (unsigned HOST_WIDE_INT) 0x100000000ll)")
162 (match_operand 0 "gpc_reg_operand")))
163
164 ;; Return 1 if op is any 32-bit unsigned constant integer
165 ;; or non-special register.
166 (define_predicate "reg_or_logical_cint_operand"
167 (if_then_else (match_code "const_int")
168 (match_test "(GET_MODE_BITSIZE (mode) > HOST_BITS_PER_WIDE_INT
169 && INTVAL (op) >= 0)
170 || ((INTVAL (op) & GET_MODE_MASK (mode)
171 & (~ (unsigned HOST_WIDE_INT) 0xffffffff)) == 0)")
172 (if_then_else (match_code "const_double")
173 (match_test "GET_MODE_BITSIZE (mode) > HOST_BITS_PER_WIDE_INT
174 && mode == DImode
175 && CONST_DOUBLE_HIGH (op) == 0")
176 (match_operand 0 "gpc_reg_operand"))))
177
178 ;; Return 1 if operand is a CONST_DOUBLE that can be set in a register
179 ;; with no more than one instruction per word.
180 (define_predicate "easy_fp_constant"
181 (match_code "const_double")
182 {
183 if (GET_MODE (op) != mode
184 || (GET_MODE_CLASS (mode) != MODE_FLOAT && mode != DImode))
185 return 0;
186
187 /* Consider all constants with -msoft-float to be easy. */
188 if ((TARGET_SOFT_FLOAT || TARGET_E500_SINGLE)
189 && mode != DImode)
190 return 1;
191
192 /* If we are using V.4 style PIC, consider all constants to be hard. */
193 if (flag_pic && DEFAULT_ABI == ABI_V4)
194 return 0;
195
196 #ifdef TARGET_RELOCATABLE
197 /* Similarly if we are using -mrelocatable, consider all constants
198 to be hard. */
199 if (TARGET_RELOCATABLE)
200 return 0;
201 #endif
202
203 if (mode == TFmode)
204 {
205 long k[4];
206 REAL_VALUE_TYPE rv;
207
208 REAL_VALUE_FROM_CONST_DOUBLE (rv, op);
209 REAL_VALUE_TO_TARGET_LONG_DOUBLE (rv, k);
210
211 return (num_insns_constant_wide ((HOST_WIDE_INT) k[0]) == 1
212 && num_insns_constant_wide ((HOST_WIDE_INT) k[1]) == 1
213 && num_insns_constant_wide ((HOST_WIDE_INT) k[2]) == 1
214 && num_insns_constant_wide ((HOST_WIDE_INT) k[3]) == 1);
215 }
216
217 else if (mode == DFmode)
218 {
219 long k[2];
220 REAL_VALUE_TYPE rv;
221
222 /* Force constants to memory before reload to utilize
223 compress_float_constant.
224 Avoid this when flag_unsafe_math_optimizations is enabled
225 because RDIV division to reciprocal optimization is not able
226 to regenerate the division. */
227 if (TARGET_E500_DOUBLE
228 || (!reload_in_progress && !reload_completed
229 && !flag_unsafe_math_optimizations))
230 return 0;
231
232 REAL_VALUE_FROM_CONST_DOUBLE (rv, op);
233 REAL_VALUE_TO_TARGET_DOUBLE (rv, k);
234
235 return (num_insns_constant_wide ((HOST_WIDE_INT) k[0]) == 1
236 && num_insns_constant_wide ((HOST_WIDE_INT) k[1]) == 1);
237 }
238
239 else if (mode == SFmode)
240 {
241 long l;
242 REAL_VALUE_TYPE rv;
243
244 /* Force constants to memory before reload to utilize
245 compress_float_constant.
246 Avoid this when flag_unsafe_math_optimizations is enabled
247 because RDIV division to reciprocal optimization is not able
248 to regenerate the division. */
249 if (!reload_in_progress && !reload_completed
250 && !flag_unsafe_math_optimizations)
251 return 0;
252
253 REAL_VALUE_FROM_CONST_DOUBLE (rv, op);
254 REAL_VALUE_TO_TARGET_SINGLE (rv, l);
255
256 return num_insns_constant_wide (l) == 1;
257 }
258
259 else if (mode == DImode)
260 return ((TARGET_POWERPC64
261 && GET_CODE (op) == CONST_DOUBLE && CONST_DOUBLE_LOW (op) == 0)
262 || (num_insns_constant (op, DImode) <= 2));
263
264 else if (mode == SImode)
265 return 1;
266 else
267 abort ();
268 })
269
270 ;; Return 1 if the operand is a CONST_VECTOR and can be loaded into a
271 ;; vector register without using memory.
272 (define_predicate "easy_vector_constant"
273 (match_code "const_vector")
274 {
275 int cst, cst2;
276
277 if (!TARGET_ALTIVEC && !TARGET_SPE)
278 return 0;
279
280 if (zero_constant (op, mode)
281 && ((TARGET_ALTIVEC && ALTIVEC_VECTOR_MODE (mode))
282 || (TARGET_SPE && SPE_VECTOR_MODE (mode))))
283 return 1;
284
285 if (GET_MODE_CLASS (mode) != MODE_VECTOR_INT)
286 return 0;
287
288 if (TARGET_SPE && mode == V1DImode)
289 return 0;
290
291 cst = INTVAL (CONST_VECTOR_ELT (op, 0));
292 cst2 = INTVAL (CONST_VECTOR_ELT (op, 1));
293
294 /* Limit SPE vectors to 15 bits signed. These we can generate with:
295 li r0, CONSTANT1
296 evmergelo r0, r0, r0
297 li r0, CONSTANT2
298
299 I don't know how efficient it would be to allow bigger constants,
300 considering we'll have an extra 'ori' for every 'li'. I doubt 5
301 instructions is better than a 64-bit memory load, but I don't
302 have the e500 timing specs. */
303 if (TARGET_SPE && mode == V2SImode
304 && cst >= -0x7fff && cst <= 0x7fff
305 && cst2 >= -0x7fff && cst2 <= 0x7fff)
306 return 1;
307
308 if (TARGET_ALTIVEC
309 && easy_vector_same (op, mode))
310 {
311 cst = easy_vector_splat_const (cst, mode);
312 if (EASY_VECTOR_15_ADD_SELF (cst)
313 || EASY_VECTOR_15 (cst))
314 return 1;
315 }
316 return 0;
317 })
318
319 ;; Same as easy_vector_constant but only for EASY_VECTOR_15_ADD_SELF.
320 (define_predicate "easy_vector_constant_add_self"
321 (and (match_code "const_vector")
322 (and (match_test "TARGET_ALTIVEC")
323 (and (match_test "easy_vector_same (op, mode)")
324 (match_test "EASY_VECTOR_15_ADD_SELF
325 (easy_vector_splat_const
326 (INTVAL (CONST_VECTOR_ELT (op, 0)),
327 mode))")))))
328
329 ;; Return 1 if operand is constant zero (scalars and vectors).
330 (define_predicate "zero_constant"
331 (and (match_code "const_int,const_double,const_vector")
332 (match_test "op == CONST0_RTX (mode)")))
333
334 ;; Return 1 if operand is 0.0.
335 ;; or non-special register register field no cr0
336 (define_predicate "zero_fp_constant"
337 (and (match_code "const_double")
338 (match_test "GET_MODE_CLASS (mode) == MODE_FLOAT
339 && op == CONST0_RTX (mode)")))
340
341 ;; Return 1 if the operand is in volatile memory. Note that during the
342 ;; RTL generation phase, memory_operand does not return TRUE for volatile
343 ;; memory references. So this function allows us to recognize volatile
344 ;; references where its safe.
345 (define_predicate "volatile_mem_operand"
346 (and (and (match_code "mem")
347 (match_test "MEM_VOLATILE_P (op)"))
348 (if_then_else (match_test "reload_completed")
349 (match_operand 0 "memory_operand")
350 (if_then_else (match_test "reload_in_progress")
351 (match_test "strict_memory_address_p (mode, XEXP (op, 0))")
352 (match_test "memory_address_p (mode, XEXP (op, 0))")))))
353
354 ;; Return 1 if the operand is an offsettable memory operand.
355 (define_predicate "offsettable_mem_operand"
356 (and (match_code "mem")
357 (match_test "offsettable_address_p (reload_completed
358 || reload_in_progress,
359 mode, XEXP (op, 0))")))
360
361 ;; Return 1 if the operand is either a non-special register or can be used
362 ;; as the operand of a `mode' add insn.
363 (define_predicate "add_operand"
364 (if_then_else (match_code "const_int")
365 (match_test "CONST_OK_FOR_LETTER_P (INTVAL (op), 'I')
366 || CONST_OK_FOR_LETTER_P (INTVAL (op), 'L')")
367 (match_operand 0 "gpc_reg_operand")))
368
369 ;; Return 1 if OP is a constant but not a valid add_operand.
370 (define_predicate "non_add_cint_operand"
371 (and (match_code "const_int")
372 (match_test "!CONST_OK_FOR_LETTER_P (INTVAL (op), 'I')
373 && !CONST_OK_FOR_LETTER_P (INTVAL (op), 'L')")))
374
375 ;; Return 1 if the operand is a non-special register or a constant that
376 ;; can be used as the operand of an OR or XOR.
377 (define_predicate "logical_operand"
378 (match_code "reg,subreg,const_int,const_double")
379 {
380 HOST_WIDE_INT opl, oph;
381
382 if (gpc_reg_operand (op, mode))
383 return 1;
384
385 if (GET_CODE (op) == CONST_INT)
386 {
387 opl = INTVAL (op) & GET_MODE_MASK (mode);
388
389 if (HOST_BITS_PER_WIDE_INT <= 32
390 && GET_MODE_BITSIZE (mode) > HOST_BITS_PER_WIDE_INT && opl < 0)
391 return 0;
392 }
393 else if (GET_CODE (op) == CONST_DOUBLE)
394 {
395 if (GET_MODE_BITSIZE (mode) <= HOST_BITS_PER_WIDE_INT)
396 abort ();
397
398 opl = CONST_DOUBLE_LOW (op);
399 oph = CONST_DOUBLE_HIGH (op);
400 if (oph != 0)
401 return 0;
402 }
403 else
404 return 0;
405
406 return ((opl & ~ (unsigned HOST_WIDE_INT) 0xffff) == 0
407 || (opl & ~ (unsigned HOST_WIDE_INT) 0xffff0000) == 0);
408 })
409
410 ;; Return 1 if op is a constant that is not a logical operand, but could
411 ;; be split into one.
412 (define_predicate "non_logical_cint_operand"
413 (and (match_code "const_int,const_double")
414 (and (not (match_operand 0 "logical_operand"))
415 (match_operand 0 "reg_or_logical_cint_operand"))))
416
417 ;; Return 1 if op is a constant that can be encoded in a 32-bit mask (no
418 ;; more than two 1->0 or 0->1 transitions). Reject all ones and all
419 ;; zeros, since these should have been optimized away and confuse the
420 ;; making of MB and ME.
421 (define_predicate "mask_operand"
422 (match_code "const_int")
423 {
424 HOST_WIDE_INT c, lsb;
425
426 c = INTVAL (op);
427
428 /* Fail in 64-bit mode if the mask wraps around because the upper
429 32-bits of the mask will all be 1s, contrary to GCC's internal view. */
430 if (TARGET_POWERPC64 && (c & 0x80000001) == 0x80000001)
431 return 0;
432
433 /* We don't change the number of transitions by inverting,
434 so make sure we start with the LS bit zero. */
435 if (c & 1)
436 c = ~c;
437
438 /* Reject all zeros or all ones. */
439 if (c == 0)
440 return 0;
441
442 /* Find the first transition. */
443 lsb = c & -c;
444
445 /* Invert to look for a second transition. */
446 c = ~c;
447
448 /* Erase first transition. */
449 c &= -lsb;
450
451 /* Find the second transition (if any). */
452 lsb = c & -c;
453
454 /* Match if all the bits above are 1's (or c is zero). */
455 return c == -lsb;
456 })
457
458 ;; Return 1 for the PowerPC64 rlwinm corner case.
459 (define_predicate "mask_operand_wrap"
460 (match_code "const_int")
461 {
462 HOST_WIDE_INT c, lsb;
463
464 c = INTVAL (op);
465
466 if ((c & 0x80000001) != 0x80000001)
467 return 0;
468
469 c = ~c;
470 if (c == 0)
471 return 0;
472
473 lsb = c & -c;
474 c = ~c;
475 c &= -lsb;
476 lsb = c & -c;
477 return c == -lsb;
478 })
479
480 ;; Return 1 if the operand is a constant that is a PowerPC64 mask (no more
481 ;; than one 1->0 or 0->1 transitions). Reject all zeros, since zero
482 ;; should have been optimized away and confuses the making of MB and ME.
483 (define_predicate "mask64_operand"
484 (match_code "const_int")
485 {
486 HOST_WIDE_INT c, lsb;
487
488 c = INTVAL (op);
489
490 /* Reject all zeros. */
491 if (c == 0)
492 return 0;
493
494 /* We don't change the number of transitions by inverting,
495 so make sure we start with the LS bit zero. */
496 if (c & 1)
497 c = ~c;
498
499 /* Find the transition, and check that all bits above are 1's. */
500 lsb = c & -c;
501
502 /* Match if all the bits above are 1's (or c is zero). */
503 return c == -lsb;
504 })
505
506 ;; Like mask64_operand, but allow up to three transitions. This
507 ;; predicate is used by insn patterns that generate two rldicl or
508 ;; rldicr machine insns.
509 (define_predicate "mask64_2_operand"
510 (match_code "const_int")
511 {
512 return mask64_1or2_operand (op, mode, false);
513 })
514
515 ;; Return 1 if the operand is either a non-special register or a constant
516 ;; that can be used as the operand of a PowerPC64 logical AND insn.
517 (define_predicate "and64_operand"
518 (if_then_else (match_code "const_int")
519 (match_operand 0 "mask64_operand")
520 (if_then_else (match_test "fixed_regs[CR0_REGNO]")
521 (match_operand 0 "gpc_reg_operand")
522 (match_operand 0 "logical_operand"))))
523
524 ;; Like and64_operand, but also match constants that can be implemented
525 ;; with two rldicl or rldicr insns.
526 (define_predicate "and64_2_operand"
527 (if_then_else (match_code "const_int")
528 (match_test "mask64_1or2_operand (op, mode, true)")
529 (if_then_else (match_test "fixed_regs[CR0_REGNO]")
530 (match_operand 0 "gpc_reg_operand")
531 (match_operand 0 "logical_operand"))))
532
533 ;; Return 1 if the operand is either a non-special register or a
534 ;; constant that can be used as the operand of a logical AND.
535 (define_predicate "and_operand"
536 (if_then_else (match_code "const_int")
537 (match_operand 0 "mask_operand")
538 (if_then_else (match_test "fixed_regs[CR0_REGNO]")
539 (match_operand 0 "gpc_reg_operand")
540 (match_operand 0 "logical_operand"))))
541
542 ;; Return 1 if the operand is a general non-special register or memory operand.
543 (define_predicate "reg_or_mem_operand"
544 (if_then_else (match_code "mem")
545 (ior (match_operand 0 "memory_operand")
546 (ior (match_test "macho_lo_sum_memory_operand (op, mode)")
547 (match_operand 0 "volatile_mem_operand")))
548 (match_operand 0 "gpc_reg_operand")))
549
550 ;; Return 1 if the operand is either an easy FP constant or memory or reg.
551 (define_predicate "reg_or_none500mem_operand"
552 (if_then_else (match_code "mem")
553 (and (match_test "!TARGET_E500_DOUBLE")
554 (ior (match_operand 0 "memory_operand")
555 (ior (match_test "macho_lo_sum_memory_operand (op, mode)")
556 (match_operand 0 "volatile_mem_operand"))))
557 (match_operand 0 "gpc_reg_operand")))
558
559 ;; Return 1 if the operand is CONST_DOUBLE 0, register or memory operand.
560 (define_predicate "zero_reg_mem_operand"
561 (ior (match_operand 0 "zero_fp_constant")
562 (match_operand 0 "reg_or_mem_operand")))
563
564 ;; Return 1 if the operand is a general register or memory operand without
565 ;; pre_inc or pre_dec, which produces invalid form of PowerPC lwa
566 ;; instruction.
567 (define_predicate "lwa_operand"
568 (match_code "reg,subreg,mem")
569 {
570 rtx inner = op;
571
572 if (reload_completed && GET_CODE (inner) == SUBREG)
573 inner = SUBREG_REG (inner);
574
575 return gpc_reg_operand (inner, mode)
576 || (memory_operand (inner, mode)
577 && GET_CODE (XEXP (inner, 0)) != PRE_INC
578 && GET_CODE (XEXP (inner, 0)) != PRE_DEC
579 && (GET_CODE (XEXP (inner, 0)) != PLUS
580 || GET_CODE (XEXP (XEXP (inner, 0), 1)) != CONST_INT
581 || INTVAL (XEXP (XEXP (inner, 0), 1)) % 4 == 0));
582 })
583
584 ;; Return 1 if the operand, used inside a MEM, is a SYMBOL_REF.
585 (define_predicate "symbol_ref_operand"
586 (and (match_code "symbol_ref")
587 (match_test "(mode == VOIDmode || GET_MODE (op) == mode)
588 && (DEFAULT_ABI != ABI_AIX || SYMBOL_REF_FUNCTION_P (op))")))
589
590 ;; Return 1 if op is an operand that can be loaded via the GOT.
591 ;; or non-special register register field no cr0
592 (define_predicate "got_operand"
593 (match_code "symbol_ref,const,label_ref"))
594
595 ;; Return 1 if op is a simple reference that can be loaded via the GOT,
596 ;; exclusing labels involving addition.
597 (define_predicate "got_no_const_operand"
598 (match_code "symbol_ref,label_ref"))
599
600 ;; Return 1 if op is a SYMBOL_REF for a TLS symbol.
601 (define_predicate "rs6000_tls_symbol_ref"
602 (and (match_code "symbol_ref")
603 (match_test "RS6000_SYMBOL_REF_TLS_P (op)")))
604
605 ;; Return 1 if the operand, used inside a MEM, is a valid first argument
606 ;; to CALL. This is a SYMBOL_REF, a pseudo-register, LR or CTR.
607 (define_predicate "call_operand"
608 (if_then_else (match_code "reg")
609 (match_test "REGNO (op) == LINK_REGISTER_REGNUM
610 || REGNO (op) == COUNT_REGISTER_REGNUM
611 || REGNO (op) >= FIRST_PSEUDO_REGISTER")
612 (match_code "symbol_ref")))
613
614 ;; Return 1 if the operand is a SYMBOL_REF for a function known to be in
615 ;; this file.
616 (define_predicate "current_file_function_operand"
617 (and (match_code "symbol_ref")
618 (match_test "(DEFAULT_ABI != ABI_AIX || SYMBOL_REF_FUNCTION_P (op))
619 && (SYMBOL_REF_LOCAL_P (op)
620 || (op == XEXP (DECL_RTL (current_function_decl),
621 0)))")))
622
623 ;; Return 1 if this operand is a valid input for a move insn.
624 (define_predicate "input_operand"
625 (match_code "label_ref,symbol_ref,const,high,reg,subreg,mem,
626 const_double,const_vector,const_int,plus")
627 {
628 /* Memory is always valid. */
629 if (memory_operand (op, mode))
630 return 1;
631
632 /* For floating-point, easy constants are valid. */
633 if (GET_MODE_CLASS (mode) == MODE_FLOAT
634 && CONSTANT_P (op)
635 && easy_fp_constant (op, mode))
636 return 1;
637
638 /* Allow any integer constant. */
639 if (GET_MODE_CLASS (mode) == MODE_INT
640 && (GET_CODE (op) == CONST_INT
641 || GET_CODE (op) == CONST_DOUBLE))
642 return 1;
643
644 /* Allow easy vector constants. */
645 if (GET_CODE (op) == CONST_VECTOR
646 && easy_vector_constant (op, mode))
647 return 1;
648
649 /* For floating-point or multi-word mode, the only remaining valid type
650 is a register. */
651 if (GET_MODE_CLASS (mode) == MODE_FLOAT
652 || GET_MODE_SIZE (mode) > UNITS_PER_WORD)
653 return register_operand (op, mode);
654
655 /* The only cases left are integral modes one word or smaller (we
656 do not get called for MODE_CC values). These can be in any
657 register. */
658 if (register_operand (op, mode))
659 return 1;
660
661 /* A SYMBOL_REF referring to the TOC is valid. */
662 if (legitimate_constant_pool_address_p (op))
663 return 1;
664
665 /* A constant pool expression (relative to the TOC) is valid */
666 if (toc_relative_expr_p (op))
667 return 1;
668
669 /* V.4 allows SYMBOL_REFs and CONSTs that are in the small data region
670 to be valid. */
671 if (DEFAULT_ABI == ABI_V4
672 && (GET_CODE (op) == SYMBOL_REF || GET_CODE (op) == CONST)
673 && small_data_operand (op, Pmode))
674 return 1;
675
676 return 0;
677 })
678
679 ;; Return true if OP is an invalid SUBREG operation on the e500.
680 (define_predicate "rs6000_nonimmediate_operand"
681 (match_code "reg,subreg,mem")
682 {
683 if (TARGET_E500_DOUBLE
684 && GET_CODE (op) == SUBREG
685 && invalid_e500_subreg (op, mode))
686 return 0;
687
688 return nonimmediate_operand (op, mode);
689 })
690
691 ;; Return true if operand is boolean operator.
692 (define_predicate "boolean_operator"
693 (match_code "and,ior,xor"))
694
695 ;; Return true if operand is OR-form of boolean operator.
696 (define_predicate "boolean_or_operator"
697 (match_code "ior,xor"))
698
699 ;; Return true if operand is MIN or MAX operator.
700 (define_predicate "min_max_operator"
701 (match_code "smin,smax,umin,umax"))
702
703 ;; Return 1 if OP is a comparison operation that is valid for a branch
704 ;; instruction. We check the opcode against the mode of the CC value.
705 ;; validate_condition_mode is an assertion.
706 (define_predicate "branch_comparison_operator"
707 (and (match_operand 0 "comparison_operator")
708 (and (match_test "GET_MODE_CLASS (GET_MODE (XEXP (op, 0))) == MODE_CC")
709 (match_test "validate_condition_mode (GET_CODE (op),
710 GET_MODE (XEXP (op, 0))),
711 1"))))
712
713 ;; Return 1 if OP is a comparison operation that is valid for an SCC insn --
714 ;; it must be a positive comparison.
715 (define_predicate "scc_comparison_operator"
716 (and (match_operand 0 "branch_comparison_operator")
717 (match_code "eq,lt,gt,ltu,gtu,unordered")))
718
719 ;; Return 1 if OP is a comparison operation that is valid for a branch
720 ;; insn, which is true if the corresponding bit in the CC register is set.
721 (define_predicate "branch_positive_comparison_operator"
722 (and (match_operand 0 "branch_comparison_operator")
723 (match_code "eq,lt,gt,ltu,gtu,unordered")))
724
725 ;; Return 1 is OP is a comparison operation that is valid for a trap insn.
726 (define_predicate "trap_comparison_operator"
727 (and (match_operand 0 "comparison_operator")
728 (match_code "eq,ne,le,lt,ge,gt,leu,ltu,geu,gtu")))
729
730 ;; Return 1 if OP is a load multiple operation, known to be a PARALLEL.
731 (define_predicate "load_multiple_operation"
732 (match_code "parallel")
733 {
734 int count = XVECLEN (op, 0);
735 unsigned int dest_regno;
736 rtx src_addr;
737 int i;
738
739 /* Perform a quick check so we don't blow up below. */
740 if (count <= 1
741 || GET_CODE (XVECEXP (op, 0, 0)) != SET
742 || GET_CODE (SET_DEST (XVECEXP (op, 0, 0))) != REG
743 || GET_CODE (SET_SRC (XVECEXP (op, 0, 0))) != MEM)
744 return 0;
745
746 dest_regno = REGNO (SET_DEST (XVECEXP (op, 0, 0)));
747 src_addr = XEXP (SET_SRC (XVECEXP (op, 0, 0)), 0);
748
749 for (i = 1; i < count; i++)
750 {
751 rtx elt = XVECEXP (op, 0, i);
752
753 if (GET_CODE (elt) != SET
754 || GET_CODE (SET_DEST (elt)) != REG
755 || GET_MODE (SET_DEST (elt)) != SImode
756 || REGNO (SET_DEST (elt)) != dest_regno + i
757 || GET_CODE (SET_SRC (elt)) != MEM
758 || GET_MODE (SET_SRC (elt)) != SImode
759 || GET_CODE (XEXP (SET_SRC (elt), 0)) != PLUS
760 || ! rtx_equal_p (XEXP (XEXP (SET_SRC (elt), 0), 0), src_addr)
761 || GET_CODE (XEXP (XEXP (SET_SRC (elt), 0), 1)) != CONST_INT
762 || INTVAL (XEXP (XEXP (SET_SRC (elt), 0), 1)) != i * 4)
763 return 0;
764 }
765
766 return 1;
767 })
768
769 ;; Return 1 if OP is a store multiple operation, known to be a PARALLEL.
770 ;; The second vector element is a CLOBBER.
771 (define_predicate "store_multiple_operation"
772 (match_code "parallel")
773 {
774 int count = XVECLEN (op, 0) - 1;
775 unsigned int src_regno;
776 rtx dest_addr;
777 int i;
778
779 /* Perform a quick check so we don't blow up below. */
780 if (count <= 1
781 || GET_CODE (XVECEXP (op, 0, 0)) != SET
782 || GET_CODE (SET_DEST (XVECEXP (op, 0, 0))) != MEM
783 || GET_CODE (SET_SRC (XVECEXP (op, 0, 0))) != REG)
784 return 0;
785
786 src_regno = REGNO (SET_SRC (XVECEXP (op, 0, 0)));
787 dest_addr = XEXP (SET_DEST (XVECEXP (op, 0, 0)), 0);
788
789 for (i = 1; i < count; i++)
790 {
791 rtx elt = XVECEXP (op, 0, i + 1);
792
793 if (GET_CODE (elt) != SET
794 || GET_CODE (SET_SRC (elt)) != REG
795 || GET_MODE (SET_SRC (elt)) != SImode
796 || REGNO (SET_SRC (elt)) != src_regno + i
797 || GET_CODE (SET_DEST (elt)) != MEM
798 || GET_MODE (SET_DEST (elt)) != SImode
799 || GET_CODE (XEXP (SET_DEST (elt), 0)) != PLUS
800 || ! rtx_equal_p (XEXP (XEXP (SET_DEST (elt), 0), 0), dest_addr)
801 || GET_CODE (XEXP (XEXP (SET_DEST (elt), 0), 1)) != CONST_INT
802 || INTVAL (XEXP (XEXP (SET_DEST (elt), 0), 1)) != i * 4)
803 return 0;
804 }
805
806 return 1;
807 })
808
809 ;; Return 1 if OP is valid for a save_world call in prologue, known to be
810 ;; a PARLLEL.
811 (define_predicate "save_world_operation"
812 (match_code "parallel")
813 {
814 int index;
815 int i;
816 rtx elt;
817 int count = XVECLEN (op, 0);
818
819 if (count != 55)
820 return 0;
821
822 index = 0;
823 if (GET_CODE (XVECEXP (op, 0, index++)) != CLOBBER
824 || GET_CODE (XVECEXP (op, 0, index++)) != USE)
825 return 0;
826
827 for (i=1; i <= 18; i++)
828 {
829 elt = XVECEXP (op, 0, index++);
830 if (GET_CODE (elt) != SET
831 || GET_CODE (SET_DEST (elt)) != MEM
832 || ! memory_operand (SET_DEST (elt), DFmode)
833 || GET_CODE (SET_SRC (elt)) != REG
834 || GET_MODE (SET_SRC (elt)) != DFmode)
835 return 0;
836 }
837
838 for (i=1; i <= 12; i++)
839 {
840 elt = XVECEXP (op, 0, index++);
841 if (GET_CODE (elt) != SET
842 || GET_CODE (SET_DEST (elt)) != MEM
843 || GET_CODE (SET_SRC (elt)) != REG
844 || GET_MODE (SET_SRC (elt)) != V4SImode)
845 return 0;
846 }
847
848 for (i=1; i <= 19; i++)
849 {
850 elt = XVECEXP (op, 0, index++);
851 if (GET_CODE (elt) != SET
852 || GET_CODE (SET_DEST (elt)) != MEM
853 || ! memory_operand (SET_DEST (elt), Pmode)
854 || GET_CODE (SET_SRC (elt)) != REG
855 || GET_MODE (SET_SRC (elt)) != Pmode)
856 return 0;
857 }
858
859 elt = XVECEXP (op, 0, index++);
860 if (GET_CODE (elt) != SET
861 || GET_CODE (SET_DEST (elt)) != MEM
862 || ! memory_operand (SET_DEST (elt), Pmode)
863 || GET_CODE (SET_SRC (elt)) != REG
864 || REGNO (SET_SRC (elt)) != CR2_REGNO
865 || GET_MODE (SET_SRC (elt)) != Pmode)
866 return 0;
867
868 if (GET_CODE (XVECEXP (op, 0, index++)) != USE
869 || GET_CODE (XVECEXP (op, 0, index++)) != USE
870 || GET_CODE (XVECEXP (op, 0, index++)) != CLOBBER)
871 return 0;
872 return 1;
873 })
874
875 ;; Return 1 if OP is valid for a restore_world call in epilogue, known to be
876 ;; a PARLLEL.
877 (define_predicate "restore_world_operation"
878 (match_code "parallel")
879 {
880 int index;
881 int i;
882 rtx elt;
883 int count = XVECLEN (op, 0);
884
885 if (count != 59)
886 return 0;
887
888 index = 0;
889 if (GET_CODE (XVECEXP (op, 0, index++)) != RETURN
890 || GET_CODE (XVECEXP (op, 0, index++)) != USE
891 || GET_CODE (XVECEXP (op, 0, index++)) != USE
892 || GET_CODE (XVECEXP (op, 0, index++)) != CLOBBER)
893 return 0;
894
895 elt = XVECEXP (op, 0, index++);
896 if (GET_CODE (elt) != SET
897 || GET_CODE (SET_SRC (elt)) != MEM
898 || ! memory_operand (SET_SRC (elt), Pmode)
899 || GET_CODE (SET_DEST (elt)) != REG
900 || REGNO (SET_DEST (elt)) != CR2_REGNO
901 || GET_MODE (SET_DEST (elt)) != Pmode)
902 return 0;
903
904 for (i=1; i <= 19; i++)
905 {
906 elt = XVECEXP (op, 0, index++);
907 if (GET_CODE (elt) != SET
908 || GET_CODE (SET_SRC (elt)) != MEM
909 || ! memory_operand (SET_SRC (elt), Pmode)
910 || GET_CODE (SET_DEST (elt)) != REG
911 || GET_MODE (SET_DEST (elt)) != Pmode)
912 return 0;
913 }
914
915 for (i=1; i <= 12; i++)
916 {
917 elt = XVECEXP (op, 0, index++);
918 if (GET_CODE (elt) != SET
919 || GET_CODE (SET_SRC (elt)) != MEM
920 || GET_CODE (SET_DEST (elt)) != REG
921 || GET_MODE (SET_DEST (elt)) != V4SImode)
922 return 0;
923 }
924
925 for (i=1; i <= 18; i++)
926 {
927 elt = XVECEXP (op, 0, index++);
928 if (GET_CODE (elt) != SET
929 || GET_CODE (SET_SRC (elt)) != MEM
930 || ! memory_operand (SET_SRC (elt), DFmode)
931 || GET_CODE (SET_DEST (elt)) != REG
932 || GET_MODE (SET_DEST (elt)) != DFmode)
933 return 0;
934 }
935
936 if (GET_CODE (XVECEXP (op, 0, index++)) != CLOBBER
937 || GET_CODE (XVECEXP (op, 0, index++)) != CLOBBER
938 || GET_CODE (XVECEXP (op, 0, index++)) != CLOBBER
939 || GET_CODE (XVECEXP (op, 0, index++)) != CLOBBER
940 || GET_CODE (XVECEXP (op, 0, index++)) != USE)
941 return 0;
942 return 1;
943 })
944
945 ;; Return 1 if OP is valid for a vrsave call, known to be a PARALLEL.
946 (define_predicate "vrsave_operation"
947 (match_code "parallel")
948 {
949 int count = XVECLEN (op, 0);
950 unsigned int dest_regno, src_regno;
951 int i;
952
953 if (count <= 1
954 || GET_CODE (XVECEXP (op, 0, 0)) != SET
955 || GET_CODE (SET_DEST (XVECEXP (op, 0, 0))) != REG
956 || GET_CODE (SET_SRC (XVECEXP (op, 0, 0))) != UNSPEC_VOLATILE)
957 return 0;
958
959 dest_regno = REGNO (SET_DEST (XVECEXP (op, 0, 0)));
960 src_regno = REGNO (SET_SRC (XVECEXP (op, 0, 0)));
961
962 if (dest_regno != VRSAVE_REGNO
963 && src_regno != VRSAVE_REGNO)
964 return 0;
965
966 for (i = 1; i < count; i++)
967 {
968 rtx elt = XVECEXP (op, 0, i);
969
970 if (GET_CODE (elt) != CLOBBER
971 && GET_CODE (elt) != SET)
972 return 0;
973 }
974
975 return 1;
976 })
977
978 ;; Return 1 if OP is valid for mfcr insn, known to be a PARALLEL.
979 (define_predicate "mfcr_operation"
980 (match_code "parallel")
981 {
982 int count = XVECLEN (op, 0);
983 int i;
984
985 /* Perform a quick check so we don't blow up below. */
986 if (count < 1
987 || GET_CODE (XVECEXP (op, 0, 0)) != SET
988 || GET_CODE (SET_SRC (XVECEXP (op, 0, 0))) != UNSPEC
989 || XVECLEN (SET_SRC (XVECEXP (op, 0, 0)), 0) != 2)
990 return 0;
991
992 for (i = 0; i < count; i++)
993 {
994 rtx exp = XVECEXP (op, 0, i);
995 rtx unspec;
996 int maskval;
997 rtx src_reg;
998
999 src_reg = XVECEXP (SET_SRC (exp), 0, 0);
1000
1001 if (GET_CODE (src_reg) != REG
1002 || GET_MODE (src_reg) != CCmode
1003 || ! CR_REGNO_P (REGNO (src_reg)))
1004 return 0;
1005
1006 if (GET_CODE (exp) != SET
1007 || GET_CODE (SET_DEST (exp)) != REG
1008 || GET_MODE (SET_DEST (exp)) != SImode
1009 || ! INT_REGNO_P (REGNO (SET_DEST (exp))))
1010 return 0;
1011 unspec = SET_SRC (exp);
1012 maskval = 1 << (MAX_CR_REGNO - REGNO (src_reg));
1013
1014 if (GET_CODE (unspec) != UNSPEC
1015 || XINT (unspec, 1) != UNSPEC_MOVESI_FROM_CR
1016 || XVECLEN (unspec, 0) != 2
1017 || XVECEXP (unspec, 0, 0) != src_reg
1018 || GET_CODE (XVECEXP (unspec, 0, 1)) != CONST_INT
1019 || INTVAL (XVECEXP (unspec, 0, 1)) != maskval)
1020 return 0;
1021 }
1022 return 1;
1023 })
1024
1025 ;; Return 1 if OP is valid for mtcrf insn, known to be a PARALLEL.
1026 (define_predicate "mtcrf_operation"
1027 (match_code "parallel")
1028 {
1029 int count = XVECLEN (op, 0);
1030 int i;
1031 rtx src_reg;
1032
1033 /* Perform a quick check so we don't blow up below. */
1034 if (count < 1
1035 || GET_CODE (XVECEXP (op, 0, 0)) != SET
1036 || GET_CODE (SET_SRC (XVECEXP (op, 0, 0))) != UNSPEC
1037 || XVECLEN (SET_SRC (XVECEXP (op, 0, 0)), 0) != 2)
1038 return 0;
1039 src_reg = XVECEXP (SET_SRC (XVECEXP (op, 0, 0)), 0, 0);
1040
1041 if (GET_CODE (src_reg) != REG
1042 || GET_MODE (src_reg) != SImode
1043 || ! INT_REGNO_P (REGNO (src_reg)))
1044 return 0;
1045
1046 for (i = 0; i < count; i++)
1047 {
1048 rtx exp = XVECEXP (op, 0, i);
1049 rtx unspec;
1050 int maskval;
1051
1052 if (GET_CODE (exp) != SET
1053 || GET_CODE (SET_DEST (exp)) != REG
1054 || GET_MODE (SET_DEST (exp)) != CCmode
1055 || ! CR_REGNO_P (REGNO (SET_DEST (exp))))
1056 return 0;
1057 unspec = SET_SRC (exp);
1058 maskval = 1 << (MAX_CR_REGNO - REGNO (SET_DEST (exp)));
1059
1060 if (GET_CODE (unspec) != UNSPEC
1061 || XINT (unspec, 1) != UNSPEC_MOVESI_TO_CR
1062 || XVECLEN (unspec, 0) != 2
1063 || XVECEXP (unspec, 0, 0) != src_reg
1064 || GET_CODE (XVECEXP (unspec, 0, 1)) != CONST_INT
1065 || INTVAL (XVECEXP (unspec, 0, 1)) != maskval)
1066 return 0;
1067 }
1068 return 1;
1069 })
1070
1071 ;; Return 1 if OP is valid for lmw insn, known to be a PARALLEL.
1072 (define_predicate "lmw_operation"
1073 (match_code "parallel")
1074 {
1075 int count = XVECLEN (op, 0);
1076 unsigned int dest_regno;
1077 rtx src_addr;
1078 unsigned int base_regno;
1079 HOST_WIDE_INT offset;
1080 int i;
1081
1082 /* Perform a quick check so we don't blow up below. */
1083 if (count <= 1
1084 || GET_CODE (XVECEXP (op, 0, 0)) != SET
1085 || GET_CODE (SET_DEST (XVECEXP (op, 0, 0))) != REG
1086 || GET_CODE (SET_SRC (XVECEXP (op, 0, 0))) != MEM)
1087 return 0;
1088
1089 dest_regno = REGNO (SET_DEST (XVECEXP (op, 0, 0)));
1090 src_addr = XEXP (SET_SRC (XVECEXP (op, 0, 0)), 0);
1091
1092 if (dest_regno > 31
1093 || count != 32 - (int) dest_regno)
1094 return 0;
1095
1096 if (legitimate_indirect_address_p (src_addr, 0))
1097 {
1098 offset = 0;
1099 base_regno = REGNO (src_addr);
1100 if (base_regno == 0)
1101 return 0;
1102 }
1103 else if (rs6000_legitimate_offset_address_p (SImode, src_addr, 0))
1104 {
1105 offset = INTVAL (XEXP (src_addr, 1));
1106 base_regno = REGNO (XEXP (src_addr, 0));
1107 }
1108 else
1109 return 0;
1110
1111 for (i = 0; i < count; i++)
1112 {
1113 rtx elt = XVECEXP (op, 0, i);
1114 rtx newaddr;
1115 rtx addr_reg;
1116 HOST_WIDE_INT newoffset;
1117
1118 if (GET_CODE (elt) != SET
1119 || GET_CODE (SET_DEST (elt)) != REG
1120 || GET_MODE (SET_DEST (elt)) != SImode
1121 || REGNO (SET_DEST (elt)) != dest_regno + i
1122 || GET_CODE (SET_SRC (elt)) != MEM
1123 || GET_MODE (SET_SRC (elt)) != SImode)
1124 return 0;
1125 newaddr = XEXP (SET_SRC (elt), 0);
1126 if (legitimate_indirect_address_p (newaddr, 0))
1127 {
1128 newoffset = 0;
1129 addr_reg = newaddr;
1130 }
1131 else if (rs6000_legitimate_offset_address_p (SImode, newaddr, 0))
1132 {
1133 addr_reg = XEXP (newaddr, 0);
1134 newoffset = INTVAL (XEXP (newaddr, 1));
1135 }
1136 else
1137 return 0;
1138 if (REGNO (addr_reg) != base_regno
1139 || newoffset != offset + 4 * i)
1140 return 0;
1141 }
1142
1143 return 1;
1144 })
1145
1146 ;; Return 1 if OP is valid for stmw insn, known to be a PARALLEL.
1147 (define_predicate "stmw_operation"
1148 (match_code "parallel")
1149 {
1150 int count = XVECLEN (op, 0);
1151 unsigned int src_regno;
1152 rtx dest_addr;
1153 unsigned int base_regno;
1154 HOST_WIDE_INT offset;
1155 int i;
1156
1157 /* Perform a quick check so we don't blow up below. */
1158 if (count <= 1
1159 || GET_CODE (XVECEXP (op, 0, 0)) != SET
1160 || GET_CODE (SET_DEST (XVECEXP (op, 0, 0))) != MEM
1161 || GET_CODE (SET_SRC (XVECEXP (op, 0, 0))) != REG)
1162 return 0;
1163
1164 src_regno = REGNO (SET_SRC (XVECEXP (op, 0, 0)));
1165 dest_addr = XEXP (SET_DEST (XVECEXP (op, 0, 0)), 0);
1166
1167 if (src_regno > 31
1168 || count != 32 - (int) src_regno)
1169 return 0;
1170
1171 if (legitimate_indirect_address_p (dest_addr, 0))
1172 {
1173 offset = 0;
1174 base_regno = REGNO (dest_addr);
1175 if (base_regno == 0)
1176 return 0;
1177 }
1178 else if (rs6000_legitimate_offset_address_p (SImode, dest_addr, 0))
1179 {
1180 offset = INTVAL (XEXP (dest_addr, 1));
1181 base_regno = REGNO (XEXP (dest_addr, 0));
1182 }
1183 else
1184 return 0;
1185
1186 for (i = 0; i < count; i++)
1187 {
1188 rtx elt = XVECEXP (op, 0, i);
1189 rtx newaddr;
1190 rtx addr_reg;
1191 HOST_WIDE_INT newoffset;
1192
1193 if (GET_CODE (elt) != SET
1194 || GET_CODE (SET_SRC (elt)) != REG
1195 || GET_MODE (SET_SRC (elt)) != SImode
1196 || REGNO (SET_SRC (elt)) != src_regno + i
1197 || GET_CODE (SET_DEST (elt)) != MEM
1198 || GET_MODE (SET_DEST (elt)) != SImode)
1199 return 0;
1200 newaddr = XEXP (SET_DEST (elt), 0);
1201 if (legitimate_indirect_address_p (newaddr, 0))
1202 {
1203 newoffset = 0;
1204 addr_reg = newaddr;
1205 }
1206 else if (rs6000_legitimate_offset_address_p (SImode, newaddr, 0))
1207 {
1208 addr_reg = XEXP (newaddr, 0);
1209 newoffset = INTVAL (XEXP (newaddr, 1));
1210 }
1211 else
1212 return 0;
1213 if (REGNO (addr_reg) != base_regno
1214 || newoffset != offset + 4 * i)
1215 return 0;
1216 }
1217
1218 return 1;
1219 })