5.13

    A.

    1. +----+----+----+----+-----+-----+
    2. |%rbp|%rcx|%rax|%rbx|%xmm1|%xmm0|
    3. +----+----+----+----+-----+-----++----+
    4. +----|----|----|----------|--->| |
    5. | +----|----|----------|--->|load| vmovad 0(%rbp,%rcx,8),%xmm1
    6. | | | | +-----|----| |
    7. | | | | | | +----+
    8. | +----|----|----------|--->| |
    9. | | | | | | |load|---+
    10. | | +----|----------|--->| | |
    11. | | | | | | +----+ | vmulsd (%rax,%rcx,8),%xmm1,%xmm0
    12. | | | | | | | |<--+
    13. | | | | +-----|--->|mul |
    14. | | | | +-----|----| |
    15. | | | | | | +----+
    16. | | | | +-----|--->| |
    17. | | | | | +--->|add | vaddsd %xmm1,%xmm0,%xmm0
    18. | | | | | +----| |
    19. | | | | | | +----+
    20. | +----|----|----------|--->| |
    21. | | | | | |add | addq $1, %rcx
    22. | +----|----|----------|----| |
    23. | | | | | | +----+
    24. | +----|----|----------|--->| |
    25. | | | | | | |cmp |---+ cmpq %rbx, %rcx
    26. | | | +----|-----|--->| | |
    27. | | | | | | +----+ |
    28. | | | | | | | | |
    29. | | | | | | |jne |<--+ jne .L15
    30. | | | | | | | |
    31. | | | | | | +----+
    32. v v v v v v
    33. +----+----+----+----+-----+-----+
    34. |%rbp|%rcx|%rax|%rbx|%xmm1|%xmm0|
    35. +----+----+----+----+-----+-----+
    36. +----+ +-----+
    37. |%rcx| |%xmm0|
    38. +----+ +-----+
    39. | |
    40. | +----+ | <--------- key path
    41. +---->|load|------+ |
    42. | +----+ | |
    43. | v v
    44. | +----+ +-+--+ +-+--+
    45. +---->|load|--->|mul |--->|add |
    46. | +----+ +----+ +----+
    47. | |
    48. | |
    49. v |
    50. +----+ |
    51. |add | |
    52. +----+ |
    53. | |
    54. v v
    55. +-+--+ +-----+
    56. |%rcx| |%xmm0|
    57. +----+ +-----+

    B.

    5-12

    float add cell, CPE is 3.0

    C.

    5-12

    long add cell, 1.0

    D.

    only float add on key path

    1. !INCLUDE "./code/5.13.c"