This is the mail archive of the
gcc-bugs@gcc.gnu.org
mailing list for the GCC project.
[Bug c/16632] New: A couple fold-const.c optimizations are non-functional
- From: "trt at acm dot org" <gcc-bugzilla at gcc dot gnu dot org>
- To: gcc-bugs at gcc dot gnu dot org
- Date: 19 Jul 2004 18:05:19 -0000
- Subject: [Bug c/16632] New: A couple fold-const.c optimizations are non-functional
- Reply-to: gcc-bugzilla at gcc dot gnu dot org
In fold-const.c there are a couple of bitmask/comparision optimizations:
/* If we have (A & C) == D where D & ~C != 0, convert this into 0.
and
/* If we have (A | C) == D where C & ~D != 0, convert this into 0.
Sample C code:
void subr (int i)
{
if ((i|3) == 1) return; /* never taken */
if ((i&4) == 2) return; /* never taken */
}
Unfortunately fold-const.c neglects to fold ~C (~D) and so
the detection of these cases is non-functional.
I'm not sure how to demonstrate this outside the debugger,
since later pieces of gcc seem to clean this up.
For example ~D is computed on approx line 8391 with
build1 (BIT_NOT_EXPR, TREE_TYPE (arg1), arg1)));
This should be fold(build1 ...), or fold_not_const(arg1, TREE_TYPE(arg1)).
Similarly for ~C on approx line 8373.
--
Summary: A couple fold-const.c optimizations are non-functional
Product: gcc
Version: 3.5.0
Status: UNCONFIRMED
Severity: minor
Priority: P2
Component: c
AssignedTo: unassigned at gcc dot gnu dot org
ReportedBy: trt at acm dot org
CC: gcc-bugs at gcc dot gnu dot org
http://gcc.gnu.org/bugzilla/show_bug.cgi?id=16632