[Bug tree-optimization/29789] New: Missed optimization in libquantum
rguenth at gcc dot gnu dot org
gcc-bugzilla@gcc.gnu.org
Thu Nov 9 21:54:00 GMT 2006
In SPEC 2k6 libquantum we can find the following (simplified) hot loop
void
quantum_toffoli(int control1, int control2, int target, unsigned long *state,
int size)
{
int i;
for(i=0; i<size; i++)
{
if (state[i] & ((unsigned long) 1 << control1))
if (state[i] & ((unsigned long) 1 << control2))
state[i] ^= ((unsigned long) 1 << target);
}
}
where we miss that
- The masks of the form ((unsigned long) 1 << X) are loop invariant
- We can combine the two ifs to
if (state[i] & C == C)
with C = ((unsigned long) 1 << control1) | ((unsigned long) 1 << control2)
The first missed-optimization is also caused by fold at
/* If this is an EQ or NE comparison with zero and ARG0 is
(1 << foo) & bar, convert it to (bar >> foo) & 1. Both require
two operations, but the latter can be done in one less insn
on machines that have only two-operand insns or on which a
constant cannot be the first operand. */
which causes the bit-tests to be written with a not loop-invariant shift.
--
Summary: Missed optimization in libquantum
Product: gcc
Version: 4.3.0
Status: UNCONFIRMED
Keywords: missed-optimization
Severity: normal
Priority: P3
Component: tree-optimization
AssignedTo: unassigned at gcc dot gnu dot org
ReportedBy: rguenth at gcc dot gnu dot org
OtherBugsDependingO 15357,26163
nThis:
http://gcc.gnu.org/bugzilla/show_bug.cgi?id=29789
More information about the Gcc-bugs
mailing list