<html>
    <head>
      <base href="https://bugs.llvm.org/">
    </head>
    <body><table border="1" cellspacing="0" cellpadding="8">
        <tr>
          <th>Bug ID</th>
          <td><a class="bz_bug_link 
          bz_status_NEW "
   title="NEW - [AVR] Bad optimization of multiplication when mul instruction is available"
   href="https://bugs.llvm.org/show_bug.cgi?id=48981">48981</a>
          </td>
        </tr>

        <tr>
          <th>Summary</th>
          <td>[AVR] Bad optimization of multiplication when mul instruction is available
          </td>
        </tr>

        <tr>
          <th>Product</th>
          <td>libraries
          </td>
        </tr>

        <tr>
          <th>Version</th>
          <td>trunk
          </td>
        </tr>

        <tr>
          <th>Hardware</th>
          <td>PC
          </td>
        </tr>

        <tr>
          <th>OS</th>
          <td>Linux
          </td>
        </tr>

        <tr>
          <th>Status</th>
          <td>NEW
          </td>
        </tr>

        <tr>
          <th>Severity</th>
          <td>enhancement
          </td>
        </tr>

        <tr>
          <th>Priority</th>
          <td>P
          </td>
        </tr>

        <tr>
          <th>Component</th>
          <td>Backend: AVR
          </td>
        </tr>

        <tr>
          <th>Assignee</th>
          <td>unassignedbugs@nondot.org
          </td>
        </tr>

        <tr>
          <th>Reporter</th>
          <td>gabravier@gmail.com
          </td>
        </tr>

        <tr>
          <th>CC</th>
          <td>llvm-bugs@lists.llvm.org
          </td>
        </tr></table>
      <p>
        <div>
        <pre>int square(int num)
{
    return num * num;
}

GCC -O3 generates this:

square(int):
  movw r18,r24
  mul r18,r18
  movw r24,r0
  mul r18,r19
  add r25,r0
  add r25,r0
  clr r1
  ret

LLVM generates this:

square(int):
  muls r25, r24
  mov r18, r0
  clr r1
  muls r24, r25
  mov r19, r0
  clr r1
  mul r24, r24
  mov r20, r1
  clr r1
  add r20, r19
  add r20, r18
  lsl r20
  rol r21
  lsl r20
  rol r21
  lsl r20
  rol r21
  lsl r20
  rol r21
  lsl r20
  rol r21
  lsl r20
  rol r21
  lsl r20
  rol r21
  lsl r20
  rol r21
  mov r24, r0
  clr r25
  or r24, r20
  or r25, r21
  ret</pre>
        </div>
      </p>


      <hr>
      <span>You are receiving this mail because:</span>

      <ul>
          <li>You are on the CC list for the bug.</li>
      </ul>
    </body>
</html>