• Home
  • Line#
  • Scopes#
  • Navigate#
  • Raw
  • Download
1; NOTE: Assertions have been autogenerated by utils/update_test_checks.py
2; RUN: opt < %s -instcombine -S | FileCheck %s
3
4; Fold
5;   x s/EXACT (-1 << y)
6; to
7;   -(x a>>EXACT y)
8
9define i8 @t0(i8 %x) {
10; CHECK-LABEL: @t0(
11; CHECK-NEXT:    [[DIV_NEG:%.*]] = ashr exact i8 [[X:%.*]], 5
12; CHECK-NEXT:    [[DIV:%.*]] = sub nsw i8 0, [[DIV_NEG]]
13; CHECK-NEXT:    ret i8 [[DIV]]
14;
15  %div = sdiv exact i8 %x, -32
16  ret i8 %div
17}
18define i8 @n1(i8 %x) {
19; CHECK-LABEL: @n1(
20; CHECK-NEXT:    [[DIV:%.*]] = sdiv i8 [[X:%.*]], -32
21; CHECK-NEXT:    ret i8 [[DIV]]
22;
23  %div = sdiv i8 %x, -32 ; not exact
24  ret i8 %div
25}
26
27define <2 x i8> @t2_vec_splat(<2 x i8> %x) {
28; CHECK-LABEL: @t2_vec_splat(
29; CHECK-NEXT:    [[DIV_NEG:%.*]] = ashr exact <2 x i8> [[X:%.*]], <i8 5, i8 5>
30; CHECK-NEXT:    [[DIV:%.*]] = sub nsw <2 x i8> zeroinitializer, [[DIV_NEG]]
31; CHECK-NEXT:    ret <2 x i8> [[DIV]]
32;
33  %div = sdiv exact <2 x i8> %x, <i8 -32, i8 -32>
34  ret <2 x i8> %div
35}
36
37define <2 x i8> @t3_vec(<2 x i8> %x) {
38; CHECK-LABEL: @t3_vec(
39; CHECK-NEXT:    [[DIV_NEG:%.*]] = ashr exact <2 x i8> [[X:%.*]], <i8 5, i8 4>
40; CHECK-NEXT:    [[DIV:%.*]] = sub <2 x i8> zeroinitializer, [[DIV_NEG]]
41; CHECK-NEXT:    ret <2 x i8> [[DIV]]
42;
43  %div = sdiv exact <2 x i8> %x, <i8 -32, i8 -16>
44  ret <2 x i8> %div
45}
46
47define <2 x i8> @n4_vec_mixed(<2 x i8> %x) {
48; CHECK-LABEL: @n4_vec_mixed(
49; CHECK-NEXT:    [[DIV:%.*]] = sdiv exact <2 x i8> [[X:%.*]], <i8 -32, i8 16>
50; CHECK-NEXT:    ret <2 x i8> [[DIV]]
51;
52  %div = sdiv exact <2 x i8> %x, <i8 -32, i8 16>
53  ret <2 x i8> %div
54}
55
56define <2 x i8> @n4_vec_undef(<2 x i8> %x) {
57; CHECK-LABEL: @n4_vec_undef(
58; CHECK-NEXT:    ret <2 x i8> undef
59;
60  %div = sdiv exact <2 x i8> %x, <i8 -32, i8 undef>
61  ret <2 x i8> %div
62}
63