Bug 30841 - [4.3 regression] Missed optimizations for sbi/cbi instructions
Summary: [4.3 regression] Missed optimizations for sbi/cbi instructions
Status: RESOLVED FIXED
Alias: None
Product: gcc
Classification: Unclassified
Component: rtl-optimization (show other bugs)
Version: 4.3.0
: P3 normal
Target Milestone: 4.3.0
Assignee: Paolo Bonzini
URL: http://gcc.gnu.org/ml/gcc-patches/200...
Keywords: missed-optimization, patch
Depends on: 30907
Blocks:
  Show dependency treegraph
 
Reported: 2007-02-18 13:03 UTC by aesok
Modified: 2007-03-20 15:29 UTC (History)
3 users (show)

See Also:
Host:
Target: avr
Build:
Known to work: 4.2.0
Known to fail: 4.3.0
Last reconfirmed: 2007-02-19 06:53:12


Attachments

Note You need to log in before you can comment on or make changes to this bug.
Description aesok 2007-02-18 13:03:47 UTC
demo.c:
#define PORTD (*(volatile unsigned char *)(50))

int
main (void)
{
  PORTD |= 1;
  
  return 0;
}

Revision r118474:
.LM2:
 ; (insn 14 12 18 main.c:6 (set (mem/v:QI (const_int 50 [0x32]) [0 S1 A8])
 ;         (ior:QI (mem/v:QI (const_int 50 [0x32]) [0 S1 A8])
 ;             (const_int 1 [0x1]))) 114 {*sbi} (nil)
 ;     (nil))
	sbi 50-0x20,0	 ;  14	*sbi	[length = 1]


Revision r118475:
.LM2:
 ; (insn 10 9 11 main.c:6 (set (reg/f:HI 30 r30 [44])
 ;         (const_int 50 [0x32])) 12 {*movhi} (nil)
 ;     (expr_list:REG_EQUIV (const_int 50 [0x32])
 ;         (nil)))
	ldi r30,lo8(50)	 ;  10	*movhi/4	[length = 2]
	ldi r31,hi8(50)
 ; (insn 11 10 12 main.c:6 (set (reg:QI 24 r24 [orig:42 D.1514 ] [42])
 ;         (mem/v:QI (reg/f:HI 30 r30 [44]) [0 S1 A8])) 9 {*movqi} (insn_list:REG_DEP_TRUE 10 (nil))
 ;     (nil))
	ld r24,Z	 ;  11	*movqi/4	[length = 1]
 ; (insn 12 11 14 main.c:6 (set (reg:QI 24 r24 [orig:42 D.1514 ] [42])
 ;         (ior:QI (reg:QI 24 r24 [orig:42 D.1514 ] [42])
 ;             (const_int 1 [0x1]))) 47 {iorqi3} (insn_list:REG_DEP_TRUE 11 (nil))
 ;     (nil))
	ori r24,lo8(1)	 ;  12	iorqi3/2	[length = 1]
 ; (insn 14 12 18 main.c:6 (set (mem/v:QI (reg/f:HI 30 r30 [44]) [0 S1 A8])
 ;         (reg:QI 24 r24 [orig:42 D.1514 ] [42])) 9 {*movqi} (insn_list:REG_DEP_TRUE 12 (nil))
 ;     (expr_list:REG_DEAD (reg:QI 24 r24 [orig:42 D.1514 ] [42])
 ;         (expr_list:REG_DEAD (reg/f:HI 30 r30 [44])
 ;             (nil))))
	st Z,r24	 ;  14	*movqi/3	[length = 1]

