[SelectionDAG] When scalarizing trunc, don't assert for legal operands.
authorAhmed Bougacha <ahmed.bougacha@gmail.com>
Thu, 30 Oct 2014 23:46:50 +0000 (23:46 +0000)
committerAhmed Bougacha <ahmed.bougacha@gmail.com>
Thu, 30 Oct 2014 23:46:50 +0000 (23:46 +0000)
commit9f336c4ec5adb124c8d7b75be8bc5d2f02db119c
treec7f9184ce965abc299920caface9fe3842bbc1f5
parent6cda0d7269188f9b21c6dfe19a6f32f8432918da
[SelectionDAG] When scalarizing trunc, don't assert for legal operands.

r212242 introduced a legalizer hook, originally to let AArch64 widen
v1i{32,16,8} rather than scalarize, because the legalizer expected, when
scalarizing the result of a conversion operation, to already have
scalarized the operands.  On AArch64, v1i64 is legal, so that commit
ensured operations such as v1i32 = trunc v1i64 wouldn't assert.

It did that by choosing to widen v1 types whenever possible.  However,
v1i1 types, for which there's no legal widened type, would still trigger
the assert.

This commit fixes that, by only scalarizing a trunc's result when the
operand has already been scalarized, and introducing an extract_elt
otherwise.
This is similar to r205625.

Fixes PR20777.

llvm-svn: 220937
llvm/lib/CodeGen/SelectionDAG/LegalizeVectorTypes.cpp
llvm/test/CodeGen/AArch64/trunc-v1i64.ll