1; RUN: opt < %s -instcombine -S | FileCheck %s 2target datalayout = "e-m:e-i64:64-f80:128-n8:16:32:64-S128" 3target triple = "x86_64-unknown-linux-gnu" 4 5; Function Attrs: nounwind 6declare void @llvm.assume(i1) #1 7 8; Function Attrs: nounwind uwtable 9define i32 @test1(i32 %a) #0 { 10entry: 11; CHECK-LABEL: @test1 12; CHECK: call void @llvm.assume 13; CHECK: ret i32 5 14 15 %and = and i32 %a, 15 16 %cmp = icmp eq i32 %and, 5 17 tail call void @llvm.assume(i1 %cmp) 18 19 %and1 = and i32 %a, 7 20 ret i32 %and1 21} 22 23; Function Attrs: nounwind uwtable 24define i32 @test2(i32 %a) #0 { 25entry: 26; CHECK-LABEL: @test2 27; CHECK: call void @llvm.assume 28; CHECK: ret i32 2 29 30 %and = and i32 %a, 15 31 %nand = xor i32 %and, -1 32 %cmp = icmp eq i32 %nand, 4294967285 33 tail call void @llvm.assume(i1 %cmp) 34 35 %and1 = and i32 %a, 7 36 ret i32 %and1 37} 38 39; Function Attrs: nounwind uwtable 40define i32 @test3(i32 %a) #0 { 41entry: 42; CHECK-LABEL: @test3 43; CHECK: call void @llvm.assume 44; CHECK: ret i32 5 45 46 %v = or i32 %a, 4294967280 47 %cmp = icmp eq i32 %v, 4294967285 48 tail call void @llvm.assume(i1 %cmp) 49 50 %and1 = and i32 %a, 7 51 ret i32 %and1 52} 53 54; Function Attrs: nounwind uwtable 55define i32 @test4(i32 %a) #0 { 56entry: 57; CHECK-LABEL: @test4 58; CHECK: call void @llvm.assume 59; CHECK: ret i32 2 60 61 %v = or i32 %a, 4294967280 62 %nv = xor i32 %v, -1 63 %cmp = icmp eq i32 %nv, 5 64 tail call void @llvm.assume(i1 %cmp) 65 66 %and1 = and i32 %a, 7 67 ret i32 %and1 68} 69 70; Function Attrs: nounwind uwtable 71define i32 @test5(i32 %a) #0 { 72entry: 73; CHECK-LABEL: @test5 74; CHECK: call void @llvm.assume 75; CHECK: ret i32 4 76 77 %v = xor i32 %a, 1 78 %cmp = icmp eq i32 %v, 5 79 tail call void @llvm.assume(i1 %cmp) 80 81 %and1 = and i32 %a, 7 82 ret i32 %and1 83} 84 85; Function Attrs: nounwind uwtable 86define i32 @test6(i32 %a) #0 { 87entry: 88; CHECK-LABEL: @test6 89; CHECK: call void @llvm.assume 90; CHECK: ret i32 5 91 92 %v = shl i32 %a, 2 93 %cmp = icmp eq i32 %v, 20 94 tail call void @llvm.assume(i1 %cmp) 95 96 %and1 = and i32 %a, 63 97 ret i32 %and1 98} 99 100; Function Attrs: nounwind uwtable 101define i32 @test7(i32 %a) #0 { 102entry: 103; CHECK-LABEL: @test7 104; CHECK: call void @llvm.assume 105; CHECK: ret i32 20 106 107 %v = lshr i32 %a, 2 108 %cmp = icmp eq i32 %v, 5 109 tail call void @llvm.assume(i1 %cmp) 110 111 %and1 = and i32 %a, 252 112 ret i32 %and1 113} 114 115; Function Attrs: nounwind uwtable 116define i32 @test8(i32 %a) #0 { 117entry: 118; CHECK-LABEL: @test8 119; CHECK: call void @llvm.assume 120; CHECK: ret i32 20 121 122 %v = lshr i32 %a, 2 123 %cmp = icmp eq i32 %v, 5 124 tail call void @llvm.assume(i1 %cmp) 125 126 %and1 = and i32 %a, 252 127 ret i32 %and1 128} 129 130; Function Attrs: nounwind uwtable 131define i32 @test9(i32 %a) #0 { 132entry: 133; CHECK-LABEL: @test9 134; CHECK: call void @llvm.assume 135; CHECK: ret i32 0 136 137 %cmp = icmp sgt i32 %a, 5 138 tail call void @llvm.assume(i1 %cmp) 139 140 %and1 = and i32 %a, 2147483648 141 ret i32 %and1 142} 143 144; Function Attrs: nounwind uwtable 145define i32 @test10(i32 %a) #0 { 146entry: 147; CHECK-LABEL: @test10 148; CHECK: call void @llvm.assume 149; CHECK: ret i32 -2147483648 150 151 %cmp = icmp sle i32 %a, -2 152 tail call void @llvm.assume(i1 %cmp) 153 154 %and1 = and i32 %a, 2147483648 155 ret i32 %and1 156} 157 158; Function Attrs: nounwind uwtable 159define i32 @test11(i32 %a) #0 { 160entry: 161; CHECK-LABEL: @test11 162; CHECK: call void @llvm.assume 163; CHECK: ret i32 0 164 165 %cmp = icmp ule i32 %a, 256 166 tail call void @llvm.assume(i1 %cmp) 167 168 %and1 = and i32 %a, 3072 169 ret i32 %and1 170} 171 172attributes #0 = { nounwind uwtable } 173attributes #1 = { nounwind } 174 175