This is the mail archive of the
gcc-patches@gcc.gnu.org
mailing list for the GCC project.
Re: -fif-conversion
- From: Jan Hubicka <jh at suse dot cz>
- To: Paolo Carlini <pcarlini at unitus dot it>, gcc-patches at gcc dot gnu dot org,rth at cygnus dot com
- Cc: Jan Hubicka <jh at suse dot cz>
- Date: Wed, 24 Apr 2002 16:42:16 +0200
- Subject: Re: -fif-conversion
- References: <20020424143234.GK25526@atrey.karlin.mff.cuni.cz> <3CC6C42C.1040203@unitus.it>
> Jan Hubicka wrote:
>
> >As if conversion has sometimes negative effect at least for Athlon, I guess
> >we should have way to disable it. I am attaching patch to create new flag.
> >It can be also used as temporary workaround for the ifcvt bug.
> >
> >Bootstrapped regtested i386/mainline
> >Honza
> >
> >Tue Apr 23 11:48:53 CEST 2002 Jan HUbicka <jh@suse.cz>
> > * i386.c (ix86_expand_clrstr): Fix pasto.
> >
Sure, sorry for that
Wed Apr 24 16:29:27 CEST 2002 Jan Hubicka <jh@suse.cz>
* toplev.c (flag_if_conversion, flag_if_conversion2): New static
variables.
(rest_of_compilation): Support new flags.
(parse_options_and_default_flags): Enable at -O1.
* invoke.texi (if-conversion, if-conversion2): Document.
Index: toplev.c
===================================================================
RCS file: /cvs/gcc/egcs/gcc/toplev.c,v
retrieving revision 1.613
diff -c -3 -p -r1.613 toplev.c
*** toplev.c 19 Apr 2002 16:21:54 -0000 1.613
--- toplev.c 24 Apr 2002 14:25:31 -0000
*************** static int flag_loop_optimize;
*** 597,602 ****
--- 597,610 ----
static int flag_crossjumping;
+ /* Nonzero means perform if conversion. */
+
+ static int flag_if_conversion;
+
+ /* Nonzero means perform if conversion after reload. */
+
+ static int flag_if_conversion2;
+
/* Nonzero means to use global dataflow analysis to eliminate
useless null pointer tests. */
*************** static const lang_independent_options f_
*** 1013,1018 ****
--- 1021,1030 ----
N_("Perform the loop optimizations") },
{"crossjumping", &flag_crossjumping, 1,
N_("Perform cross-jumping optimization") },
+ {"if-conversion", &flag_if_conversion, 1,
+ N_("Perform conversion of conditional jumps to branchless equivalents") },
+ {"if-conversion2", &flag_if_conversion2, 1,
+ N_("Perform conversion of conditional jumps to conditional execution") },
{"rerun-cse-after-loop", &flag_rerun_cse_after_loop, 1,
N_("Run CSE pass after loop optimizations") },
{"rerun-loop-opt", &flag_rerun_loop_opt, 1,
*************** rest_of_compilation (decl)
*** 2632,2638 ****
timevar_push (TV_JUMP);
! if (optimize > 0)
{
open_dump_file (DFI_null, decl);
find_basic_blocks (insns, max_reg_num (), rtl_dump_file);
--- 2644,2650 ----
timevar_push (TV_JUMP);
! if (flag_delete_null_pointer_checks || flag_if_conversion)
{
open_dump_file (DFI_null, decl);
find_basic_blocks (insns, max_reg_num (), rtl_dump_file);
*************** rest_of_compilation (decl)
*** 2645,2651 ****
delete_null_pointer_checks (insns);
timevar_push (TV_IFCVT);
! if_convert (0);
timevar_pop (TV_IFCVT);
cleanup_cfg (CLEANUP_EXPENSIVE | CLEANUP_PRE_LOOP);
close_dump_file (DFI_null, print_rtl_with_bb, insns);
--- 2657,2664 ----
delete_null_pointer_checks (insns);
timevar_push (TV_IFCVT);
! if (flag_if_conversion)
! if_convert (0);
timevar_pop (TV_IFCVT);
cleanup_cfg (CLEANUP_EXPENSIVE | CLEANUP_PRE_LOOP);
close_dump_file (DFI_null, print_rtl_with_bb, insns);
*************** rest_of_compilation (decl)
*** 2894,2900 ****
timevar_push (TV_IFCVT);
cleanup_cfg (CLEANUP_EXPENSIVE);
! if_convert (0);
timevar_pop(TV_IFCVT);
timevar_pop (TV_JUMP);
--- 2907,2914 ----
timevar_push (TV_IFCVT);
cleanup_cfg (CLEANUP_EXPENSIVE);
! if (flag_if_conversion)
! if_convert (0);
timevar_pop(TV_IFCVT);
timevar_pop (TV_JUMP);
*************** rest_of_compilation (decl)
*** 2993,2999 ****
/* Rerun if-conversion, as combine may have simplified things enough to
now meet sequence length restrictions. */
! if (optimize > 0)
{
timevar_push (TV_IFCVT);
open_dump_file (DFI_ce, decl);
--- 3007,3013 ----
/* Rerun if-conversion, as combine may have simplified things enough to
now meet sequence length restrictions. */
! if (flag_if_conversion)
{
timevar_push (TV_IFCVT);
open_dump_file (DFI_ce, decl);
*************** rest_of_compilation (decl)
*** 3234,3240 ****
timevar_pop (TV_RENAME_REGISTERS);
}
! if (optimize > 0)
{
timevar_push (TV_IFCVT2);
open_dump_file (DFI_ce2, decl);
--- 3248,3254 ----
timevar_pop (TV_RENAME_REGISTERS);
}
! if (flag_if_conversion2)
{
timevar_push (TV_IFCVT2);
open_dump_file (DFI_ce2, decl);
*************** parse_options_and_default_flags (argc, a
*** 4590,4595 ****
--- 4604,4611 ----
flag_cprop_registers = 1;
flag_loop_optimize = 1;
flag_crossjumping = 1;
+ flag_if_conversion = 1;
+ flag_if_conversion2 = 1;
}
if (optimize >= 2)
Index: doc/invoke.texi
===================================================================
RCS file: /cvs/gcc/egcs/gcc/doc/invoke.texi,v
retrieving revision 1.138
diff -c -3 -p -r1.138 invoke.texi
*** doc/invoke.texi 20 Apr 2002 20:44:10 -0000 1.138
--- doc/invoke.texi 24 Apr 2002 14:25:39 -0000
*************** in the following sections.
*** 267,272 ****
--- 267,273 ----
-fexpensive-optimizations -ffast-math -ffloat-store @gol
-fforce-addr -fforce-mem -ffunction-sections @gol
-fgcse -fgcse-lm -fgcse-sm -floop-optimize -fcrossjumping @gol
+ -fif-conversion -fif-conversion2 @gol
-finline-functions -finline-limit=@var{n} -fkeep-inline-functions @gol
-fkeep-static-consts -fmerge-constants -fmerge-all-constants @gol
-fmove-all-movables -fno-default-inline -fno-defer-pop @gol
*************** well.
*** 3518,3523 ****
--- 3519,3536 ----
@opindex crossjumping
Perform cross-jumping transformation. This transformation unifies equivalent code and save code size. The
resulting code may or may not perform better than without cross-jumping.
+
+ @item -fif-conversion
+ @opindex if-conversion
+ Attempt to transform conditional jumps into branch-less equivalents. This
+ include use of conditional moves, min, max, set flags and abs instructions, and
+ some tricks doable by standard arithmetics. The use of conditional execution
+ on chips where it is available is controlled by @code{if-conversion2}.
+
+ @item -fif-conversion2
+ @opindex if-conversion2
+ Use conditional execution (where available) to transform conditional jumps into
+ branch-less equivalents.
@item -fdelete-null-pointer-checks
@opindex fdelete-null-pointer-checks