This patch fixes bug 23800 ( https://llvm.org/bugs/show_bug.cgi?id=23800#c2 ). There existed a case where the index operand from extractelement was directly used to create a shufflevector mask. Since the index can be of any integral type but the mask must only contain 32 bit integers a 64 bit index operand led to an assertion error later on.
Yes, that's a fine way to do it.
It would be a little cleaner to pull out a function to do the entire -> i32 conversion, so that you can just have Args.push_back(getAsInt32(CGF, C));
Hi Simon, is this test case enough? Clang will fail with an exit code other than 0 if wrong code is generated. The test passes with my changes. Or should I add a check to the test that something like <2 x i64> <i64 0, i64 undef> is not generated?
Yes please add a FileCheck stage to the test to give some insight as to what you expect the result to be.
A comment would be useful as well (reference the PR# and a brief explanation of the bug).