This is the mail archive of the
gcc-patches@gcc.gnu.org
mailing list for the GCC project.
i386 fp branches optimization
- To: patches at x86-64 dot org, rth at cygnus dot com, gcc-patches at gcc dot gnu dot org
- Subject: i386 fp branches optimization
- From: Jan Hubicka <jh at suse dot cz>
- Date: Fri, 12 Jan 2001 18:36:53 +0100
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;