Skip to content

Commit 7092a7b

Browse files
author
hanwen.chang
committed
vpmovdb test
1 parent 5505ed5 commit 7092a7b

File tree

3 files changed

+24
-6
lines changed

3 files changed

+24
-6
lines changed

11.cpp

+1-1
Original file line numberDiff line numberDiff line change
@@ -30,7 +30,7 @@ int main(){
3030
long*a;
3131
a=(long *)malloc(1*sizeof(long));
3232
printf("===========asm==========\n");
33-
mm(3,5,a);
33+
mm(257,5,a);
3434
printf("===========result %ld==========\n",*a);
3535

3636
return 0;

22.s

+22-4
Original file line numberDiff line numberDiff line change
@@ -1,13 +1,13 @@
1-
.text
21
.globl add_sum
32
.type add_sum, @function
3+
.text
4+
45
add_sum:
56
.LFB0:
67
.cfi_startproc #program start
78
#endbr64 #TERMINATE BRANCH 64bit
89
pushq %rbp #stack pointer
910

10-
1111
#+----------------+
1212
#|stack pointer rbp|
1313
#+----------------+
@@ -32,7 +32,6 @@ add_sum:
3232
#| reserved space | <--- %rsp == CFA - 16 ,call site
3333
#+----------------+
3434

35-
3635
movq %rsp, %rbp
3736
#rbp is the base pointer, which points to the base of the current stack frame, and rsp is the stack pointer, which points to the top of the current stack frame.
3837
.cfi_def_cfa_register 6 #cfa register is rbp
@@ -45,10 +44,25 @@ add_sum:
4544

4645
movq %rax,%rcx
4746

47+
48+
49+
50+
51+
52+
movq %rdx,%xmm0
53+
vpbroadcastd %xmm0, %zmm0
54+
#vcvtps2dq %ymm1, %ymm6
55+
#movq %rax,%zmm0
56+
vpmovdb %zmm0,%xmm0#xmm0:128bits,lower 64 bits
57+
#movhlps %xmm0,%xmm0 #move hight to lower
58+
59+
#vpmovdb %zmm0,%xmm0
60+
61+
4862
#movq %rax, -8(%rbp) #*(rbp-8) = rax
4963
movq -40(%rbp), %rax #rax = arg2
5064
#movq -8(%rbp), %rdx #rdx = *(rbp-8)
51-
movq %rcx, (%rax) #*rax=rdx
65+
movq %xmm0, (%rax) #*rax=rdx
5266
## movq %rax, -40(%rbp)
5367
nop
5468
popq %rbp
@@ -76,3 +90,7 @@ add_sum:
7690
#3:
7791
# .align 8
7892
#4:
93+
94+
95+
96+

asm.sh

+1-1
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,4 @@
11
#!/bin/bash
22

3-
gcc -shared -o 11.so 22.s
3+
gcc -shared -o 11.so 22.s
44
icx 11.cpp -lstdc++ -o test -std=c++17

0 commit comments

Comments
 (0)