Bug 23670 - Fold does not fold (a|b)&b to b likewise for (a&b) | b to b
Summary: Fold does not fold (a|b)&b to b likewise for (a&b) | b to b
Status: RESOLVED FIXED
Alias: None
Product: gcc
Classification: Unclassified
Component: middle-end (show other bugs)
Version: 4.1.0
: P2 enhancement
Target Milestone: 4.2.0
Assignee: Not yet assigned to anyone
URL:
Keywords: missed-optimization, TREE
Depends on:
Blocks: 19986
  Show dependency treegraph
 
Reported: 2005-09-01 02:15 UTC by Andrew Pinski
Modified: 2006-02-14 23:26 UTC (History)
1 user (show)

See Also:
Host:
Target:
Build:
Known to work:
Known to fail:
Last reconfirmed: 2005-12-24 19:55:41


Attachments

Note You need to log in before you can comment on or make changes to this bug.
Description Andrew Pinski 2005-09-01 02:15:19 UTC
Example:
int f(int a, int b)
{
  return (a|9)&9;
}

int f1(int a, int b)
{
  return (a|9)&9;
}


This is folded at the rtl level but not at the tree level.
Comment 1 Andrew Pinski 2005-09-01 02:15:42 UTC
Oh, this was from LLVM again.
Comment 2 Andrew Pinski 2005-09-17 02:12:28 UTC
Confirmed.
Comment 3 Roger Sayle 2006-02-14 21:08:55 UTC
Subject: Bug 23670

Author: sayle
Date: Tue Feb 14 21:08:52 2006
New Revision: 110997

URL: http://gcc.gnu.org/viewcvs?root=gcc&view=rev&rev=110997
Log:

	PR middle-end/23670
	* fold-const.c (fold_binary) <BIT_IOR_EXPR>: Optimize (X&Y)|Y into
	(X,Y) and the corresponding symmetry related transformations.
	(fold_binary) <BIT_AND_EXPR>: Likewise, optimize (X|Y)&Y into
	(X,Y) and its symmetry related transformations.

	* gcc.dg/tree-ssa/andor-2.c: New test case.


Added:
    trunk/gcc/testsuite/gcc.dg/tree-ssa/andor-2.c
Modified:
    trunk/gcc/ChangeLog
    trunk/gcc/fold-const.c
    trunk/gcc/testsuite/ChangeLog

Comment 4 Andrew Pinski 2006-02-14 23:26:39 UTC
Fixed, thanks Roger for fixing this one.