1 ; NOTE: Assertions have been autogenerated by utils/update_test_checks.py
2 ; RUN: opt < %s -passes=instcombine -S | FileCheck %s
4 define i64 @t0(i64 %x) {
6 ; CHECK-NEXT: [[T0_NEG:%.*]] = ashr i64 [[X:%.*]], 63
7 ; CHECK-NEXT: ret i64 [[T0_NEG]]
13 define 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]]
18 %t0 = lshr exact i64 %x, 63
22 define i64 @t2(i64 %x) {
24 ; CHECK-NEXT: [[T0_NEG:%.*]] = lshr i64 [[X:%.*]], 63
25 ; CHECK-NEXT: ret i64 [[T0_NEG]]
31 define 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]]
36 %t0 = ashr exact i64 %x, 63
41 define <2 x i64> @t4(<2 x i64> %x) {
43 ; CHECK-NEXT: [[T0_NEG:%.*]] = ashr <2 x i64> [[X:%.*]], <i64 63, i64 63>
44 ; CHECK-NEXT: ret <2 x i64> [[T0_NEG]]
46 %t0 = lshr <2 x i64> %x, <i64 63, i64 63>
47 %r = sub <2 x i64> zeroinitializer, %t0
51 define <2 x i64> @t5(<2 x i64> %x) {
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]]
57 %t0 = lshr <2 x i64> %x, <i64 63, i64 undef>
58 %r = sub <2 x i64> <i64 0, i64 undef>, %t0
62 declare void @use64(i64)
63 declare void @use32(i64)
65 define i64 @t6(i64 %x) {
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]]
73 call void @use64(i64 %t0)
78 define i64 @n7(i64 %x) {
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]]
86 call void @use32(i64 %t0)
91 define i64 @n8(i64 %x) {
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]]
100 call void @use64(i64 %t0)
101 call void @use32(i64 %t0)
106 define i64 @n9(i64 %x) {
108 ; CHECK-NEXT: [[T0:%.*]] = lshr i64 [[X:%.*]], 62
109 ; CHECK-NEXT: [[R:%.*]] = sub nsw i64 0, [[T0]]
110 ; CHECK-NEXT: ret i64 [[R]]
112 %t0 = lshr i64 %x, 62
117 define i64 @n10(i64 %x) {
119 ; CHECK-NEXT: [[ISNOTNEG:%.*]] = icmp sgt i64 [[X:%.*]], -1
120 ; CHECK-NEXT: [[R:%.*]] = zext i1 [[ISNOTNEG]] to i64
121 ; CHECK-NEXT: ret i64 [[R]]
123 %t0 = lshr i64 %x, 63