flat assembler
Message board for the users of flat assembler.
  
       
      Index
      > Main > How to compare eight values in AVX register? | 
  
| Author | 
  | 
              
| 
                  
                   cod3b453 07 Jun 2014, 12:11 
                  Sorry I don't have a machine to test this on - vpandn might be wrong but hopefully this is enough to get the idea:     
                  Code: const_1p0 dd 1.0, 1.0, 1.0, 1.0, 1.0, 1.0, 1.0, 1.0 const_0p0 dd 0.0, 0.0, 0.0, 0.0, 0.0, 0.0, 0.0, 0.0 vcmpps ymm1,ymm0,qqword [const_1p0],0 ; ymm1 has 1.0 mask vpandn ymm0,ymm1,ymm0 ; zero 1.0 cells vpand ymm1,ymm1,qqword [const_0p0] ; create 0.0 cells vpor ymm0,ymm0,ymm1 ; merge to complete the replacement Last edited by cod3b453 on 08 Jun 2014, 14:34; edited 1 time in total  | 
              |||
                  
  | 
              
| 
                  
                   SeryZone 07 Jun 2014, 12:44 
                  cod3b453 wrote: Sorry I don't have a machine to test this on - vpandn might be wrong but hopefully this is enough to get the idea: operand size do not much... format MS COFF...  | 
              |||
                  
  | 
              
| 
                  
                   cod3b453 08 Jun 2014, 14:35 
                  I'd missed the "qqword" specifiers (previous snippet updated) 
                  
                 | 
              |||
                  
  | 
              
| 
                  
                   tthsqe 16 Jun 2014, 02:15 
                  Sery, this is the simplest way,
 
                  
                Code: macro ReplaceOneWithZero a,b,t { ; for each i ; if b[i] == 1.0 ; then a[i] = 0.0 ; else a[i] = b[i] ; end if ; end for ; if a and b are the same register, t must be a different register ; if a and b are different registers, t can be the same register as a vcmpeqps t,b,qqword[_ones] ; t[i] = 0x00000000 in the case b[i]<>1.0 . t[i] = 0xFFFFFFFF in the case b[i]=1.0 . vandnps a,t,b ; overwrite appropriate entries in a[i] with 0.0 (0x00000000) } align 32 _ones dd 1.0,1.0,1.0,1.0,1.0,1.0,1.0,1.0  | 
              |||
                  
  | 
              
< Last Thread | Next Thread >  | 
    
Forum Rules: 
  | 
    
Copyright © 1999-2025, Tomasz Grysztar. Also on GitHub, YouTube.
Website powered by rwasa.