2005-10-02 Jakub Jelinek <jakub@redhat.com>
PR optimization/12799
* gcc.c-torture/execute/20051002-1.c: New test.
2003-11-02 Eric Botcazou <ebotcazou@libertysurf.fr>
PR optimization/12799
* reload1.c (reload_cse_move2add): Generate the add2
patterns manually.
* gcc.dg/20031102-1.c: New test.
--- gcc/reload1.c.jj 2003-10-31 11:42:15.000000000 +0100
+++ gcc/reload1.c 2005-10-02 21:52:08.000000000 +0200
@@ -9176,8 +9176,13 @@ reload_cse_move2add (first)
success = validate_change (insn, &SET_SRC (pat), reg, 0);
else if (rtx_cost (new_src, PLUS) < rtx_cost (src, SET)
&& have_add2_insn (reg, new_src))
- success = validate_change (insn, &PATTERN (insn),
- gen_add2_insn (reg, new_src), 0);
+ {
+ rtx newpat = gen_rtx_SET (VOIDmode, reg,
+ gen_rtx_PLUS (GET_MODE (reg),
+ reg, new_src));
+ success
+ = validate_change (insn, &PATTERN (insn), newpat, 0);
+ }
reg_set_luid[regno] = move2add_luid;
reg_mode[regno] = GET_MODE (reg);
reg_offset[regno] = INTVAL (src);
@@ -9227,9 +9232,15 @@ reload_cse_move2add (first)
else if ((rtx_cost (new_src, PLUS)
< COSTS_N_INSNS (1) + rtx_cost (src3, SET))
&& have_add2_insn (reg, new_src))
- success
- = validate_change (next, &PATTERN (next),
- gen_add2_insn (reg, new_src), 0);
+ {
+ rtx newpat
+ = gen_rtx_SET (VOIDmode, reg,
+ gen_rtx_PLUS (GET_MODE (reg),
+ reg, new_src));
+ success
+ = validate_change (next, &PATTERN (next),
+ newpat, 0);
+ }
if (success)
delete_insn (insn);
insn = next;
--- gcc/testsuite/gcc.dg/20031102-1.c.jj 1 Jan 1970 00:00:00 -0000
+++ gcc/testsuite/gcc.dg/20031102-1.c 2 Nov 2003 08:32:23 -0000 1.1
@@ -0,0 +1,37 @@
+/* PR optimization/12799 */
+/* Origin: Pratap Subrahmanyam <pratap@vmware.com> */
+
+/* { dg-do run } */
+/* { dg-options "-O2" } */
+/* { dg-options "-O2 -march=i686" { target i686-*-* } } */
+
+/* Verify that reload_cse_move2add doesn't add unexpected CLOBBERs. */
+
+extern void abort(void);
+
+int loo = 1;
+
+__inline__ char InlineFunc(void)
+{
+ return __builtin_expect(!!(loo == 1), 1);
+}
+
+int FooBar(void)
+{
+ int i;
+ int var1 = InlineFunc() ? 2046 : 1023;
+ int var2 = InlineFunc() ? 512 : 1024;
+
+ for (i = 0; i < var1; i++)
+ ;
+
+ if (InlineFunc() && var2 != 512)
+ abort();
+
+ return 0;
+}
+
+int main(void)
+{
+ return FooBar();
+}
--- gcc/testsuite/gcc.c-torture/execute/20051002-1.c.jj 2005-09-19 08:33:21.659531528 +0200
+++ gcc/testsuite/gcc.c-torture/execute/20051002-1.c 2005-10-02 20:38:54.000000000 +0200
@@ -0,0 +1,18 @@
+/* PR optimization/12799 */
+extern void abort (void);
+
+unsigned int
+foo (unsigned long a)
+{
+ if (a >= 0xffffffffUL)
+ return 0xffffffff;
+ return a;
+}
+
+int
+main ()
+{
+ if (foo (0) != 0)
+ abort ();
+ return 0;
+}