* expr.c (expand_expr_real_1) <MAX_EXPR>: Ensure that target, op0
and op1 are all registers (or constants) before expanding the RTL
comparison sequence [to avoid reg_overlap_mentioned (target, op1)].
* gcc.dg/max-1.c: New test case.
git-svn-id: svn+ssh://gcc.gnu.org/svn/gcc/trunk@92351
138bc75d-0d04-0410-961f-
82ee72b054a4
+2004-12-18 Roger Sayle <roger@eyesopen.com>
+
+ PR middle-end/18548
+ * expr.c (expand_expr_real_1) <MAX_EXPR>: Ensure that target, op0
+ and op1 are all registers (or constants) before expanding the RTL
+ comparison sequence [to avoid reg_overlap_mentioned (target, op1)].
+
2004-12-18 Eric Botcazou <ebotcazou@libertysurf.fr>
PR rtl-optimization/16968
/* At this point, a MEM target is no longer useful; we will get better
code without it. */
- if (MEM_P (target))
+ if (! REG_P (target))
target = gen_reg_rtx (mode);
/* If op1 was placed in target, swap op0 and op1. */
op1 = tem;
}
+ /* We generate better code and avoid problems with op1 mentioning
+ target by forcing op1 into a pseudo if it isn't a constant. */
+ if (! CONSTANT_P (op1))
+ op1 = force_reg (mode, op1);
+
if (target != op0)
emit_move_insn (target, op0);
+2004-12-18 Roger Sayle <roger@eyesopen.com>
+
+ PR middle-end/18548
+ * gcc.dg/max-1.c: New test case.
+
2004-12-18 Jakub Jelinek <jakub@redhat.com>
* gcc.c-torture/execute/20041218-1.c: New test.
--- /dev/null
+/* PR middle-end/18548 */
+/* Test case reduced by Andrew Pinski <pinskia@physics.uc.edu> */
+/* { dg-do run } */
+/* { dg-options "-O1 -fno-tree-lrs" } */
+
+extern void abort (void);
+
+long fff[10];
+
+void f(long a, long b)
+{
+ long crcc = b;
+ long d = *((long*)(a+1));
+ int i;
+
+ a = d >= b? d:b;
+
+
+ for(i=0;i<10;i++)
+ fff[i] = a;
+}
+
+int main(void)
+{
+ int i;
+ long a = 10;
+ f((long)(&a)-1,0);
+ for(i = 0;i<10;i++)
+ if (fff[i]!=10)
+ abort ();
+ return 0;
+}
+