diff options
Diffstat (limited to 'llvm/test/Transforms/InstSimplify/div.ll')
| -rw-r--r-- | llvm/test/Transforms/InstSimplify/div.ll | 42 |
1 files changed, 34 insertions, 8 deletions
diff --git a/llvm/test/Transforms/InstSimplify/div.ll b/llvm/test/Transforms/InstSimplify/div.ll index 1eb767e17bf..b8ee7bc901b 100644 --- a/llvm/test/Transforms/InstSimplify/div.ll +++ b/llvm/test/Transforms/InstSimplify/div.ll @@ -1,5 +1,31 @@ +; NOTE: Assertions have been autogenerated by utils/update_test_checks.py ; RUN: opt < %s -instsimplify -S | FileCheck %s +define i32 @zero_dividend(i32 %A) { +; CHECK-LABEL: @zero_dividend( +; CHECK-NEXT: ret i32 0 +; + %B = sdiv i32 0, %A + ret i32 %B +} + +define <2 x i32> @zero_dividend_vector(<2 x i32> %A) { +; CHECK-LABEL: @zero_dividend_vector( +; CHECK-NEXT: ret <2 x i32> zeroinitializer +; + %B = udiv <2 x i32> zeroinitializer, %A + ret <2 x i32> %B +} + +define <2 x i32> @zero_dividend_vector_undef_elt(<2 x i32> %A) { +; CHECK-LABEL: @zero_dividend_vector_undef_elt( +; CHECK-NEXT: [[B:%.*]] = sdiv <2 x i32> <i32 0, i32 undef>, [[A:%.*]] +; CHECK-NEXT: ret <2 x i32> [[B]] +; + %B = sdiv <2 x i32> <i32 0, i32 undef>, %A + ret <2 x i32> %B +} + ; Division-by-zero is undef. UB in any vector lane means the whole op is undef. define <2 x i8> @sdiv_zero_elt_vec_constfold(<2 x i8> %x) { @@ -56,7 +82,7 @@ define <2 x i8> @udiv_undef_elt_vec(<2 x i8> %x) { define <2 x i1> @sdiv_bool_vec(<2 x i1> %x, <2 x i1> %y) { ; CHECK-LABEL: @sdiv_bool_vec( -; CHECK-NEXT: ret <2 x i1> %x +; CHECK-NEXT: ret <2 x i1> [[X:%.*]] ; %div = sdiv <2 x i1> %x, %y ret <2 x i1> %div @@ -64,7 +90,7 @@ define <2 x i1> @sdiv_bool_vec(<2 x i1> %x, <2 x i1> %y) { define <2 x i1> @udiv_bool_vec(<2 x i1> %x, <2 x i1> %y) { ; CHECK-LABEL: @udiv_bool_vec( -; CHECK-NEXT: ret <2 x i1> %x +; CHECK-NEXT: ret <2 x i1> [[X:%.*]] ; %div = udiv <2 x i1> %x, %y ret <2 x i1> %div @@ -81,7 +107,7 @@ define i32 @udiv_dividend_known_smaller_than_constant_divisor(i32 %x) { define i32 @not_udiv_dividend_known_smaller_than_constant_divisor(i32 %x) { ; CHECK-LABEL: @not_udiv_dividend_known_smaller_than_constant_divisor( -; CHECK-NEXT: [[AND:%.*]] = and i32 %x, 251 +; CHECK-NEXT: [[AND:%.*]] = and i32 [[X:%.*]], 251 ; CHECK-NEXT: [[DIV:%.*]] = udiv i32 [[AND]], 251 ; CHECK-NEXT: ret i32 [[DIV]] ; @@ -101,7 +127,7 @@ define i32 @udiv_constant_dividend_known_smaller_than_divisor(i32 %x) { define i32 @not_udiv_constant_dividend_known_smaller_than_divisor(i32 %x) { ; CHECK-LABEL: @not_udiv_constant_dividend_known_smaller_than_divisor( -; CHECK-NEXT: [[OR:%.*]] = or i32 %x, 251 +; CHECK-NEXT: [[OR:%.*]] = or i32 [[X:%.*]], 251 ; CHECK-NEXT: [[DIV:%.*]] = udiv i32 251, [[OR]] ; CHECK-NEXT: ret i32 [[DIV]] ; @@ -114,8 +140,8 @@ define i32 @not_udiv_constant_dividend_known_smaller_than_divisor(i32 %x) { define i32 @udiv_dividend_known_smaller_than_divisor(i32 %x, i32 %y) { ; CHECK-LABEL: @udiv_dividend_known_smaller_than_divisor( -; CHECK-NEXT: [[AND:%.*]] = and i32 %x, 250 -; CHECK-NEXT: [[OR:%.*]] = or i32 %y, 251 +; CHECK-NEXT: [[AND:%.*]] = and i32 [[X:%.*]], 250 +; CHECK-NEXT: [[OR:%.*]] = or i32 [[Y:%.*]], 251 ; CHECK-NEXT: [[DIV:%.*]] = udiv i32 [[AND]], [[OR]] ; CHECK-NEXT: ret i32 [[DIV]] ; @@ -127,8 +153,8 @@ define i32 @udiv_dividend_known_smaller_than_divisor(i32 %x, i32 %y) { define i32 @not_udiv_dividend_known_smaller_than_divisor(i32 %x, i32 %y) { ; CHECK-LABEL: @not_udiv_dividend_known_smaller_than_divisor( -; CHECK-NEXT: [[AND:%.*]] = and i32 %x, 251 -; CHECK-NEXT: [[OR:%.*]] = or i32 %y, 251 +; CHECK-NEXT: [[AND:%.*]] = and i32 [[X:%.*]], 251 +; CHECK-NEXT: [[OR:%.*]] = or i32 [[Y:%.*]], 251 ; CHECK-NEXT: [[DIV:%.*]] = udiv i32 [[AND]], [[OR]] ; CHECK-NEXT: ret i32 [[DIV]] ; |

