Question: The following code performs matrix multiplication in c + + . It takes integer pointers int dot _ product _ i ( int * m
The following code performs matrix multiplication in c
It takes integer pointers
int dotproductiint m int m int r int c int l
int product ;
forint i; i l; i
int a mi r l; row of matrix
int b mc i l; col of matrix
product a b;
return product;
The following is the assembly for the above c code. The requirement is to remove redundant instructions to improve performance. Please provide new working assembly file with improved code. Please explain the improvement changes Thanks.
text
file dpint.cpp
globl ZdotproductiPiSiii # Begin function ZdotproductiPiSiii
palign x
type ZdotproductiPiSiii,@function
ZdotproductiPiSiii: # @ZdotproductiPiSiii
cfistartproc
# bb:
pushq rbp
cfidefcfaoffset
cfioffset rbp
movq rsprbp
cfidefcfaregister rbp
movq rdi, rbp
movq rsi, rbp
movl edx, rbp
movl ecx, rbp
movl rdrbp
movl $rbp
movl $rbp
LBB: # This Inner Loop Header: Depth
movl rbpeax
cmpl rbpeax
jge LBB
# bb: # in Loop: HeaderBB Depth
movq rbprax
movl rbpecx
movl rbpedx
imull rbpedx
addl edx, ecx
movslq ecx, rcx
movl rax,rcxeax
movl eax, rbp
movq rbprax
movl rbpecx
movl rbpedx
imull rbpedx
addl edx, ecx
movslq ecx, rcx
movl rax,rcxeax
movl eax, rbp
movl rbpeax
imull rbpeax
addl rbpeax
movl eax, rbp
# bb: # in Loop: HeaderBB Depth
movl rbpeax
addl $eax
movl eax, rbp
jmp LBB
LBB:
movl rbpeax
popq rbp
cfidefcfa rsp
retq
Lfuncend:
size ZdotproductiPiSiii, LfuncendZdotproductiPiSiii
cfiendproc
# End function
ident "clang version CentOS el
section note.GNUstack","",@progbits
addrsig
Step by Step Solution
There are 3 Steps involved in it
1 Expert Approved Answer
Step: 1 Unlock
Question Has Been Solved by an Expert!
Get step-by-step solutions from verified subject matter experts
Step: 2 Unlock
Step: 3 Unlock
