https://gcc.gnu.org/bugzilla/show_bug.cgi?id=66520
Bug ID: 66520 Summary: bad code generated code for branches with single & Product: gcc Version: unknown Status: UNCONFIRMED Severity: normal Priority: P3 Component: c++ Assignee: unassigned at gcc dot gnu.org Reporter: fkastrati at gmail dot com Target Milestone: --- consider the following code snippet (c++): void ampamp(int x, int y) { if (x < 3 && y > 10 ) printf("%d%d", x, y); } void amp(int x, int y) { if ((x < 3) & (y > 10) ) printf("%d%d", x, y); } the assembly code generated by g++ (all versions I tested with optimization flag `-O3'), is not optimal (see the link on the bottom of this message). Basically, for both methods, the generated assembly code is identical. For the method "amp" (with single `&') there should be generated only one jump, as branch misprediction penalty is very high otherwise! As a side note: the code by intel's compiler (ICC) is however generating optimal code for such scenarios, at least for versions icc13, and icc15 that I've tested. See: http://goo.gl/oiTPX5