Revision 118475  
2006-11-03  Paolo Bonzini  <bonzini@gnu.org>
            Steven Bosscher  <stevenb.gcc@gmail.com>

        * fwprop.c: New file.
        * Makefile.in: Add fwprop.o.
        * tree-pass.h (pass_rtl_fwprop, pass_rtl_fwprop_with_addr): New.
        * passes.c (init_optimization_passes): Schedule forward propagation.
        * rtlanal.c (loc_mentioned_in_p): Support NULL value of the second
        parameter.
        * timevar.def (TV_FWPROP): New.
        * common.opt (-fforward-propagate): New.
        * opts.c (decode_options): Enable forward propagation at -O2.
        * gcse.c (one_cprop_pass): Do not run local cprop unless touching jumps.
        * cse.c (fold_rtx_subreg, fold_rtx_mem, fold_rtx_mem_1, find_best_addr,
        canon_for_address, table_size): Remove.
        (new_basic_block, insert, remove_from_table): Remove references to
        table_size.
        (fold_rtx): Process SUBREGs and MEMs with equiv_constant, make
        simplification loop more straightforward by not calling fold_rtx
        recursively.
        (equiv_constant): Move here a small part of fold_rtx_subreg,
        do not call fold_rtx.  Call avoid_constant_pool_reference
        to process MEMs.
        * recog.c (canonicalize_change_group): New.
        * recog.h (canonicalize_change_group): New.

        * doc/invoke.texi (Optimization Options): Document fwprop.
        * doc/passes.texi (RTL passes): Document fwprop.

Anatoly.
Comment 1 Paolo Bonzini 2007-02-22 08:27:23 UTC
It's actually a small oversight in fwprop, which is supposed to replace find_best_addr indeed.

The patch indicated in the URL is enough for dataflow-branch; on mainline you need also http://gcc.gnu.org/ml/gcc-patches/2007-02/msg01797.html because of a bug in df that is already fixed on the branch.
Comment 2 Paolo Bonzini 2007-02-22 16:46:52 UTC
Changing the patch address since part 1 was approved.  And adding bug 30907 since committing part 2 would cause that bug to surface on mainline.
Comment 3 Paolo Bonzini 2007-02-23 07:45:48 UTC
Subject: Bug 30841

Author: bonzini
Date: Fri Feb 23 07:45:34 2007
New Revision: 122253

URL: http://gcc.gnu.org/viewcvs?root=gcc&view=rev&rev=122253
Log:
2007-02-22  Paolo Bonzini  <bonzini@gnu.org>

	PR rtl-optimization/30841
        * fwprop.c (propagate_rtx_1): Accept a VOIDmode replacement address.

Modified:
    trunk/gcc/ChangeLog
    trunk/gcc/fwprop.c

Comment 4 Paolo Bonzini 2007-03-20 08:31:36 UTC
Subject: Bug 30841

Author: bonzini
Date: Tue Mar 20 08:31:13 2007
New Revision: 123084

URL: http://gcc.gnu.org/viewcvs?root=gcc&view=rev&rev=123084
Log:
2007-03-19  Paolo Bonzini  <bonzini@gnu.org>

	PR rtl-optimization/30907
	* fwprop.c (forward_propagate_into): Never propagate inside a loop.
	(fwprop_init): Always call loop_optimizer_initialize.
	(fwprop_done): Always call loop_optimizer_finalize.
	(fwprop): We always have loop info now.
	(gate_fwprop_addr): Remove.
	(pass_fwprop_addr): Use gate_fwprop as gate.

	PR rtl-optimization/30841
	* df-problems.c (df_ru_local_compute, df_rd_local_compute,
	df_chain_alloc): Call df_reorganize_refs unconditionally.
	* df-scan.c (df_rescan_blocks, df_reorganize_refs): Change
	refs_organized to refs_organized_size.
	(df_ref_create_structure): Use refs_organized_size instead of
	bitmap_size if refs had been organized, and keep refs_organized_size
	up-to-date.
	* df.h (struct df_ref_info): Change refs_organized to
	refs_organized_size.
	(DF_DEFS_SIZE, DF_USES_SIZE): Use refs_organized_size instead of
	bitmap_size.


Modified:
    trunk/gcc/ChangeLog
    trunk/gcc/df-problems.c
    trunk/gcc/df-scan.c
    trunk/gcc/df.h
    trunk/gcc/fwprop.c

Comment 5 Paolo Bonzini 2007-03-20 08:31:47 UTC
fixed.
Comment 6 Andrew Pinski 2007-03-20 15:29:31 UTC
Fixed.