Hi Tim and other reviewers,
Recently we found an assertion failure caused by scalarizing node like "v1i32 trunc v1i64". As v1i64 is legal, it will fail to scalarize v1i32.
This patch adds two hooks (like the existing hook shouldSplitVectorType()) to change the scalarization behavior:
(1) avoid scalarize v1i32 by shouldScalarizeVectorType().
(2) If avoid scalarization, the default behavior is changed to be promoted from v1i32 to v1i64, which may introduce extra operations like extend, truncate... Hook preferWidenVectorType() can change it to be widen from v1i32 to v2i32.
v1i8 and v1i16 are similar to v1i32. This patch can also have benefit on reducing FMOV.
BTW, I also think it's better to widen v2i8, v4i8, v2i16 to v8i8, v8i8, v4i16 than the default behavior of promote. But such change will cause several regression test case failures. Some of the test cases result in better code, but some of the test cases result in worse code. If we can improve the worse case, we will also have benefit.
Code review. Please.
Thanks,
-Hao
Could you change this to "return TargetLoweringBase::getPreferredVectorAction(VT)"? It makes it clearer we're not overriding anything else.