1 ; NOTE: Assertions have been autogenerated by utils/update_test_checks.py
2 ; RUN: opt < %s -instcombine -S | FileCheck %s
8 ; iff 1<<y is non-negative
10 define i8 @t0(i8 %x) {
12 ; CHECK-NEXT: [[DIV:%.*]] = ashr exact i8 [[X:%.*]], 5
13 ; CHECK-NEXT: ret i8 [[DIV]]
15 %div = sdiv exact i8 %x, 32
18 define i8 @n1(i8 %x) {
20 ; CHECK-NEXT: [[DIV:%.*]] = sdiv i8 [[X:%.*]], 32
21 ; CHECK-NEXT: ret i8 [[DIV]]
23 %div = sdiv i8 %x, 32 ; not exact
26 define i8 @n2(i8 %x) {
28 ; CHECK-NEXT: [[TMP1:%.*]] = icmp eq i8 [[X:%.*]], -128
29 ; CHECK-NEXT: [[DIV:%.*]] = zext i1 [[TMP1]] to i8
30 ; CHECK-NEXT: ret i8 [[DIV]]
32 %div = sdiv i8 %x, 128 ; negative divisor
36 define <2 x i8> @t3_vec_splat(<2 x i8> %x) {
37 ; CHECK-LABEL: @t3_vec_splat(
38 ; CHECK-NEXT: [[DIV:%.*]] = ashr exact <2 x i8> [[X:%.*]], <i8 5, i8 5>
39 ; CHECK-NEXT: ret <2 x i8> [[DIV]]
41 %div = sdiv exact <2 x i8> %x, <i8 32, i8 32>
45 define <2 x i8> @t4_vec(<2 x i8> %x) {
46 ; CHECK-LABEL: @t4_vec(
47 ; CHECK-NEXT: [[DIV:%.*]] = ashr exact <2 x i8> [[X:%.*]], <i8 5, i8 4>
48 ; CHECK-NEXT: ret <2 x i8> [[DIV]]
50 %div = sdiv exact <2 x i8> %x, <i8 32, i8 16>
54 define <2 x i8> @n5_vec_undef(<2 x i8> %x) {
55 ; CHECK-LABEL: @n5_vec_undef(
56 ; CHECK-NEXT: ret <2 x i8> poison
58 %div = sdiv exact <2 x i8> %x, <i8 32, i8 undef>
61 define <2 x i8> @n6_vec_negative(<2 x i8> %x) {
62 ; CHECK-LABEL: @n6_vec_negative(
63 ; CHECK-NEXT: [[DIV:%.*]] = sdiv exact <2 x i8> [[X:%.*]], <i8 32, i8 -128>
64 ; CHECK-NEXT: ret <2 x i8> [[DIV]]
66 %div = sdiv exact <2 x i8> %x, <i8 32, i8 128> ; non-non-negative divisor