Folding nodes in instruction selection - please review

Demikhovsky, Elena elena.demikhovsky at intel.com
Mon Jul 8 04:47:41 PDT 2013


Hi,

I analyzed the folding DAG nodes algorithm in LLVM, compared to code generated by Intel compiler and got into conclusion that the LLVM code is not always optimal.
This is an example:

  %b1 = fadd <8 x float> %a1, <float AAA, float AAA, float AAA, float AAA, float AAA, float AAA, float AAA, float AAA >
  %b2 = fadd <8 x float> %a2, <float AAA, float AAA, float AAA, float AAA, float AAA, float AAA, float AAA, float AAA >
  %c = fmul <8 x float> %b1, %b2

The result (1) bellow is not better than (2), because loading constant is not a problem, but spilling %ymm2 that may be required  in (1) is not cheap.

(1)
        vmovaps .LCPI1_0(%rip), %ymm2
        vaddps  %ymm2, %ymm1, %ymm1
        vaddps  %ymm2, %ymm0, %ymm0
        vmulps  %ymm1, %ymm0, %ymm0

(2)
        vaddps  .LCPI1_0(%rip), %ymm1, %ymm1
        vaddps  .LCPI1_0(%rip),  %ymm0, %ymm0
        vmulps  %ymm1, %ymm0, %ymm0

In the attached patch I did a minor thing that does not change the current algorithm, but allows to add some target-specific analysis.

Please review.

Thank you.

-        Elena



---------------------------------------------------------------------
Intel Israel (74) Limited

This e-mail and any attachments may contain confidential material for
the sole use of the intended recipient(s). Any review or distribution
by others is strictly prohibited. If you are not the intended
recipient, please contact the sender and delete all copies.
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://lists.llvm.org/pipermail/llvm-commits/attachments/20130708/d64cad18/attachment.html>
-------------- next part --------------
A non-text attachment was scrubbed...
Name: folding.diff
Type: application/octet-stream
Size: 3441 bytes
Desc: folding.diff
URL: <http://lists.llvm.org/pipermail/llvm-commits/attachments/20130708/d64cad18/attachment.obj>


More information about the llvm-commits mailing list