1 ; RUN: opt < %s -instsimplify -S | FileCheck %s
3 define i32 @test1(i32 %x) {
5 %cmp = icmp eq i32 %and, 0
7 %and1.x = select i1 %cmp, i32 %and1, i32 %x
13 define i32 @test2(i32 %x) {
15 %cmp = icmp ne i32 %and, 0
16 %and1 = and i32 %x, -2
17 %and1.x = select i1 %cmp, i32 %x, i32 %and1
19 ; CHECK-LABEL: @test2(
23 define i32 @test3(i32 %x) {
25 %cmp = icmp ne i32 %and, 0
26 %and1 = and i32 %x, -2
27 %and1.x = select i1 %cmp, i32 %and1, i32 %x
29 ; CHECK-LABEL: @test3(
30 ; CHECK: %[[and:.*]] = and i32 %x, -2
31 ; CHECK: ret i32 %[[and]]
34 ; CHECK-LABEL: @select_icmp_and_8_eq_0_or_8(
35 ; CHECK-NEXT: [[OR:%[a-z0-9]+]] = or i32 %x, 8
36 ; CHECK-NEXT: ret i32 [[OR]]
37 define i32 @select_icmp_and_8_eq_0_or_8(i32 %x) {
39 %cmp = icmp eq i32 %and, 0
41 %or.x = select i1 %cmp, i32 %or, i32 %x
45 ; CHECK-LABEL: @select_icmp_and_8_ne_0_and_not_8(
46 ; CHECK-NEXT: [[AND:%[a-z0-9]+]] = and i32 %x, -9
47 ; CHECK-NEXT: ret i32 [[AND]]
48 define i32 @select_icmp_and_8_ne_0_and_not_8(i32 %x) {
50 %cmp = icmp eq i32 %and, 0
51 %and1 = and i32 %x, -9
52 %x.and1 = select i1 %cmp, i32 %x, i32 %and1
56 ; CHECK-LABEL: @select_icmp_and_8_eq_0_and_not_8(
57 ; CHECK-NEXT: ret i32 %x
58 define i32 @select_icmp_and_8_eq_0_and_not_8(i32 %x) {
60 %cmp = icmp eq i32 %and, 0
61 %and1 = and i32 %x, -9
62 %and1.x = select i1 %cmp, i32 %and1, i32 %x
66 ; CHECK-LABEL: @select_icmp_x_and_8_eq_0_y_and_not_8(
67 ; CHECK: select i1 %cmp, i64 %y, i64 %and1
68 define i64 @select_icmp_x_and_8_eq_0_y_and_not_8(i32 %x, i64 %y) {
70 %cmp = icmp eq i32 %and, 0
71 %and1 = and i64 %y, -9
72 %y.and1 = select i1 %cmp, i64 %y, i64 %and1
76 ; CHECK-LABEL: @select_icmp_x_and_8_ne_0_y_and_not_8(
77 ; CHECK: select i1 %cmp, i64 %and1, i64 %y
78 define i64 @select_icmp_x_and_8_ne_0_y_and_not_8(i32 %x, i64 %y) {
80 %cmp = icmp eq i32 %and, 0
81 %and1 = and i64 %y, -9
82 %and1.y = select i1 %cmp, i64 %and1, i64 %y