• 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
4define i64 @t0(i64 %x) {
5; CHECK-LABEL: @t0(
6; CHECK-NEXT:    [[T0_NEG:%.*]] = ashr i64 [[X:%.*]], 63
7; CHECK-NEXT:    ret i64 [[T0_NEG]]
8;
9  %t0 = lshr i64 %x, 63
10  %r = sub i64 0, %t0
11  ret i64 %r
12}
13define i64 @t0_exact(i64 %x) {
14; CHECK-LABEL: @t0_exact(
15; CHECK-NEXT:    [[T0_NEG:%.*]] = ashr exact i64 [[X:%.*]], 63
16; CHECK-NEXT:    ret i64 [[T0_NEG]]
17;
18  %t0 = lshr exact i64 %x, 63
19  %r = sub i64 0, %t0
20  ret i64 %r
21}
22define i64 @t2(i64 %x) {
23; CHECK-LABEL: @t2(
24; CHECK-NEXT:    [[T0_NEG:%.*]] = lshr i64 [[X:%.*]], 63
25; CHECK-NEXT:    ret i64 [[T0_NEG]]
26;
27  %t0 = ashr i64 %x, 63
28  %r = sub i64 0, %t0
29  ret i64 %r
30}
31define i64 @t3_exact(i64 %x) {
32; CHECK-LABEL: @t3_exact(
33; CHECK-NEXT:    [[T0_NEG:%.*]] = lshr exact i64 [[X:%.*]], 63
34; CHECK-NEXT:    ret i64 [[T0_NEG]]
35;
36  %t0 = ashr exact i64 %x, 63
37  %r = sub i64 0, %t0
38  ret i64 %r
39}
40
41define <2 x i64> @t4(<2 x i64> %x) {
42; CHECK-LABEL: @t4(
43; CHECK-NEXT:    [[T0_NEG:%.*]] = ashr <2 x i64> [[X:%.*]], <i64 63, i64 63>
44; CHECK-NEXT:    ret <2 x i64> [[T0_NEG]]
45;
46  %t0 = lshr <2 x i64> %x, <i64 63, i64 63>
47  %r = sub <2 x i64> zeroinitializer, %t0
48  ret <2 x i64> %r
49}
50
51define <2 x i64> @t5(<2 x i64> %x) {
52; CHECK-LABEL: @t5(
53; CHECK-NEXT:    [[T0:%.*]] = lshr <2 x i64> [[X:%.*]], <i64 63, i64 undef>
54; CHECK-NEXT:    [[R:%.*]] = sub <2 x i64> <i64 0, i64 undef>, [[T0]]
55; CHECK-NEXT:    ret <2 x i64> [[R]]
56;
57  %t0 = lshr <2 x i64> %x, <i64 63, i64 undef>
58  %r = sub <2 x i64> <i64 0, i64 undef>, %t0
59  ret <2 x i64> %r
60}
61
62declare void @use64(i64)
63declare void @use32(i64)
64
65define i64 @t6(i64 %x) {
66; CHECK-LABEL: @t6(
67; CHECK-NEXT:    [[T0_NEG:%.*]] = ashr i64 [[X:%.*]], 63
68; CHECK-NEXT:    [[T0:%.*]] = lshr i64 [[X]], 63
69; CHECK-NEXT:    call void @use64(i64 [[T0]])
70; CHECK-NEXT:    ret i64 [[T0_NEG]]
71;
72  %t0 = lshr i64 %x, 63
73  call void @use64(i64 %t0)
74  %r = sub i64 0, %t0
75  ret i64 %r
76}
77
78define i64 @n7(i64 %x) {
79; CHECK-LABEL: @n7(
80; CHECK-NEXT:    [[T0_NEG:%.*]] = ashr i64 [[X:%.*]], 63
81; CHECK-NEXT:    [[T0:%.*]] = lshr i64 [[X]], 63
82; CHECK-NEXT:    call void @use32(i64 [[T0]])
83; CHECK-NEXT:    ret i64 [[T0_NEG]]
84;
85  %t0 = lshr i64 %x, 63
86  call void @use32(i64 %t0)
87  %r = sub i64 0, %t0
88  ret i64 %r
89}
90
91define i64 @n8(i64 %x) {
92; CHECK-LABEL: @n8(
93; CHECK-NEXT:    [[T0_NEG:%.*]] = ashr i64 [[X:%.*]], 63
94; CHECK-NEXT:    [[T0:%.*]] = lshr i64 [[X]], 63
95; CHECK-NEXT:    call void @use64(i64 [[T0]])
96; CHECK-NEXT:    call void @use32(i64 [[T0]])
97; CHECK-NEXT:    ret i64 [[T0_NEG]]
98;
99  %t0 = lshr i64 %x, 63
100  call void @use64(i64 %t0)
101  call void @use32(i64 %t0)
102  %r = sub i64 0, %t0
103  ret i64 %r
104}
105
106define i64 @n9(i64 %x) {
107; CHECK-LABEL: @n9(
108; CHECK-NEXT:    [[T0:%.*]] = lshr i64 [[X:%.*]], 62
109; CHECK-NEXT:    [[R:%.*]] = sub nsw i64 0, [[T0]]
110; CHECK-NEXT:    ret i64 [[R]]
111;
112  %t0 = lshr i64 %x, 62
113  %r = sub i64 0, %t0
114  ret i64 %r
115}
116
117define i64 @n10(i64 %x) {
118; CHECK-LABEL: @n10(
119; CHECK-NEXT:    [[T0_NEG:%.*]] = ashr i64 [[X:%.*]], 63
120; CHECK-NEXT:    [[R:%.*]] = add nsw i64 [[T0_NEG]], 1
121; CHECK-NEXT:    ret i64 [[R]]
122;
123  %t0 = lshr i64 %x, 63
124  %r = sub i64 1, %t0
125  ret i64 %r
126}
127