diff --git a/llvm/lib/Target/AArch64/AArch64MachineLegalizer.cpp b/llvm/lib/Target/AArch64/AArch64MachineLegalizer.cpp index 4f921e8d8efd..46261bca67c6 100644 --- a/llvm/lib/Target/AArch64/AArch64MachineLegalizer.cpp +++ b/llvm/lib/Target/AArch64/AArch64MachineLegalizer.cpp @@ -181,14 +181,21 @@ AArch64MachineLegalizer::AArch64MachineLegalizer() { setAction({G_BITCAST, 1, Ty}, Legal); } + // For the sake of copying bits around, the type does not really + // matter as long as it fits a register. for (int EltSize = 8; EltSize <= 64; EltSize *= 2) { setAction({G_BITCAST, 0, LLT::vector(128/EltSize, EltSize)}, Legal); setAction({G_BITCAST, 1, LLT::vector(128/EltSize, EltSize)}, Legal); - if (EltSize == 64) + if (EltSize >= 64) continue; setAction({G_BITCAST, 0, LLT::vector(64/EltSize, EltSize)}, Legal); setAction({G_BITCAST, 1, LLT::vector(64/EltSize, EltSize)}, Legal); + if (EltSize >= 32) + continue; + + setAction({G_BITCAST, 0, LLT::vector(32/EltSize, EltSize)}, Legal); + setAction({G_BITCAST, 1, LLT::vector(32/EltSize, EltSize)}, Legal); } computeTables(); diff --git a/llvm/test/CodeGen/AArch64/GlobalISel/legalize-simple.mir b/llvm/test/CodeGen/AArch64/GlobalISel/legalize-simple.mir index 1817a9101511..97a31d365772 100644 --- a/llvm/test/CodeGen/AArch64/GlobalISel/legalize-simple.mir +++ b/llvm/test/CodeGen/AArch64/GlobalISel/legalize-simple.mir @@ -48,6 +48,7 @@ registers: - { id: 31, class: _ } - { id: 32, class: _ } - { id: 33, class: _ } + - { id: 34, class: _ } body: | bb.0.entry: liveins: %x0, %x1, %x2, %x3 @@ -127,4 +128,6 @@ body: | %30(<2 x s32>) = G_BITCAST %9 %31(s64) = G_BITCAST %30 %32(s32) = G_BITCAST %15 + %33(<4 x s8>) = G_BITCAST %15 + %34(<2 x s16>) = G_BITCAST %15 ...