1 ; NOTE: Assertions have been autogenerated by utils/update_test_checks.py UTC_ARGS: --version 5
2 ; RUN: opt -S -passes=newgvn < %s | FileCheck %s
4 ; Make sure attributes in function calls are intersected correctly.
6 define i1 @bucket(i32 noundef %x) {
7 ; CHECK-LABEL: define i1 @bucket(
8 ; CHECK-SAME: i32 noundef [[X:%.*]]) {
9 ; CHECK-NEXT: [[CMP1:%.*]] = icmp sgt i32 [[X]], 0
10 ; CHECK-NEXT: [[CTPOP1:%.*]] = tail call range(i32 0, 33) i32 @llvm.ctpop.i32(i32 [[X]])
11 ; CHECK-NEXT: [[CMP2:%.*]] = icmp samesign ult i32 [[CTPOP1]], 2
12 ; CHECK-NEXT: [[COND:%.*]] = select i1 [[CMP1]], i1 [[CMP2]], i1 false
13 ; CHECK-NEXT: br i1 [[COND]], label %[[IF_THEN:.*]], label %[[IF_ELSE:.*]]
15 ; CHECK-NEXT: [[RES:%.*]] = icmp eq i32 [[CTPOP1]], 1
16 ; CHECK-NEXT: ret i1 [[RES]]
18 ; CHECK-NEXT: ret i1 false
20 %cmp1 = icmp sgt i32 %x, 0
21 %ctpop1 = tail call range(i32 1, 32) i32 @llvm.ctpop.i32(i32 %x)
22 %cmp2 = icmp samesign ult i32 %ctpop1, 2
23 %cond = select i1 %cmp1, i1 %cmp2, i1 false
24 br i1 %cond, label %if.then, label %if.else
27 %ctpop2 = tail call range(i32 0, 33) i32 @llvm.ctpop.i32(i32 %x)
28 %res = icmp eq i32 %ctpop2, 1
35 ; Make sure we don't merge these two users of the incompatible call pair.
37 define i1 @bucket2(i32 noundef %x) {
38 ; CHECK-LABEL: define i1 @bucket2(
39 ; CHECK-SAME: i32 noundef [[X:%.*]]) {
40 ; CHECK-NEXT: [[CMP1:%.*]] = icmp sgt i32 [[X]], 0
41 ; CHECK-NEXT: [[CTPOP1:%.*]] = tail call range(i32 1, 32) i32 @llvm.ctpop.i32(i32 zeroext [[X]])
42 ; CHECK-NEXT: [[CTPOP1INC:%.*]] = add i32 [[CTPOP1]], 1
43 ; CHECK-NEXT: [[CMP2:%.*]] = icmp samesign ult i32 [[CTPOP1INC]], 3
44 ; CHECK-NEXT: [[COND:%.*]] = select i1 [[CMP1]], i1 [[CMP2]], i1 false
45 ; CHECK-NEXT: br i1 [[COND]], label %[[IF_THEN:.*]], label %[[IF_ELSE:.*]]
47 ; CHECK-NEXT: [[CTPOP2:%.*]] = tail call range(i32 0, 33) i32 @llvm.ctpop.i32(i32 [[X]])
48 ; CHECK-NEXT: [[CTPOP2INC:%.*]] = add i32 [[CTPOP2]], 1
49 ; CHECK-NEXT: [[RES:%.*]] = icmp eq i32 [[CTPOP2INC]], 2
50 ; CHECK-NEXT: ret i1 [[RES]]
52 ; CHECK-NEXT: ret i1 false
54 %cmp1 = icmp sgt i32 %x, 0
55 %ctpop1 = tail call range(i32 1, 32) i32 @llvm.ctpop.i32(i32 zeroext %x)
56 %ctpop1inc = add i32 %ctpop1, 1
57 %cmp2 = icmp samesign ult i32 %ctpop1inc, 3
58 %cond = select i1 %cmp1, i1 %cmp2, i1 false
59 br i1 %cond, label %if.then, label %if.else
62 %ctpop2 = tail call range(i32 0, 33) i32 @llvm.ctpop.i32(i32 %x)
63 %ctpop2inc = add i32 %ctpop2, 1
64 %res = icmp eq i32 %ctpop2inc, 2