1 ; NOTE: Assertions have been autogenerated by utils/update_llc_test_checks.py
2 ; RUN: llc < %s -mtriple=x86_64-unknown-unknown | FileCheck %s
4 ; Div/rem by zero is undef.
6 define i32 @srem0(i32 %x) {
14 define i32 @urem0(i32 %x) {
22 define i32 @sdiv0(i32 %x) {
30 define i32 @udiv0(i32 %x) {
38 ; Div/rem by zero vectors is undef.
40 define <4 x i32> @srem_vec0(<4 x i32> %x) {
41 ; CHECK-LABEL: srem_vec0:
44 %rem = srem <4 x i32> %x, zeroinitializer
48 define <4 x i32> @urem_vec0(<4 x i32> %x) {
49 ; CHECK-LABEL: urem_vec0:
52 %rem = urem <4 x i32> %x, zeroinitializer
56 define <4 x i32> @sdiv_vec0(<4 x i32> %x) {
57 ; CHECK-LABEL: sdiv_vec0:
60 %div = sdiv <4 x i32> %x, zeroinitializer
64 define <4 x i32> @udiv_vec0(<4 x i32> %x) {
65 ; CHECK-LABEL: udiv_vec0:
68 %div = udiv <4 x i32> %x, zeroinitializer
72 ; Make sure we handle undef before we try to fold constants from the select with the 0.
73 ; These used to assert because we can't fold div/rem-by-0 into APInt.
75 define i32 @sel_urem0(i1 %cond) {
76 ; CHECK-LABEL: sel_urem0:
79 %sel = select i1 %cond, i32 23, i32 234
80 %rem = urem i32 %sel, 0
84 define i32 @sel_srem0(i1 %cond) {
85 ; CHECK-LABEL: sel_srem0:
88 %sel = select i1 %cond, i32 23, i32 234
89 %rem = srem i32 %sel, 0
93 define i32 @sel_udiv0(i1 %cond) {
94 ; CHECK-LABEL: sel_udiv0:
97 %sel = select i1 %cond, i32 23, i32 234
98 %div = udiv i32 %sel, 0
102 define i32 @sel_sdiv0(i1 %cond) {
103 ; CHECK-LABEL: sel_sdiv0:
106 %sel = select i1 %cond, i32 23, i32 234
107 %div = sdiv i32 %sel, 0
111 ; Make sure we handle undef before we try to fold constants from the select with the vector 0.
112 ; These used to assert because we can't fold div/rem-by-0 into APInt.
114 define <4 x i32> @sel_urem0_vec(i1 %cond) {
115 ; CHECK-LABEL: sel_urem0_vec:
118 %sel = select i1 %cond, <4 x i32> <i32 -1, i32 0, i32 1, i32 2>, <4 x i32> <i32 11, i32 12, i32 13, i32 14>
119 %rem = urem <4 x i32> %sel, zeroinitializer
123 define <4 x i32> @sel_srem0_vec(i1 %cond) {
124 ; CHECK-LABEL: sel_srem0_vec:
127 %sel = select i1 %cond, <4 x i32> <i32 -1, i32 0, i32 1, i32 2>, <4 x i32> <i32 11, i32 12, i32 13, i32 14>
128 %rem = srem <4 x i32> %sel, zeroinitializer
132 define <4 x i32> @sel_udiv0_vec(i1 %cond) {
133 ; CHECK-LABEL: sel_udiv0_vec:
136 %sel = select i1 %cond, <4 x i32> <i32 -1, i32 0, i32 1, i32 2>, <4 x i32> <i32 11, i32 12, i32 13, i32 14>
137 %div = udiv <4 x i32> %sel, zeroinitializer
141 define <4 x i32> @sel_sdiv0_vec(i1 %cond) {
142 ; CHECK-LABEL: sel_sdiv0_vec:
145 %sel = select i1 %cond, <4 x i32> <i32 -1, i32 0, i32 1, i32 2>, <4 x i32> <i32 11, i32 12, i32 13, i32 14>
146 %div = sdiv <4 x i32> %sel, zeroinitializer
150 ; If any element of a constant divisor vector is zero, the whole op is undef.
152 define <4 x i32> @sdiv0elt_vec(<4 x i32> %x) {
153 ; CHECK-LABEL: sdiv0elt_vec:
156 %zero = and <4 x i32> %x, <i32 0, i32 0, i32 0, i32 0>
157 %some_ones = or <4 x i32> %zero, <i32 0, i32 -1, i32 0, i32 3>
158 %div = sdiv <4 x i32> <i32 -11, i32 -12, i32 -13, i32 -14>, %some_ones
162 define <4 x i32> @udiv0elt_vec(<4 x i32> %x) {
163 ; CHECK-LABEL: udiv0elt_vec:
166 %div = udiv <4 x i32> <i32 11, i32 12, i32 13, i32 14>, <i32 0, i32 3, i32 4, i32 0>
170 define <4 x i32> @urem0elt_vec(<4 x i32> %x) {
171 ; CHECK-LABEL: urem0elt_vec:
174 %zero = and <4 x i32> %x, <i32 0, i32 0, i32 0, i32 0>
175 %some_ones = or <4 x i32> %zero, <i32 0, i32 0, i32 0, i32 3>
176 %rem = urem <4 x i32> <i32 11, i32 12, i32 13, i32 14>, %some_ones
180 define <4 x i32> @srem0elt_vec(<4 x i32> %x) {
181 ; CHECK-LABEL: srem0elt_vec:
184 %rem = srem <4 x i32> <i32 -11, i32 -12, i32 -13, i32 -14>, <i32 -3, i32 -3, i32 0, i32 2>