What's the best assembly sequences for vm64z indexing?

Programming, for all ages and all languages.
Post Reply
blackoil
Member
Member
Posts: 146
Joined: Mon Feb 12, 2007 4:45 am

What's the best assembly sequences for vm64z indexing?

Post by blackoil »

e.g.

e0 = 0;
e1 = 8;
e2 = 16;
...
nullplan
Member
Member
Posts: 1769
Joined: Wed Aug 30, 2017 8:24 am

Re: What's the best assembly sequences for vm64z indexing?

Post by nullplan »

You are going to have to write a little bit more than that. What is it you wish to do? If I have to google it, I can't answer your question.
Carpe diem!
blackoil
Member
Member
Posts: 146
Joined: Mon Feb 12, 2007 4:45 am

Re: What's the best assembly sequences for vm64z indexing?

Post by blackoil »

to form [ gpr_base + zmm0 + displacement ], vm64z.

It's a bit slow to use instruction mov zmm0, [ vm64z_index_from_memory ]
User avatar
bzt
Member
Member
Posts: 1584
Joined: Thu Oct 13, 2016 4:55 pm
Contact:

Re: What's the best assembly sequences for vm64z indexing?

Post by bzt »

blackoil wrote:to form [ gpr_base + zmm0 + displacement ], vm64z.

It's a bit slow to use instruction mov zmm0, [ vm64z_index_from_memory ]
I lost you there. If zmm0 is supposed to be a floating point / SIMD register, then you can't use it for indexing and you can't use "mov". You have to use special instructions like "movaps" with those registers. Otherwise you can speed up the read by using only aligned values and prefetch.

Btw, with indexed addressing you can encode 3 bit shifts and a base in a single mov instruction (like [rbx + rax*8]), and reading memory with it into a gpr is not slow at all. Read about addressing modes in Intel spec.

Cheers,
bzt
blackoil
Member
Member
Posts: 146
Joined: Mon Feb 12, 2007 4:45 am

Re: What's the best assembly sequences for vm64z indexing?

Post by blackoil »

I used pseudo one.

vmovdqa64 zmm0, [index64] ; vindex instruction from armv8 can do this without memory read
vgatherqpd zmm1, [ rbx + zmm0 ] ; the zmm0 contains offsets for each element of zmm1.

index64:
dq 0
dq 16
dq 32
dq 48
dq 64
dq 80
dq 96
dq 112
Octocontrabass
Member
Member
Posts: 5516
Joined: Mon Mar 25, 2013 7:01 pm

Re: What's the best assembly sequences for vm64z indexing?

Post by Octocontrabass »

I don't think x86 has any way to do that without an extra memory access to load the indices.

Why is there an 8-byte gap between each of the values you want to load?
Post Reply