1; NOTE: Assertions have been autogenerated by utils/update_test_checks.py 2; RUN: opt < %s -passes=instcombine -S | FileCheck %s 3; PR3021 4 5; When inst combining an FCMP with the LHS coming from a uitofp instruction, we 6; can't lower it to signed ICMP instructions. 7 8define i1 @test1(i32 %val) { 9; CHECK-LABEL: @test1( 10; CHECK-NEXT: [[TMP1:%.*]] = icmp eq i32 [[VAL:%.*]], 0 11; CHECK-NEXT: ret i1 [[TMP1]] 12; 13 %1 = uitofp i32 %val to double 14 %2 = fcmp ole double %1, 0.000000e+00 15 ret i1 %2 16} 17 18define i1 @test2(i32 %val) { 19; CHECK-LABEL: @test2( 20; CHECK-NEXT: ret i1 false 21; 22 %1 = uitofp i32 %val to double 23 %2 = fcmp olt double %1, 0.000000e+00 24 ret i1 %2 25} 26 27define i1 @test3(i32 %val) { 28; CHECK-LABEL: @test3( 29; CHECK-NEXT: ret i1 true 30; 31 %1 = uitofp i32 %val to double 32 %2 = fcmp oge double %1, 0.000000e+00 33 ret i1 %2 34} 35 36define i1 @test4(i32 %val) { 37; CHECK-LABEL: @test4( 38; CHECK-NEXT: [[TMP1:%.*]] = icmp ne i32 [[VAL:%.*]], 0 39; CHECK-NEXT: ret i1 [[TMP1]] 40; 41 %1 = uitofp i32 %val to double 42 %2 = fcmp ogt double %1, 0.000000e+00 43 ret i1 %2 44} 45 46define i1 @test5(i32 %val) { 47; CHECK-LABEL: @test5( 48; CHECK-NEXT: ret i1 true 49; 50 %1 = uitofp i32 %val to double 51 %2 = fcmp ogt double %1, -4.400000e+00 52 ret i1 %2 53} 54 55define i1 @test6(i32 %val) { 56; CHECK-LABEL: @test6( 57; CHECK-NEXT: ret i1 false 58; 59 %1 = uitofp i32 %val to double 60 %2 = fcmp olt double %1, -4.400000e+00 61 ret i1 %2 62} 63 64; Check that optimizing unsigned >= comparisons correctly distinguishes 65; positive and negative constants. <rdar://problem/12029145> 66define i1 @test7(i32 %val) { 67; CHECK-LABEL: @test7( 68; CHECK-NEXT: [[TMP1:%.*]] = icmp ugt i32 [[VAL:%.*]], 3 69; CHECK-NEXT: ret i1 [[TMP1]] 70; 71 %1 = uitofp i32 %val to double 72 %2 = fcmp oge double %1, 3.200000e+00 73 ret i1 %2 74} 75