shufflevector should rewrite undef per element
MODIFY
ir/instr.cpp
ir/instr.cpp
@@ -3333,16 +3333,11 @@ StateValue ShuffleVector::toSMT(State &s) const {
auto sz = vty->numElementsConst();
vector<StateValue> vals;
- const StateValue *vect1 = nullptr;
- const StateValue *vect2 = nullptr;
-
for (auto m : mask) {
if (m >= 2 * sz) {
vals.emplace_back(UndefValue(vty->getChild(0)).toSMT(s).value, true);
} else {
- auto &vect = m < sz ? vect1 : vect2;
- if (!vect)
- vect = &s[m < sz ? *v1 : *v2];
+ auto *vect = &s[m < sz ? *v1 : *v2];
vals.emplace_back(vty->extract(*vect, m % sz));
}
}

ADD
tests/alive-tv/shufflevec-undef.srctgt.ll
+define <2 x i32> @src(i32 %a) {
+ %ie = insertelement <2 x i32> poison, i32 %a, i32 0
+ %ret = shufflevector <2 x i32> %ie, <2 x i32> poison, <2 x i32> <i32 0, i32 0>
+ ret <2 x i32> %ret
+}
+
+define <2 x i32> @tgt(i32 %a) {
+ %ie = insertelement <2 x i32> poison, i32 %a, i32 0
+ %ret = insertelement <2 x i32> %ie, i32 %a, i32 1
+ ret <2 x i32> %ret
+}

shufflevector should rewrite undef per element (#640)