Intel® ISA Extensions
Use hardware-based isolation and memory encryption to provide more code protection in your solutions.
Announcements
FPGA community forums and blogs on community.intel.com are migrating to the new Altera Community and are read-only. For urgent support needs during this transition, please visit the FPGA Design Resources page or contact an Altera Authorized Distributor.

256 bit subtraction

garfield-lewis
Beginner
632 Views

Hi,

I've got the following datatype:

struct X { __m128i hi; __m128i lo; }

I need to use only SSE 4.2 and below instructions to do a subtraction of 2 of these taking into account possible borrow issues at bits 63-64, 127-128 and 191-192. Does anyone have a quick set of instructions that could be used to accomplish this? Again using SSE 4.2 and earlier instructions.

Thx...

0 Kudos
1 Reply
styc
Beginner
632 Views
garfield-lewis wrote:

Hi,

I've got the following datatype:

struct X { __m128i hi; __m128i lo; }

I need to use only SSE 4.2 and below instructions to do a subtraction of 2 of these taking into account possible borrow issues at bits 63-64, 127-128 and 191-192. Does anyone have a quick set of instructions that could be used to accomplish this? Again using SSE 4.2 and earlier instructions.

Thx...

The best solution is to break components of X into scalars:

[cpp] asm ("sub %4, %0;" "sbb %5, %1;" "sbb %6, %2;" "sbb %7, %3;" : "=r" (*(uint64*) &z.lo), "=r" (*((uint64*) &z.lo + 1)), "=r" (*(uint64*) &z.hi), "=r" (*((uint64*) &z.hi + 1)) : "g" (*(uint64*) &y.lo), "g" (*((uint64*) &y.lo + 1)), "g" (*(uint64*) &y.hi), "g" (*((uint64*) &y.hi + 1)), "0" (*(uint64*) &x.lo), "1" (*((uint64*) &x.lo + 1)), "2" (*(uint64*) &x.hi), "3" (*((uint64*) &x.hi + 1)) );[/cpp]
0 Kudos
Reply