blob: f1af7ce2fb1290506e4285ba2c979f0ea260888f [file] [log] [blame]
Nick Lewyckyb56e1ab2009-09-27 06:25:05 +00001; RUN: opt < %s -instcombine -S | FileCheck %s
Bill Wendling3f547be2008-11-09 04:26:50 +00002; PR3021
3
4; When inst combining an FCMP with the LHS coming from a uitofp instruction, we
5; can't lower it to signed ICMP instructions.
6
Matt Arsenaultea515d32014-11-24 23:03:17 +00007; CHECK-LABEL: @test1(
Bill Wendling3f547be2008-11-09 04:26:50 +00008define i1 @test1(i32 %val) {
9 %1 = uitofp i32 %val to double
10 %2 = fcmp ole double %1, 0.000000e+00
Nick Lewyckyb56e1ab2009-09-27 06:25:05 +000011; CHECK: icmp eq i32 %val, 0
Bill Wendling3f547be2008-11-09 04:26:50 +000012 ret i1 %2
13}
14
Matt Arsenaultea515d32014-11-24 23:03:17 +000015; CHECK-LABEL: @test2(
Bill Wendling3f547be2008-11-09 04:26:50 +000016define i1 @test2(i32 %val) {
17 %1 = uitofp i32 %val to double
18 %2 = fcmp olt double %1, 0.000000e+00
19 ret i1 %2
Nick Lewyckyb56e1ab2009-09-27 06:25:05 +000020; CHECK: ret i1 false
Bill Wendling3f547be2008-11-09 04:26:50 +000021}
22
Matt Arsenaultea515d32014-11-24 23:03:17 +000023; CHECK-LABEL: @test3(
Bill Wendling3f547be2008-11-09 04:26:50 +000024define i1 @test3(i32 %val) {
25 %1 = uitofp i32 %val to double
26 %2 = fcmp oge double %1, 0.000000e+00
27 ret i1 %2
Nick Lewyckyb56e1ab2009-09-27 06:25:05 +000028; CHECK: ret i1 true
Bill Wendling3f547be2008-11-09 04:26:50 +000029}
30
Matt Arsenaultea515d32014-11-24 23:03:17 +000031; CHECK-LABEL: @test4(
Bill Wendling3f547be2008-11-09 04:26:50 +000032define i1 @test4(i32 %val) {
33 %1 = uitofp i32 %val to double
34 %2 = fcmp ogt double %1, 0.000000e+00
Nick Lewyckyb56e1ab2009-09-27 06:25:05 +000035; CHECK: icmp ne i32 %val, 0
Bill Wendling3f547be2008-11-09 04:26:50 +000036 ret i1 %2
37}
38
Matt Arsenaultea515d32014-11-24 23:03:17 +000039; CHECK-LABEL: @test5(
Bill Wendling3f547be2008-11-09 04:26:50 +000040define i1 @test5(i32 %val) {
41 %1 = uitofp i32 %val to double
42 %2 = fcmp ogt double %1, -4.400000e+00
43 ret i1 %2
Nick Lewyckyb56e1ab2009-09-27 06:25:05 +000044; CHECK: ret i1 true
Bill Wendling3f547be2008-11-09 04:26:50 +000045}
46
Matt Arsenaultea515d32014-11-24 23:03:17 +000047; CHECK-LABEL: @test6(
Bill Wendling3f547be2008-11-09 04:26:50 +000048define i1 @test6(i32 %val) {
49 %1 = uitofp i32 %val to double
50 %2 = fcmp olt double %1, -4.400000e+00
51 ret i1 %2
Nick Lewyckyb56e1ab2009-09-27 06:25:05 +000052; CHECK: ret i1 false
Bill Wendling3f547be2008-11-09 04:26:50 +000053}
Bob Wilson61f3ad52012-08-07 22:35:16 +000054
55; Check that optimizing unsigned >= comparisons correctly distinguishes
56; positive and negative constants. <rdar://problem/12029145>
Matt Arsenaultea515d32014-11-24 23:03:17 +000057; CHECK-LABEL: @test7(
Bob Wilson61f3ad52012-08-07 22:35:16 +000058define i1 @test7(i32 %val) {
59 %1 = uitofp i32 %val to double
60 %2 = fcmp oge double %1, 3.200000e+00
61 ret i1 %2
62; CHECK: icmp ugt i32 %val, 3
63}