1 2002-07-29 Jakub Jelinek <jakub@redhat.com>
3 * gcc.dg/20020729-1.c: New test.
5 2002-05-17 Richard Sandiford <rsandifo@redhat.com>
7 * expr.c (force_operand): Fix reversed move.
9 Sat May 4 13:20:54 CEST 2002 Jan Hubicka <jh@suse.cz>
11 * expr.c (force_operand): Use expand_simple_* to handle more
14 --- gcc/expr.c.jj 2002-05-07 12:45:49.000000000 +0200
15 +++ gcc/expr.c 2002-08-03 01:08:28.000000000 +0200
16 @@ -5434,16 +5434,13 @@ rtx
17 force_operand (value, target)
21 - /* Use a temporary to force order of execution of calls to
26 /* Use subtarget as the target for operand 0 of a binary operation. */
27 rtx subtarget = get_subtarget (target);
28 + enum rtx_code code = GET_CODE (value);
30 /* Check for a PIC address load. */
31 - if ((GET_CODE (value) == PLUS || GET_CODE (value) == MINUS)
32 + if ((code == PLUS || code == MINUS)
33 && XEXP (value, 0) == pic_offset_table_rtx
34 && (GET_CODE (XEXP (value, 1)) == SYMBOL_REF
35 || GET_CODE (XEXP (value, 1)) == LABEL_REF
36 @@ -5455,60 +5452,88 @@ force_operand (value, target)
40 - if (GET_CODE (value) == PLUS)
41 - binoptab = add_optab;
42 - else if (GET_CODE (value) == MINUS)
43 - binoptab = sub_optab;
44 - else if (GET_CODE (value) == MULT)
45 + if (code == ZERO_EXTEND || code == SIGN_EXTEND)
47 - op2 = XEXP (value, 1);
48 - if (!CONSTANT_P (op2)
49 - && !(GET_CODE (op2) == REG && op2 != subtarget))
51 - tmp = force_operand (XEXP (value, 0), subtarget);
52 - return expand_mult (GET_MODE (value), tmp,
53 - force_operand (op2, NULL_RTX),
56 + target = gen_reg_rtx (GET_MODE (value));
57 + convert_move (target, force_operand (XEXP (value, 0), NULL),
58 + code == ZERO_EXTEND);
63 + if (GET_RTX_CLASS (code) == '2' || GET_RTX_CLASS (code) == 'c')
65 op2 = XEXP (value, 1);
66 - if (!CONSTANT_P (op2)
67 - && !(GET_CODE (op2) == REG && op2 != subtarget))
68 + if (!CONSTANT_P (op2) && !(GET_CODE (op2) == REG && op2 != subtarget))
70 - if (binoptab == sub_optab && GET_CODE (op2) == CONST_INT)
71 + if (code == MINUS && GET_CODE (op2) == CONST_INT)
73 - binoptab = add_optab;
75 op2 = negate_rtx (GET_MODE (value), op2);
78 /* Check for an addition with OP2 a constant integer and our first
79 - operand a PLUS of a virtual register and something else. In that
80 - case, we want to emit the sum of the virtual register and the
81 - constant first and then add the other value. This allows virtual
82 - register instantiation to simply modify the constant rather than
83 - creating another one around this addition. */
84 - if (binoptab == add_optab && GET_CODE (op2) == CONST_INT
85 + operand a PLUS of a virtual register and something else. In that
86 + case, we want to emit the sum of the virtual register and the
87 + constant first and then add the other value. This allows virtual
88 + register instantiation to simply modify the constant rather than
89 + creating another one around this addition. */
90 + if (code == PLUS && GET_CODE (op2) == CONST_INT
91 && GET_CODE (XEXP (value, 0)) == PLUS
92 && GET_CODE (XEXP (XEXP (value, 0), 0)) == REG
93 && REGNO (XEXP (XEXP (value, 0), 0)) >= FIRST_VIRTUAL_REGISTER
94 && REGNO (XEXP (XEXP (value, 0), 0)) <= LAST_VIRTUAL_REGISTER)
96 - rtx temp = expand_binop (GET_MODE (value), binoptab,
97 - XEXP (XEXP (value, 0), 0), op2,
98 - subtarget, 0, OPTAB_LIB_WIDEN);
99 - return expand_binop (GET_MODE (value), binoptab, temp,
100 - force_operand (XEXP (XEXP (value, 0), 1), 0),
101 - target, 0, OPTAB_LIB_WIDEN);
102 + rtx temp = expand_simple_binop (GET_MODE (value), code,
103 + XEXP (XEXP (value, 0), 0), op2,
104 + subtarget, 0, OPTAB_LIB_WIDEN);
105 + return expand_simple_binop (GET_MODE (value), code, temp,
106 + force_operand (XEXP (XEXP (value,
108 + target, 0, OPTAB_LIB_WIDEN);
111 + op1 = force_operand (XEXP (value, 0), subtarget);
112 + op2 = force_operand (op2, NULL_RTX);
116 + return expand_mult (GET_MODE (value), op1, op2, target, 1);
118 + if (!INTEGRAL_MODE_P (GET_MODE (value)))
119 + return expand_simple_binop (GET_MODE (value), code, op1, op2,
120 + target, 1, OPTAB_LIB_WIDEN);
122 + return expand_divmod (0,
123 + FLOAT_MODE_P (GET_MODE (value))
124 + ? RDIV_EXPR : TRUNC_DIV_EXPR,
125 + GET_MODE (value), op1, op2, target, 0);
128 + return expand_divmod (1, TRUNC_MOD_EXPR, GET_MODE (value), op1, op2,
132 + return expand_divmod (0, TRUNC_DIV_EXPR, GET_MODE (value), op1, op2,
136 + return expand_divmod (1, TRUNC_MOD_EXPR, GET_MODE (value), op1, op2,
140 + return expand_simple_binop (GET_MODE (value), code, op1, op2,
141 + target, 0, OPTAB_LIB_WIDEN);
144 + return expand_simple_binop (GET_MODE (value), code, op1, op2,
145 + target, 1, OPTAB_LIB_WIDEN);
148 - tmp = force_operand (XEXP (value, 0), subtarget);
149 - return expand_binop (GET_MODE (value), binoptab, tmp,
150 - force_operand (op2, NULL_RTX),
151 - target, 0, OPTAB_LIB_WIDEN);
152 - /* We give UNSIGNEDP = 0 to expand_binop
153 - because the only operations we are expanding here are signed ones. */
155 + if (GET_RTX_CLASS (code) == '1')
157 + op1 = force_operand (XEXP (value, 0), NULL_RTX);
158 + return expand_simple_unop (GET_MODE (value), code, op1, target, 0);
161 #ifdef INSN_SCHEDULING
162 --- gcc/testsuite/gcc.dg/20020729-1.c.jj 2002-08-03 01:08:28.000000000 +0200
163 +++ gcc/testsuite/gcc.dg/20020729-1.c 2002-08-03 01:08:28.000000000 +0200
165 +/* { dg-do compile { target i?86-*-* } } */
166 +/* { dg-options "-O2 -march=k6" } */
168 +static inline void *
169 +baz (void *s, unsigned long c, unsigned int count)
172 + __asm__ __volatile__ (""
173 + : "=&c" (d0), "=&D" (d1)
174 + :"a" (c), "q" (count), "0" (count / 4), "1" ((long) s)
184 +inline static void *
185 +bar (struct A *x, int y)
189 + ptr = (void *) x->a[y >> 12];
190 + ptr += y % (1UL << 12);
191 + return (void *) ptr;
195 +foo (struct A *x, unsigned int *y, int z, int u)
209 + baz (bar (x, z), 0, d);