// Scan the current block backward, looking for other uses of SI.
BasicBlock::iterator BBI = I.getIterator(), BBFront = I.getParent()->begin();
-
+ Type *CondTy = SelectCond->getType();
while (BBI != BBFront) {
--BBI;
// If we found a call to a function, we can't assume it will return, so
*I = SI->getOperand(NonNullOperand);
Worklist.Add(&*BBI);
} else if (*I == SelectCond) {
- *I = Builder.getInt1(NonNullOperand == 1);
+ *I = NonNullOperand == 1 ? ConstantInt::getTrue(CondTy)
+ : ConstantInt::getFalse(CondTy);
Worklist.Add(&*BBI);
}
}
ret i64 %sum
}
+; https://bugs.llvm.org/show_bug.cgi?id=34856
+; This would assert/crash because we didn't propagate the condition with the correct vector type.
+
+define <2 x i32> @PR34856(<2 x i32> %t0, <2 x i32> %t1) {
+; CHECK-LABEL: @PR34856(
+; CHECK-NEXT: [[DIV1:%.*]] = udiv <2 x i32> %t1, <i32 -7, i32 -7>
+; CHECK-NEXT: ret <2 x i32> [[DIV1]]
+;
+ %cmp = icmp eq <2 x i32> %t0, <i32 1, i32 1>
+ %zext = zext <2 x i1> %cmp to <2 x i32>
+ %neg = select <2 x i1> %cmp, <2 x i32> zeroinitializer, <2 x i32> <i32 -7, i32 -7>
+ %div1 = udiv <2 x i32> %t1, %neg
+ %use_cmp_again = add <2 x i32> %div1, %zext
+ ret <2 x i32> %use_cmp_again
+}
+