Bug 31657 - Should combine bit tests in if stmts
Summary: Should combine bit tests in if stmts
Status: RESOLVED FIXED
Alias: None
Product: gcc
Classification: Unclassified
Component: tree-optimization (show other bugs)
Version: 4.3.0
: P3 enhancement
Target Milestone: 4.3.0
Assignee: Richard Biener
URL: http://gcc.gnu.org/ml/gcc-patches/200...
Keywords: missed-optimization, patch
Depends on:
Blocks: spec 15353 15357
  Show dependency treegraph
 
Reported: 2007-04-22 12:34 UTC by Richard Biener
Modified: 2007-06-12 12:08 UTC (History)
3 users (show)

See Also:
Host:
Target:
Build:
Known to work:
Known to fail:
Last reconfirmed:


Attachments

Note You need to log in before you can comment on or make changes to this bug.
Description Richard Biener 2007-04-22 12:34:04 UTC
1)

  if (X & (1 << a))
    if (X & (1 << b))

  should be combined to

  tmp = (1 << a) | (1 << b)
  if (X & tmp == tmp)

2)

  if (X & a)
    goto doit;
  else
    if (X & b)
      goto doit

 doit:

  (i.e. the CFG form of (X & a || X & b))

 should be combined to
  if (X & (a | b))
    goto doit


The first form happens in SPEC2k6 libquantum hottest loop.  The patch I
have for this should also be made to address PR15353.
Comment 1 Richard Biener 2007-06-12 12:06:39 UTC
Subject: Bug 31657

Author: rguenth
Date: Tue Jun 12 12:06:19 2007
New Revision: 125644

URL: http://gcc.gnu.org/viewcvs?root=gcc&view=rev&rev=125644
Log:
2007-06-12  Richard Guenther  <rguenther@suse.de>

	PR tree-optimization/15353
	PR tree-optimization/31657
	* passes.c (init_optimization_passes): Add pass_tree_ifcombine.
	* timevar.def: Add TV_TREE_IFCOMBINE.
	* tree-pass.h (pass_tree_ifcombine): Declare.
	* tree-ssa-ifcombine.c: New file.
	* tree-ssa-phiopt.c (blocks_in_phiopt_order): Export.
	* tree-flow.h (blocks_in_phiopt_order): Declare.
	* Makefile.in (OBJS-common): Add tree-ssa-ifcombine.o.
	(tree-ssa-ifcombine.o): New dependencies.

	* gcc.c-torture/execute/20070424-1.c: New testcase.
	* gcc.dg/tree-ssa/ssa-ifcombine-1.c: Likewise.
	* gcc.dg/tree-ssa/ssa-ifcombine-2.c: Likewise.
	* gcc.dg/tree-ssa/ssa-ifcombine-3.c: Likewise.
	* gcc.dg/tree-ssa/ssa-ifcombine-4.c: Likewise.
	* gcc.dg/tree-ssa/ssa-ifcombine-5.c: Likewise.

Added:
    trunk/gcc/testsuite/gcc.c-torture/execute/20070424-1.c
    trunk/gcc/testsuite/gcc.dg/tree-ssa/ssa-ifcombine-1.c
    trunk/gcc/testsuite/gcc.dg/tree-ssa/ssa-ifcombine-2.c
    trunk/gcc/testsuite/gcc.dg/tree-ssa/ssa-ifcombine-3.c
    trunk/gcc/testsuite/gcc.dg/tree-ssa/ssa-ifcombine-4.c
    trunk/gcc/testsuite/gcc.dg/tree-ssa/ssa-ifcombine-5.c
    trunk/gcc/tree-ssa-ifcombine.c
Modified:
    trunk/gcc/ChangeLog
    trunk/gcc/Makefile.in
    trunk/gcc/passes.c
    trunk/gcc/testsuite/ChangeLog
    trunk/gcc/timevar.def
    trunk/gcc/tree-flow.h
    trunk/gcc/tree-pass.h
    trunk/gcc/tree-ssa-phiopt.c

Comment 2 Richard Biener 2007-06-12 12:08:56 UTC
Fixed.