https://gcc.gnu.org/bugzilla/show_bug.cgi?id=102679

            Bug ID: 102679
           Summary: Failure to optimize out 64-bit multiplication to
                    32-bit multiplication when possible in circumstances
                    involving modifying a 64-bit variable that gets
                    converted to 32-bit
           Product: gcc
           Version: 12.0
            Status: UNCONFIRMED
          Severity: normal
          Priority: P3
         Component: tree-optimization
          Assignee: unassigned at gcc dot gnu.org
          Reporter: gabravier at gmail dot com
  Target Milestone: ---

#include <stdint.h>

int32_t mac(int32_t *b, int64_t sqr)
{
    sqr += (int64_t)*b * *b;
    return sqr;
}

This can be optimized to remove the `(int64_t)` cast. This optimization is done
by LLVM, but not by GCC.

Reply via email to