https://gcc.gnu.org/bugzilla/show_bug.cgi?id=85323
Bug ID: 85323 Summary: SSE/AVX/AVX512 shift by 0 not optimized away Product: gcc Version: 8.0.1 Status: UNCONFIRMED Severity: normal Priority: P3 Component: target Assignee: unassigned at gcc dot gnu.org Reporter: kretz at kde dot org Target Milestone: --- In the following test case, all three functions should compile to just `ret`: #include <x86intrin.h> __m128i f(__m128i x) { x = _mm_sll_epi64(x, __m128i()); x = _mm_sll_epi32(x, __m128i()); x = _mm_sll_epi16(x, __m128i()); x = _mm_srl_epi64(x, __m128i()); x = _mm_srl_epi32(x, __m128i()); x = _mm_srl_epi16(x, __m128i()); x = _mm_sra_epi64(x, __m128i()); x = _mm_sra_epi32(x, __m128i()); x = _mm_sra_epi16(x, __m128i()); x = _mm_slli_epi64(x, 0); x = _mm_slli_epi32(x, 0); x = _mm_slli_epi16(x, 0); x = _mm_srli_epi64(x, 0); x = _mm_srli_epi32(x, 0); x = _mm_srli_epi16(x, 0); x = _mm_srai_epi64(x, 0); x = _mm_srai_epi32(x, 0); x = _mm_srai_epi16(x, 0); return x; } __m256i f(__m256i x) { x = _mm256_sll_epi64(x, __m128i()); x = _mm256_sll_epi32(x, __m128i()); x = _mm256_sll_epi16(x, __m128i()); x = _mm256_srl_epi64(x, __m128i()); x = _mm256_srl_epi32(x, __m128i()); x = _mm256_srl_epi16(x, __m128i()); x = _mm256_sra_epi64(x, __m128i()); x = _mm256_sra_epi32(x, __m128i()); x = _mm256_sra_epi16(x, __m128i()); x = _mm256_slli_epi64(x, 0); x = _mm256_slli_epi32(x, 0); x = _mm256_slli_epi16(x, 0); x = _mm256_srli_epi64(x, 0); x = _mm256_srli_epi32(x, 0); x = _mm256_srli_epi16(x, 0); x = _mm256_srai_epi64(x, 0); x = _mm256_srai_epi32(x, 0); x = _mm256_srai_epi16(x, 0); return x; } __m512i f(__m512i x) { x = _mm512_sll_epi64(x, __m128i()); x = _mm512_sll_epi32(x, __m128i()); x = _mm512_sll_epi16(x, __m128i()); x = _mm512_srl_epi64(x, __m128i()); x = _mm512_srl_epi32(x, __m128i()); x = _mm512_srl_epi16(x, __m128i()); x = _mm512_sra_epi64(x, __m128i()); x = _mm512_sra_epi32(x, __m128i()); x = _mm512_sra_epi16(x, __m128i()); x = _mm512_slli_epi64(x, 0); x = _mm512_slli_epi32(x, 0); x = _mm512_slli_epi16(x, 0); x = _mm512_srli_epi64(x, 0); x = _mm512_srli_epi32(x, 0); x = _mm512_srli_epi16(x, 0); x = _mm512_srai_epi64(x, 0); x = _mm512_srai_epi32(x, 0); x = _mm512_srai_epi16(x, 0); return x; }