diff --git a/ppc-simd.h b/ppc-simd.h index a9c0c608..6fc52848 100644 --- a/ppc-simd.h +++ b/ppc-simd.h @@ -169,27 +169,19 @@ template inline T VectorShiftLeft(const T& vec) { const T zero = {0}; + if (C >= 16) + { + // Out of range + return zero; + } + else + { #if CRYPTOPP_BIG_ENDIAN - if (C >= 16) - { - // Out of range - return zero; - } - else - { - return (T)vec_sld((uint8x16_p)vec, (uint8x16_p)zero, C); - } + return (T)vec_sld((uint8x16_p)vec, (uint8x16_p)zero, C); #else - if (C >= 16) - { - // Out of range - return zero; - } - else - { - return (T)vec_sld((uint8x16_p)zero, (uint8x16_p)vec, 16-C); - } + return (T)vec_sld((uint8x16_p)zero, (uint8x16_p)vec, 16-C); #endif + } } // Full specializations for 0 over uint8x16_p to uint64x2_p @@ -238,27 +230,19 @@ template inline T VectorShiftRight(const T& vec) { const T zero = {0}; + if (C >= 16) + { + // Out of range + return zero; + } + else + { #if CRYPTOPP_BIG_ENDIAN - if (C >= 16) - { - // Out of range - return zero; - } - else - { - return (T)vec_sld((uint8x16_p)zero, (uint8x16_p)vec, 16-C); - } + return (T)vec_sld((uint8x16_p)zero, (uint8x16_p)vec, 16-C); #else - if (C >= 16) - { - // Out of range - return zero; - } - else - { - return (T)vec_sld((uint8x16_p)vec, (uint8x16_p)zero, C); - } + return (T)vec_sld((uint8x16_p)vec, (uint8x16_p)zero, C); #endif + } } // Full specializations for 0 over uint8x16_p to uint64x2_p diff --git a/validat1.cpp b/validat1.cpp index 93cb9986..4a602425 100644 --- a/validat1.cpp +++ b/validat1.cpp @@ -1141,11 +1141,10 @@ bool TestAltivecOps() uint8x16_p val = {0xff,0xff,0xff,0xff, 0xff,0xff,0xff,0xff, 0xff,0xff,0xff,0xff, 0xff,0xff,0xff,0xff}; - uint8x16_p t; - pass2 = (VectorEqual(val, t=VectorShiftLeft<0>(val))) && pass2; + pass2 = (VectorEqual(val, VectorShiftLeft<0>(val))) && pass2; CRYPTOPP_ASSERT(pass2); - pass2 = (VectorEqual(val, t=VectorShiftRight<0>(val))) && pass2; + pass2 = (VectorEqual(val, VectorShiftRight<0>(val))) && pass2; CRYPTOPP_ASSERT(pass2); uint8x16_p lsh1 = {0xff,0xff,0xff,0xff, 0xff,0xff,0xff,0xff, @@ -1153,9 +1152,9 @@ bool TestAltivecOps() uint8x16_p rsh1 = {0x00,0xff,0xff,0xff, 0xff,0xff,0xff,0xff, 0xff,0xff,0xff,0xff, 0xff,0xff,0xff,0xff}; - pass2 = (VectorEqual(lsh1, t=VectorShiftLeft<1>(val))) && pass2; + pass2 = (VectorEqual(lsh1, VectorShiftLeft<1>(val))) && pass2; CRYPTOPP_ASSERT(pass2); - pass2 = (VectorEqual(rsh1, t=VectorShiftRight<1>(val))) && pass2; + pass2 = (VectorEqual(rsh1, VectorShiftRight<1>(val))) && pass2; CRYPTOPP_ASSERT(pass2); uint8x16_p lsh15 = {0xff,0x00,0x00,0x00, 0x00,0x00,0x00,0x00, @@ -1163,9 +1162,9 @@ bool TestAltivecOps() uint8x16_p rsh15 = {0x00,0x00,0x00,0x00, 0x00,0x00,0x00,0x00, 0x00,0x00,0x00,0x00, 0x00,0x00,0x00,0xff}; - pass2 = (VectorEqual(lsh15, t=VectorShiftLeft<15>(val))) && pass2; + pass2 = (VectorEqual(lsh15, VectorShiftLeft<15>(val))) && pass2; CRYPTOPP_ASSERT(pass2); - pass2 = (VectorEqual(rsh15, t=VectorShiftRight<15>(val))) && pass2; + pass2 = (VectorEqual(rsh15, VectorShiftRight<15>(val))) && pass2; CRYPTOPP_ASSERT(pass2); uint8x16_p lsh16 = {0x00,0x00,0x00,0x00, 0x00,0x00,0x00,0x00, @@ -1173,9 +1172,9 @@ bool TestAltivecOps() uint8x16_p rsh16 = {0x00,0x00,0x00,0x00, 0x00,0x00,0x00,0x00, 0x00,0x00,0x00,0x00, 0x00,0x00,0x00,0x00}; - pass2 = (VectorEqual(lsh16, t=VectorShiftLeft<16>(val))) && pass2; + pass2 = (VectorEqual(lsh16, VectorShiftLeft<16>(val))) && pass2; CRYPTOPP_ASSERT(pass2); - pass2 = (VectorEqual(rsh16, t=VectorShiftRight<16>(val))) && pass2; + pass2 = (VectorEqual(rsh16, VectorShiftRight<16>(val))) && pass2; CRYPTOPP_ASSERT(pass2); if (!pass2)