In the code below, the test is always true and could be found as such by using
distributivity on binary operators to factor out constant values. This is not
currently done, by looking at the assembly code produced.
<code>
extern int f(unsigned);
int f(unsigned u)
{
if( (u|4) & 6 ) /* could be tested as (u&6) || (4&6), always true */
return 5;
else
return 10;
}
</code>
--
Summary: missing optimization opportunity with binary operators
Product: gcc
Version: 4.0.1
Status: UNCONFIRMED
Severity: enhancement
Priority: P4
Component: tree-optimization
AssignedTo: unassigned at gcc dot gnu dot org
ReportedBy: dvilleneuve at kronos dot com
GCC target triplet: i386-redhat-linux
http://gcc.gnu.org/bugzilla/show_bug.cgi?id=24427