1; NOTE: Assertions have been autogenerated by utils/update_test_checks.py 2; RUN: opt -S -correlated-propagation < %s | FileCheck %s 3 4declare i32 @llvm.umin.i32(i32, i32) 5declare i32 @llvm.umax.i32(i32, i32) 6declare i32 @llvm.smin.i32(i32, i32) 7declare i32 @llvm.smax.i32(i32, i32) 8declare i32 @llvm.abs.i32(i32, i1) 9declare void @use(i1) 10 11define void @test_umin(i32 %x) { 12; CHECK-LABEL: @test_umin( 13; CHECK-NEXT: [[M:%.*]] = call i32 @llvm.umin.i32(i32 [[X:%.*]], i32 10) 14; CHECK-NEXT: call void @use(i1 true) 15; CHECK-NEXT: [[C2:%.*]] = icmp ult i32 [[M]], 10 16; CHECK-NEXT: call void @use(i1 [[C2]]) 17; CHECK-NEXT: ret void 18; 19 %m = call i32 @llvm.umin.i32(i32 %x, i32 10) 20 %c1 = icmp ule i32 %m, 10 21 call void @use(i1 %c1) 22 %c2 = icmp ult i32 %m, 10 23 call void @use(i1 %c2) 24 ret void 25} 26 27define void @test_umax(i32 %x) { 28; CHECK-LABEL: @test_umax( 29; CHECK-NEXT: [[M:%.*]] = call i32 @llvm.umax.i32(i32 [[X:%.*]], i32 10) 30; CHECK-NEXT: call void @use(i1 true) 31; CHECK-NEXT: [[C2:%.*]] = icmp ugt i32 [[M]], 10 32; CHECK-NEXT: call void @use(i1 [[C2]]) 33; CHECK-NEXT: ret void 34; 35 %m = call i32 @llvm.umax.i32(i32 %x, i32 10) 36 %c1 = icmp uge i32 %m, 10 37 call void @use(i1 %c1) 38 %c2 = icmp ugt i32 %m, 10 39 call void @use(i1 %c2) 40 ret void 41} 42 43define void @test_smin(i32 %x) { 44; CHECK-LABEL: @test_smin( 45; CHECK-NEXT: [[M:%.*]] = call i32 @llvm.smin.i32(i32 [[X:%.*]], i32 10) 46; CHECK-NEXT: call void @use(i1 true) 47; CHECK-NEXT: [[C2:%.*]] = icmp slt i32 [[M]], 10 48; CHECK-NEXT: call void @use(i1 [[C2]]) 49; CHECK-NEXT: ret void 50; 51 %m = call i32 @llvm.smin.i32(i32 %x, i32 10) 52 %c1 = icmp sle i32 %m, 10 53 call void @use(i1 %c1) 54 %c2 = icmp slt i32 %m, 10 55 call void @use(i1 %c2) 56 ret void 57} 58 59define void @test_smax(i32 %x) { 60; CHECK-LABEL: @test_smax( 61; CHECK-NEXT: [[M:%.*]] = call i32 @llvm.smax.i32(i32 [[X:%.*]], i32 10) 62; CHECK-NEXT: call void @use(i1 true) 63; CHECK-NEXT: [[C2:%.*]] = icmp sgt i32 [[M]], 10 64; CHECK-NEXT: call void @use(i1 [[C2]]) 65; CHECK-NEXT: ret void 66; 67 %m = call i32 @llvm.smax.i32(i32 %x, i32 10) 68 %c1 = icmp sge i32 %m, 10 69 call void @use(i1 %c1) 70 %c2 = icmp sgt i32 %m, 10 71 call void @use(i1 %c2) 72 ret void 73} 74 75define void @test_abs1(i32* %p) { 76; CHECK-LABEL: @test_abs1( 77; CHECK-NEXT: [[X:%.*]] = load i32, i32* [[P:%.*]], align 4, [[RNG0:!range !.*]] 78; CHECK-NEXT: [[A:%.*]] = call i32 @llvm.abs.i32(i32 [[X]], i1 false) 79; CHECK-NEXT: call void @use(i1 true) 80; CHECK-NEXT: [[C2:%.*]] = icmp ult i32 [[A]], 15 81; CHECK-NEXT: call void @use(i1 [[C2]]) 82; CHECK-NEXT: ret void 83; 84 %x = load i32, i32* %p, !range !{i32 -15, i32 10} 85 %a = call i32 @llvm.abs.i32(i32 %x, i1 false) 86 %c1 = icmp ule i32 %a, 15 87 call void @use(i1 %c1) 88 %c2 = icmp ult i32 %a, 15 89 call void @use(i1 %c2) 90 ret void 91} 92 93define void @test_abs2(i32 %x) { 94; CHECK-LABEL: @test_abs2( 95; CHECK-NEXT: [[A:%.*]] = call i32 @llvm.abs.i32(i32 [[X:%.*]], i1 false) 96; CHECK-NEXT: call void @use(i1 true) 97; CHECK-NEXT: [[C2:%.*]] = icmp ult i32 [[A]], -2147483648 98; CHECK-NEXT: call void @use(i1 [[C2]]) 99; CHECK-NEXT: ret void 100; 101 %a = call i32 @llvm.abs.i32(i32 %x, i1 false) 102 %c1 = icmp ule i32 %a, 2147483648 103 call void @use(i1 %c1) 104 %c2 = icmp ult i32 %a, 2147483648 105 call void @use(i1 %c2) 106 ret void 107} 108 109define void @test_abs3(i32 %x) { 110; CHECK-LABEL: @test_abs3( 111; CHECK-NEXT: [[A:%.*]] = call i32 @llvm.abs.i32(i32 [[X:%.*]], i1 true) 112; CHECK-NEXT: call void @use(i1 true) 113; CHECK-NEXT: [[C2:%.*]] = icmp sgt i32 [[A]], 0 114; CHECK-NEXT: call void @use(i1 [[C2]]) 115; CHECK-NEXT: ret void 116; 117 %a = call i32 @llvm.abs.i32(i32 %x, i1 true) 118 %c1 = icmp sge i32 %a, 0 119 call void @use(i1 %c1) 120 %c2 = icmp sgt i32 %a, 0 121 call void @use(i1 %c2) 122 ret void 123} 124