This is the mail archive of the gcc-patches@gcc.gnu.org mailing list for the GCC project.


Index Nav: [Date Index] [Subject Index] [Author Index] [Thread Index]
Message Nav: [Date Prev] [Date Next] [Thread Prev] [Thread Next]

i386 fp branches optimization



Hi
This patch adds code to ix86_prepare_fp_compare_args to swap comparison
operands when doing so reduces comparison costs.  This makes all comparisons
except EQ/NE cheap on i386 (requiring only single branch or single test instruction
in arithmetics case).

This patch brings important speedups in code that heavily depends on fp compares.

Bootstrapped and regression tested on i386 with and without -march=athlon

Pá led 12 17:41:13 CET 2001  Jan Hubicka  <jh@suse.cz>

	* i386.c (ix86_prepare_fp_compare_args): Try to rearange the comparison
	to make it cheaper.

*** ../../../../orig/egcs/gcc/config/i386/i386.c	Thu Jan 11 11:18:04 2001
--- i386.c	Fri Jan 12 17:30:40 2001
*************** ix86_prepare_fp_compare_args (code, pop0
*** 4787,4792 ****
--- 4769,4786 ----
  	}
      }
  
+   /* Try to rearange the comparison to make it cheaper.  */
+   if (ix86_fp_comparison_cost (code)
+       > ix86_fp_comparison_cost (swap_condition (code))
+       && (GET_CODE (op0) == REG || !reload_completed))
+     {
+       rtx tmp;
+       tmp = op0, op0 = op1, op1 = tmp;
+       code = swap_condition (code);
+       if (GET_CODE (op0) != REG)
+ 	op0 = force_reg (op_mode, op0);
+     }
+ 
    *pop0 = op0;
    *pop1 = op1;
    return code;

Index Nav: [Date Index] [Subject Index] [Author Index] [Thread Index]
Message Nav: [Date Prev] [Date Next] [Thread Prev] [Thread Next]