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

            Bug ID: 94715
           Summary: Squared multiplies are incorrectly signextended
           Product: gcc
           Version: 10.0
            Status: UNCONFIRMED
          Severity: normal
          Priority: P3
         Component: middle-end
          Assignee: unassigned at gcc dot gnu.org
          Reporter: wilco at gcc dot gnu.org
  Target Milestone: ---

The following example generates incorrect code with -O2:

unsigned long long f (int x)
{
  unsigned int t = x * x;
  return t;
}

On AArch64 I get:

  mul w0, w0, w0
  sxtw x0, w0
  ret

It's correct if you do x * y or x * 100.

Reply via email to