// X / 1 -> X
// X % 1 -> 0
- // If this is a boolean op (single-bit type), we can't have division-by-zero
- // or remainder-by-zero, so assume the divisor is 1.
- if (match(Op1, m_One()) || Ty->isIntegerTy(1))
+ // If this is a boolean op (single-bit element type), we can't have
+ // division-by-zero or remainder-by-zero, so assume the divisor is 1.
+ if (match(Op1, m_One()) || Ty->getScalarType()->isIntegerTy(1))
return IsDiv ? Op0 : Constant::getNullValue(Ty);
return nullptr;
ret <2 x i8> %div
}
-; FIXME: Division-by-zero is undef. UB in any vector lane means the whole op is undef.
+; Division-by-zero is undef. UB in any vector lane means the whole op is undef.
; Thus, we can simplify this: if any element of 'y' is 0, we can do anything.
; Therefore, assume that all elements of 'y' must be 1.
define <2 x i1> @sdiv_bool_vec(<2 x i1> %x, <2 x i1> %y) {
; CHECK-LABEL: @sdiv_bool_vec(
-; CHECK-NEXT: [[DIV:%.*]] = sdiv <2 x i1> %x, %y
-; CHECK-NEXT: ret <2 x i1> [[DIV]]
+; CHECK-NEXT: ret <2 x i1> %x
;
%div = sdiv <2 x i1> %x, %y
ret <2 x i1> %div
define <2 x i1> @udiv_bool_vec(<2 x i1> %x, <2 x i1> %y) {
; CHECK-LABEL: @udiv_bool_vec(
-; CHECK-NEXT: [[DIV:%.*]] = udiv <2 x i1> %x, %y
-; CHECK-NEXT: ret <2 x i1> [[DIV]]
+; CHECK-NEXT: ret <2 x i1> %x
;
%div = udiv <2 x i1> %x, %y
ret <2 x i1> %div
ret <2 x i8> %rem
}
-; FIXME: Division-by-zero is undef. UB in any vector lane means the whole op is undef.
+; Division-by-zero is undef. UB in any vector lane means the whole op is undef.
; Thus, we can simplify this: if any element of 'y' is 0, we can do anything.
; Therefore, assume that all elements of 'y' must be 1.
define <2 x i1> @srem_bool_vec(<2 x i1> %x, <2 x i1> %y) {
; CHECK-LABEL: @srem_bool_vec(
-; CHECK-NEXT: [[REM:%.*]] = srem <2 x i1> %x, %y
-; CHECK-NEXT: ret <2 x i1> [[REM]]
+; CHECK-NEXT: ret <2 x i1> zeroinitializer
;
%rem = srem <2 x i1> %x, %y
ret <2 x i1> %rem
define <2 x i1> @urem_bool_vec(<2 x i1> %x, <2 x i1> %y) {
; CHECK-LABEL: @urem_bool_vec(
-; CHECK-NEXT: [[REM:%.*]] = urem <2 x i1> %x, %y
-; CHECK-NEXT: ret <2 x i1> [[REM]]
+; CHECK-NEXT: ret <2 x i1> zeroinitializer
;
%rem = urem <2 x i1> %x, %y
ret <2 x i1> %rem