1 ; NOTE: Assertions have been autogenerated by utils/update_test_checks.py
2 ; RUN: opt -instcombine -S < %s | FileCheck %s
4 define i32 @cttz_neg_value(i32 %x) {
5 ; CHECK-LABEL: @cttz_neg_value(
6 ; CHECK-NEXT: [[B:%.*]] = call i32 @llvm.cttz.i32(i32 [[X:%.*]], i1 false), !range !0
7 ; CHECK-NEXT: ret i32 [[B]]
10 %b = tail call i32 @llvm.cttz.i32(i32 %a)
14 define i32 @cttz_neg_value_multiuse(i32 %x) {
15 ; CHECK-LABEL: @cttz_neg_value_multiuse(
16 ; CHECK-NEXT: [[A:%.*]] = sub i32 0, [[X:%.*]]
17 ; CHECK-NEXT: call void @use(i32 [[A]])
18 ; CHECK-NEXT: [[B:%.*]] = call i32 @llvm.cttz.i32(i32 [[X]], i1 false), !range !0
19 ; CHECK-NEXT: ret i32 [[B]]
22 call void @use(i32 %a)
23 %b = tail call i32 @llvm.cttz.i32(i32 %a)
27 define i64 @cttz_neg_value_64(i64 %x) {
28 ; CHECK-LABEL: @cttz_neg_value_64(
29 ; CHECK-NEXT: [[B:%.*]] = tail call i64 @llvm.cttz.i64(i64 [[X:%.*]], i1 true), !range !1
30 ; CHECK-NEXT: ret i64 [[B]]
33 %b = tail call i64 @llvm.cttz.i64(i64 %a, i1 true)
37 define i64 @cttz_neg_value2_64(i64 %x) {
38 ; CHECK-LABEL: @cttz_neg_value2_64(
39 ; CHECK-NEXT: [[B:%.*]] = tail call i64 @llvm.cttz.i64(i64 [[X:%.*]], i1 false), !range !1
40 ; CHECK-NEXT: ret i64 [[B]]
43 %b = tail call i64 @llvm.cttz.i64(i64 %a, i1 false)
47 define <2 x i64> @cttz_neg_value_vec(<2 x i64> %x) {
48 ; CHECK-LABEL: @cttz_neg_value_vec(
49 ; CHECK-NEXT: [[B:%.*]] = call <2 x i64> @llvm.cttz.v2i64(<2 x i64> [[X:%.*]], i1 false)
50 ; CHECK-NEXT: ret <2 x i64> [[B]]
52 %a = sub <2 x i64> zeroinitializer, %x
53 %b = tail call <2 x i64> @llvm.cttz.v2i64(<2 x i64> %a)
59 define i32 @cttz_nonneg_value(i32 %x) {
60 ; CHECK-LABEL: @cttz_nonneg_value(
61 ; CHECK-NEXT: [[A:%.*]] = sub i32 1, [[X:%.*]]
62 ; CHECK-NEXT: [[B:%.*]] = call i32 @llvm.cttz.i32(i32 [[A]], i1 false), !range !0
63 ; CHECK-NEXT: ret i32 [[B]]
66 %b = tail call i32 @llvm.cttz.i32(i32 %a)
70 define <2 x i64> @cttz_nonneg_value_vec(<2 x i64> %x) {
71 ; CHECK-LABEL: @cttz_nonneg_value_vec(
72 ; CHECK-NEXT: [[A:%.*]] = sub <2 x i64> <i64 1, i64 0>, [[X:%.*]]
73 ; CHECK-NEXT: [[B:%.*]] = call <2 x i64> @llvm.cttz.v2i64(<2 x i64> [[A]], i1 false)
74 ; CHECK-NEXT: ret <2 x i64> [[B]]
76 %a = sub <2 x i64> <i64 1, i64 0>, %x
77 %b = tail call <2 x i64> @llvm.cttz.v2i64(<2 x i64> %a)
81 declare void @use(i32 %a)
82 declare i32 @llvm.cttz.i32(i32)
83 declare i64 @llvm.cttz.i64(i64, i1)
84 declare <2 x i64> @llvm.cttz.v2i64(<2 x i64>)