https://gcc.gnu.org/bugzilla/show_bug.cgi?id=92233
Bug ID: 92233 Summary: missed optimisation for multiplication when it's known that at least one of the arguments is 0 Product: gcc Version: 9.2.1 Status: UNCONFIRMED Keywords: missed-optimization Severity: normal Priority: P3 Component: tree-optimization Assignee: unassigned at gcc dot gnu.org Reporter: SztfG at yandex dot ru Target Milestone: --- testcase: unsigned test_mult(unsigned a, unsigned b) { if ((a == 0) || (b == 0)) { return a*b; // here a*0 or 0*b or 0*0 - always 0 } return 0; } So this function should always return 0 no matter what, but GCC generate comparisons and imul instruction, even with -O3