https://gcc.gnu.org/bugzilla/show_bug.cgi?id=66852

--- Comment #7 from Markus Trippelsdorf <trippels at gcc dot gnu.org> ---
(In reply to Richard Biener from comment #6)
> So I suppose the IsAligned template is wrong.

Yes.

 390 template <class T>                                                         
 391 inline unsigned int GetAlignmentOf(T *dummy=NULL)       // VC60 workaround 
 392 {                                                                          
 393 #ifdef CRYPTOPP_ALLOW_UNALIGNED_DATA_ACCESS                                
 394         if (sizeof(T) < 16)                                                
 395                 return 1;                                                  
 396 #endif                                                                     
 397                                                                            
 398 #if (_MSC_VER >= 1300)                                                     
 399         return __alignof(T);                                               
 400 #elif defined(__GNUC__)                                                    
 401         return __alignof__(T);                                             
 402 #elif CRYPTOPP_BOOL_SLOW_WORD64                                            
 403         return UnsignedMin(4U, sizeof(T));                                 
 404 #else                                                                      
 405         return sizeof(T);                                                  
 406 #endif                                                                     
 407 }                                                                          
 408                                                                            
 409 inline bool IsAlignedOn(const void *p, unsigned int alignment)             
 410 {                                                                          
 411         return alignment==1 || (IsPowerOf2(alignment) ?
ModPowerOf2((size_t)p, alignment) == 0 : (size_t)p % alignment == 0);           
 412 }                                                                          
 413                                                                            
 414 template <class T>                                                         
 415 inline bool IsAligned(const void *p, T *dummy=NULL)     // VC60 workaround 
 416 {                                                                          
 417         return IsAlignedOn(p, GetAlignmentOf<T>());                        
 418 } 

and 
345 #if CRYPTOPP_BOOL_X64 || CRYPTOPP_BOOL_X86 || defined(__powerpc__)          
346         #define CRYPTOPP_ALLOW_UNALIGNED_DATA_ACCESS                        
347 #endif 

The only architecture where the assumption is valid is POWER8, where
unaligned vector loads are preferable to ones with forced-alignment.

Reply via email to