Fix PR 17368: disable vector mul distribution for square of add/sub for ARM
authorWeiming Zhao <weimingz@codeaurora.org>
Wed, 25 Sep 2013 23:12:06 +0000 (23:12 +0000)
committerWeiming Zhao <weimingz@codeaurora.org>
Wed, 25 Sep 2013 23:12:06 +0000 (23:12 +0000)
commit541681c8485c18b564970c80180a798b2c1663e8
treecaf8c901cb8c2f1025ae709169dc8d0f44384f26
parent498ffb8a568992d613e654ddec69b04d350aec20
Fix PR 17368: disable vector mul distribution for square of add/sub for ARM

Generally, it is desirable to distribute (a + b) * c to a*c + b*c for
ARM with VMLx forwarding, where a, b and c are vectors.
However, for (a + b)*(a + b), distribution will result in one extra
instruction.
With distribution:
  x = a + b (add)
  y = a * x (mul)
  z = y + b * y (mla)

Without distribution:
  x = a + b (add)
  z = x * x (mul)

This patch checks if a mul is a square of add/sub. If yes, skip
distribution.

git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@191410 91177308-0d34-0410-b5e6-96231b3b80d8
lib/Target/ARM/ARMISelLowering.cpp
test/CodeGen/ARM/vmul.ll