}
case Instruction::Mul:
if (*RHSV == 0 && BO->hasNoSignedWrap()) {
- // FIXME: Vectors are excluded by ConstantInt.
- if (ConstantInt *BOC = dyn_cast<ConstantInt>(BOp1)) {
- // The trivial case (mul X, 0) is handled by InstSimplify
+ const APInt *BOC;
+ if (match(BOp1, m_APInt(BOC)) && *BOC != 0) {
+ // The trivial case (mul X, 0) is handled by InstSimplify.
// General case : (mul X, C) != 0 iff X != 0
// (mul X, C) == 0 iff X == 0
- if (!BOC->isZero())
- return new ICmpInst(ICI.getPredicate(), BOp0,
- Constant::getNullValue(RHS->getType()));
+ return new ICmpInst(ICI.getPredicate(), BOp0,
+ Constant::getNullValue(RHS->getType()));
}
}
break;
; FIXME: Vectors should fold the same way.
define <2 x i1> @icmp_mul_neq0_vec(<2 x i32> %x) {
; CHECK-LABEL: @icmp_mul_neq0_vec(
-; CHECK-NEXT: [[MUL:%.*]] = mul nsw <2 x i32> %x, <i32 -12, i32 -12>
-; CHECK-NEXT: [[CMP:%.*]] = icmp ne <2 x i32> [[MUL]], zeroinitializer
+; CHECK-NEXT: [[CMP:%.*]] = icmp ne <2 x i32> %x, zeroinitializer
; CHECK-NEXT: ret <2 x i1> [[CMP]]
;
%mul = mul nsw <2 x i32> %x, <i32 -12, i32 -12>