File: fcmp.ll

package info (click to toggle)
llvm-toolchain-17 1%3A17.0.6-22
  • links: PTS, VCS
  • area: main
  • in suites: forky, sid, trixie
  • size: 1,799,624 kB
  • sloc: cpp: 6,428,607; ansic: 1,383,196; asm: 793,408; python: 223,504; objc: 75,364; f90: 60,502; lisp: 33,869; pascal: 15,282; sh: 9,684; perl: 7,453; ml: 4,937; awk: 3,523; makefile: 2,889; javascript: 2,149; xml: 888; fortran: 619; cs: 573
file content (1290 lines) | stat: -rw-r--r-- 39,843 bytes parent folder | download | duplicates (4)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
245
246
247
248
249
250
251
252
253
254
255
256
257
258
259
260
261
262
263
264
265
266
267
268
269
270
271
272
273
274
275
276
277
278
279
280
281
282
283
284
285
286
287
288
289
290
291
292
293
294
295
296
297
298
299
300
301
302
303
304
305
306
307
308
309
310
311
312
313
314
315
316
317
318
319
320
321
322
323
324
325
326
327
328
329
330
331
332
333
334
335
336
337
338
339
340
341
342
343
344
345
346
347
348
349
350
351
352
353
354
355
356
357
358
359
360
361
362
363
364
365
366
367
368
369
370
371
372
373
374
375
376
377
378
379
380
381
382
383
384
385
386
387
388
389
390
391
392
393
394
395
396
397
398
399
400
401
402
403
404
405
406
407
408
409
410
411
412
413
414
415
416
417
418
419
420
421
422
423
424
425
426
427
428
429
430
431
432
433
434
435
436
437
438
439
440
441
442
443
444
445
446
447
448
449
450
451
452
453
454
455
456
457
458
459
460
461
462
463
464
465
466
467
468
469
470
471
472
473
474
475
476
477
478
479
480
481
482
483
484
485
486
487
488
489
490
491
492
493
494
495
496
497
498
499
500
501
502
503
504
505
506
507
508
509
510
511
512
513
514
515
516
517
518
519
520
521
522
523
524
525
526
527
528
529
530
531
532
533
534
535
536
537
538
539
540
541
542
543
544
545
546
547
548
549
550
551
552
553
554
555
556
557
558
559
560
561
562
563
564
565
566
567
568
569
570
571
572
573
574
575
576
577
578
579
580
581
582
583
584
585
586
587
588
589
590
591
592
593
594
595
596
597
598
599
600
601
602
603
604
605
606
607
608
609
610
611
612
613
614
615
616
617
618
619
620
621
622
623
624
625
626
627
628
629
630
631
632
633
634
635
636
637
638
639
640
641
642
643
644
645
646
647
648
649
650
651
652
653
654
655
656
657
658
659
660
661
662
663
664
665
666
667
668
669
670
671
672
673
674
675
676
677
678
679
680
681
682
683
684
685
686
687
688
689
690
691
692
693
694
695
696
697
698
699
700
701
702
703
704
705
706
707
708
709
710
711
712
713
714
715
716
717
718
719
720
721
722
723
724
725
726
727
728
729
730
731
732
733
734
735
736
737
738
739
740
741
742
743
744
745
746
747
748
749
750
751
752
753
754
755
756
757
758
759
760
761
762
763
764
765
766
767
768
769
770
771
772
773
774
775
776
777
778
779
780
781
782
783
784
785
786
787
788
789
790
791
792
793
794
795
796
797
798
799
800
801
802
803
804
805
806
807
808
809
810
811
812
813
814
815
816
817
818
819
820
821
822
823
824
825
826
827
828
829
830
831
832
833
834
835
836
837
838
839
840
841
842
843
844
845
846
847
848
849
850
851
852
853
854
855
856
857
858
859
860
861
862
863
864
865
866
867
868
869
870
871
872
873
874
875
876
877
878
879
880
881
882
883
884
885
886
887
888
889
890
891
892
893
894
895
896
897
898
899
900
901
902
903
904
905
906
907
908
909
910
911
912
913
914
915
916
917
918
919
920
921
922
923
924
925
926
927
928
929
930
931
932
933
934
935
936
937
938
939
940
941
942
943
944
945
946
947
948
949
950
951
952
953
954
955
956
957
958
959
960
961
962
963
964
965
966
967
968
969
970
971
972
973
974
975
976
977
978
979
980
981
982
983
984
985
986
987
988
989
990
991
992
993
994
995
996
997
998
999
1000
1001
1002
1003
1004
1005
1006
1007
1008
1009
1010
1011
1012
1013
1014
1015
1016
1017
1018
1019
1020
1021
1022
1023
1024
1025
1026
1027
1028
1029
1030
1031
1032
1033
1034
1035
1036
1037
1038
1039
1040
1041
1042
1043
1044
1045
1046
1047
1048
1049
1050
1051
1052
1053
1054
1055
1056
1057
1058
1059
1060
1061
1062
1063
1064
1065
1066
1067
1068
1069
1070
1071
1072
1073
1074
1075
1076
1077
1078
1079
1080
1081
1082
1083
1084
1085
1086
1087
1088
1089
1090
1091
1092
1093
1094
1095
1096
1097
1098
1099
1100
1101
1102
1103
1104
1105
1106
1107
1108
1109
1110
1111
1112
1113
1114
1115
1116
1117
1118
1119
1120
1121
1122
1123
1124
1125
1126
1127
1128
1129
1130
1131
1132
1133
1134
1135
1136
1137
1138
1139
1140
1141
1142
1143
1144
1145
1146
1147
1148
1149
1150
1151
1152
1153
1154
1155
1156
1157
1158
1159
1160
1161
1162
1163
1164
1165
1166
1167
1168
1169
1170
1171
1172
1173
1174
1175
1176
1177
1178
1179
1180
1181
1182
1183
1184
1185
1186
1187
1188
1189
1190
1191
1192
1193
1194
1195
1196
1197
1198
1199
1200
1201
1202
1203
1204
1205
1206
1207
1208
1209
1210
1211
1212
1213
1214
1215
1216
1217
1218
1219
1220
1221
1222
1223
1224
1225
1226
1227
1228
1229
1230
1231
1232
1233
1234
1235
1236
1237
1238
1239
1240
1241
1242
1243
1244
1245
1246
1247
1248
1249
1250
1251
1252
1253
1254
1255
1256
1257
1258
1259
1260
1261
1262
1263
1264
1265
1266
1267
1268
1269
1270
1271
1272
1273
1274
1275
1276
1277
1278
1279
1280
1281
1282
1283
1284
1285
1286
1287
1288
1289
1290
; NOTE: Assertions have been autogenerated by utils/update_test_checks.py
; RUN: opt -S -passes=instcombine < %s | FileCheck %s

declare half @llvm.fabs.f16(half)
declare double @llvm.fabs.f64(double)
declare <2 x float> @llvm.fabs.v2f32(<2 x float>)
declare double @llvm.copysign.f64(double, double)
declare <2 x double> @llvm.copysign.v2f64(<2 x double>, <2 x double>)

declare void @use(float)

define i1 @fpext_fpext(float %x, float %y) {
; CHECK-LABEL: @fpext_fpext(
; CHECK-NEXT:    [[CMP:%.*]] = fcmp nnan ogt float [[X:%.*]], [[Y:%.*]]
; CHECK-NEXT:    ret i1 [[CMP]]
;
  %ext1 = fpext float %x to double
  %ext2 = fpext float %y to double
  %cmp = fcmp nnan ogt double %ext1, %ext2
  ret i1 %cmp
}

define i1 @fpext_constant(float %a) {
; CHECK-LABEL: @fpext_constant(
; CHECK-NEXT:    [[CMP:%.*]] = fcmp ninf ogt float [[A:%.*]], 1.000000e+00
; CHECK-NEXT:    ret i1 [[CMP]]
;
  %ext = fpext float %a to double
  %cmp = fcmp ninf ogt double %ext, 1.000000e+00
  ret i1 %cmp
}

define <2 x i1> @fpext_constant_vec_splat(<2 x half> %a) {
; CHECK-LABEL: @fpext_constant_vec_splat(
; CHECK-NEXT:    [[CMP:%.*]] = fcmp nnan ole <2 x half> [[A:%.*]], <half 0xH5140, half 0xH5140>
; CHECK-NEXT:    ret <2 x i1> [[CMP]]
;
  %ext = fpext <2 x half> %a to <2 x double>
  %cmp = fcmp nnan ole <2 x double> %ext, <double 42.0, double 42.0>
  ret <2 x i1> %cmp
}

define i1 @fpext_constant_lossy(float %a) {
; CHECK-LABEL: @fpext_constant_lossy(
; CHECK-NEXT:    [[EXT:%.*]] = fpext float [[A:%.*]] to double
; CHECK-NEXT:    [[CMP:%.*]] = fcmp ogt double [[EXT]], 0x3FF0000000000001
; CHECK-NEXT:    ret i1 [[CMP]]
;
  %ext = fpext float %a to double
  %cmp = fcmp ogt double %ext, 0x3FF0000000000001 ; more precision than float.
  ret i1 %cmp
}

define i1 @fpext_constant_denorm(float %a) {
; CHECK-LABEL: @fpext_constant_denorm(
; CHECK-NEXT:    [[EXT:%.*]] = fpext float [[A:%.*]] to double
; CHECK-NEXT:    [[CMP:%.*]] = fcmp ogt double [[EXT]], 0x36A0000000000000
; CHECK-NEXT:    ret i1 [[CMP]]
;
  %ext = fpext float %a to double
  %cmp = fcmp ogt double %ext, 0x36A0000000000000 ; denormal in float.
  ret i1 %cmp
}

define i1 @fneg_constant_swap_pred(float %x) {
; CHECK-LABEL: @fneg_constant_swap_pred(
; CHECK-NEXT:    [[CMP:%.*]] = fcmp olt float [[X:%.*]], -1.000000e+00
; CHECK-NEXT:    ret i1 [[CMP]]
;
  %neg = fsub float -0.0, %x
  %cmp = fcmp ogt float %neg, 1.0
  ret i1 %cmp
}

define i1 @unary_fneg_constant_swap_pred(float %x) {
; CHECK-LABEL: @unary_fneg_constant_swap_pred(
; CHECK-NEXT:    [[CMP:%.*]] = fcmp olt float [[X:%.*]], -1.000000e+00
; CHECK-NEXT:    ret i1 [[CMP]]
;
  %neg = fneg float %x
  %cmp = fcmp ogt float %neg, 1.0
  ret i1 %cmp
}

define <2 x i1> @fneg_constant_swap_pred_vec(<2 x float> %x) {
; CHECK-LABEL: @fneg_constant_swap_pred_vec(
; CHECK-NEXT:    [[CMP:%.*]] = fcmp olt <2 x float> [[X:%.*]], <float -1.000000e+00, float -2.000000e+00>
; CHECK-NEXT:    ret <2 x i1> [[CMP]]
;
  %neg = fsub <2 x float> <float -0.0, float -0.0>, %x
  %cmp = fcmp ogt <2 x float> %neg, <float 1.0, float 2.0>
  ret <2 x i1> %cmp
}

define <2 x i1> @unary_fneg_constant_swap_pred_vec(<2 x float> %x) {
; CHECK-LABEL: @unary_fneg_constant_swap_pred_vec(
; CHECK-NEXT:    [[CMP:%.*]] = fcmp olt <2 x float> [[X:%.*]], <float -1.000000e+00, float -2.000000e+00>
; CHECK-NEXT:    ret <2 x i1> [[CMP]]
;
  %neg = fneg <2 x float> %x
  %cmp = fcmp ogt <2 x float> %neg, <float 1.0, float 2.0>
  ret <2 x i1> %cmp
}

define <2 x i1> @fneg_constant_swap_pred_vec_undef(<2 x float> %x) {
; CHECK-LABEL: @fneg_constant_swap_pred_vec_undef(
; CHECK-NEXT:    [[CMP:%.*]] = fcmp olt <2 x float> [[X:%.*]], <float -1.000000e+00, float -2.000000e+00>
; CHECK-NEXT:    ret <2 x i1> [[CMP]]
;
  %neg = fsub <2 x float> <float undef, float -0.0>, %x
  %cmp = fcmp ogt <2 x float> %neg, <float 1.0, float 2.0>
  ret <2 x i1> %cmp
}

; The new fcmp should have the same FMF as the original.

define i1 @fneg_fmf(float %x) {
; CHECK-LABEL: @fneg_fmf(
; CHECK-NEXT:    [[R:%.*]] = fcmp fast oeq float [[X:%.*]], -4.200000e+01
; CHECK-NEXT:    ret i1 [[R]]
;
  %n = fsub fast float -0.0, %x
  %r = fcmp fast oeq float %n, 42.0
  ret i1 %r
}

define i1 @unary_fneg_fmf(float %x) {
; CHECK-LABEL: @unary_fneg_fmf(
; CHECK-NEXT:    [[R:%.*]] = fcmp fast oeq float [[X:%.*]], -4.200000e+01
; CHECK-NEXT:    ret i1 [[R]]
;
  %n = fneg fast float %x
  %r = fcmp fast oeq float %n, 42.0
  ret i1 %r
}

; The new fcmp should have the same FMF as the original, vector edition.

define <2 x i1> @fcmp_fneg_fmf_vec(<2 x float> %x) {
; CHECK-LABEL: @fcmp_fneg_fmf_vec(
; CHECK-NEXT:    [[R:%.*]] = fcmp reassoc nnan ule <2 x float> [[X:%.*]], <float -4.200000e+01, float 1.900000e+01>
; CHECK-NEXT:    ret <2 x i1> [[R]]
;
  %n = fsub nsz <2 x float> zeroinitializer, %x
  %r = fcmp nnan reassoc uge <2 x float> %n, <float 42.0, float -19.0>
  ret <2 x i1> %r
}

define i1 @fneg_fneg_swap_pred(float %x, float %y) {
; CHECK-LABEL: @fneg_fneg_swap_pred(
; CHECK-NEXT:    [[CMP:%.*]] = fcmp nnan ogt float [[X:%.*]], [[Y:%.*]]
; CHECK-NEXT:    ret i1 [[CMP]]
;
  %neg1 = fsub float -0.0, %x
  %neg2 = fsub float -0.0, %y
  %cmp = fcmp nnan olt float %neg1, %neg2
  ret i1 %cmp
}

define i1 @unary_fneg_unary_fneg_swap_pred(float %x, float %y) {
; CHECK-LABEL: @unary_fneg_unary_fneg_swap_pred(
; CHECK-NEXT:    [[CMP:%.*]] = fcmp nnan ogt float [[X:%.*]], [[Y:%.*]]
; CHECK-NEXT:    ret i1 [[CMP]]
;
  %neg1 = fneg float %x
  %neg2 = fneg float %y
  %cmp = fcmp nnan olt float %neg1, %neg2
  ret i1 %cmp
}

define i1 @unary_fneg_fneg_swap_pred(float %x, float %y) {
; CHECK-LABEL: @unary_fneg_fneg_swap_pred(
; CHECK-NEXT:    [[CMP:%.*]] = fcmp nnan ogt float [[X:%.*]], [[Y:%.*]]
; CHECK-NEXT:    ret i1 [[CMP]]
;
  %neg1 = fneg float %x
  %neg2 = fsub float -0.0, %y
  %cmp = fcmp nnan olt float %neg1, %neg2
  ret i1 %cmp
}

define i1 @fneg_unary_fneg_swap_pred(float %x, float %y) {
; CHECK-LABEL: @fneg_unary_fneg_swap_pred(
; CHECK-NEXT:    [[CMP:%.*]] = fcmp nnan ogt float [[X:%.*]], [[Y:%.*]]
; CHECK-NEXT:    ret i1 [[CMP]]
;
  %neg1 = fsub float -0.0, %x
  %neg2 = fneg float %y
  %cmp = fcmp nnan olt float %neg1, %neg2
  ret i1 %cmp
}

define <2 x i1> @fneg_fneg_swap_pred_vec(<2 x float> %x, <2 x float> %y) {
; CHECK-LABEL: @fneg_fneg_swap_pred_vec(
; CHECK-NEXT:    [[CMP:%.*]] = fcmp ninf ogt <2 x float> [[X:%.*]], [[Y:%.*]]
; CHECK-NEXT:    ret <2 x i1> [[CMP]]
;
  %neg1 = fsub <2 x float> <float -0.0, float -0.0>, %x
  %neg2 = fsub <2 x float> <float -0.0, float -0.0>, %y
  %cmp = fcmp ninf olt <2 x float> %neg1, %neg2
  ret <2 x i1> %cmp
}

define <2 x i1> @unary_fneg_unary_fneg_swap_pred_vec(<2 x float> %x, <2 x float> %y) {
; CHECK-LABEL: @unary_fneg_unary_fneg_swap_pred_vec(
; CHECK-NEXT:    [[CMP:%.*]] = fcmp ninf ogt <2 x float> [[X:%.*]], [[Y:%.*]]
; CHECK-NEXT:    ret <2 x i1> [[CMP]]
;
  %neg1 = fneg <2 x float> %x
  %neg2 = fneg <2 x float> %y
  %cmp = fcmp ninf olt <2 x float> %neg1, %neg2
  ret <2 x i1> %cmp
}

define <2 x i1> @unary_fneg_fneg_swap_pred_vec(<2 x float> %x, <2 x float> %y) {
; CHECK-LABEL: @unary_fneg_fneg_swap_pred_vec(
; CHECK-NEXT:    [[CMP:%.*]] = fcmp ninf ogt <2 x float> [[X:%.*]], [[Y:%.*]]
; CHECK-NEXT:    ret <2 x i1> [[CMP]]
;
  %neg1 = fneg <2 x float> %x
  %neg2 = fsub <2 x float> <float -0.0, float -0.0>, %y
  %cmp = fcmp ninf olt <2 x float> %neg1, %neg2
  ret <2 x i1> %cmp
}

define <2 x i1> @fneg_unary_fneg_swap_pred_vec(<2 x float> %x, <2 x float> %y) {
; CHECK-LABEL: @fneg_unary_fneg_swap_pred_vec(
; CHECK-NEXT:    [[CMP:%.*]] = fcmp ninf ogt <2 x float> [[X:%.*]], [[Y:%.*]]
; CHECK-NEXT:    ret <2 x i1> [[CMP]]
;
  %neg1 = fsub <2 x float> <float -0.0, float -0.0>, %x
  %neg2 = fneg <2 x float> %y
  %cmp = fcmp ninf olt <2 x float> %neg1, %neg2
  ret <2 x i1> %cmp
}

define <2 x i1> @fneg_fneg_swap_pred_vec_undef(<2 x float> %x, <2 x float> %y) {
; CHECK-LABEL: @fneg_fneg_swap_pred_vec_undef(
; CHECK-NEXT:    [[CMP:%.*]] = fcmp ogt <2 x float> [[X:%.*]], [[Y:%.*]]
; CHECK-NEXT:    ret <2 x i1> [[CMP]]
;
  %neg1 = fsub <2 x float> <float -0.0, float undef>, %x
  %neg2 = fsub <2 x float> <float undef, float -0.0>, %y
  %cmp = fcmp olt <2 x float> %neg1, %neg2
  ret <2 x i1> %cmp
}

define <2 x i1> @unary_fneg_fneg_swap_pred_vec_undef(<2 x float> %x, <2 x float> %y) {
; CHECK-LABEL: @unary_fneg_fneg_swap_pred_vec_undef(
; CHECK-NEXT:    [[CMP:%.*]] = fcmp ogt <2 x float> [[X:%.*]], [[Y:%.*]]
; CHECK-NEXT:    ret <2 x i1> [[CMP]]
;
  %neg1 = fneg <2 x float> %x
  %neg2 = fsub <2 x float> <float undef, float -0.0>, %y
  %cmp = fcmp olt <2 x float> %neg1, %neg2
  ret <2 x i1> %cmp
}

define <2 x i1> @fneg_unary_fneg_swap_pred_vec_undef(<2 x float> %x, <2 x float> %y) {
; CHECK-LABEL: @fneg_unary_fneg_swap_pred_vec_undef(
; CHECK-NEXT:    [[CMP:%.*]] = fcmp ogt <2 x float> [[X:%.*]], [[Y:%.*]]
; CHECK-NEXT:    ret <2 x i1> [[CMP]]
;
  %neg1 = fsub <2 x float> <float -0.0, float undef>, %x
  %neg2 = fneg <2 x float> %y
  %cmp = fcmp olt <2 x float> %neg1, %neg2
  ret <2 x i1> %cmp
}

define i1 @test7(float %x) {
; CHECK-LABEL: @test7(
; CHECK-NEXT:    [[CMP:%.*]] = fcmp ogt float [[X:%.*]], 0.000000e+00
; CHECK-NEXT:    ret i1 [[CMP]]
;
  %ext = fpext float %x to ppc_fp128
  %cmp = fcmp ogt ppc_fp128 %ext, 0xM00000000000000000000000000000000
  ret i1 %cmp
}

define float @test8(float %x) {
; CHECK-LABEL: @test8(
; CHECK-NEXT:    [[CMP:%.*]] = fcmp olt float [[X:%.*]], 0.000000e+00
; CHECK-NEXT:    [[CONV2:%.*]] = uitofp i1 [[CMP]] to float
; CHECK-NEXT:    ret float [[CONV2]]
;
  %conv = fpext float %x to double
  %cmp = fcmp olt double %conv, 0.000000e+00
  %conv1 = zext i1 %cmp to i32
  %conv2 = sitofp i32 %conv1 to float
  ret float %conv2
; Float comparison to zero shouldn't cast to double.
}

define i1 @fabs_uge(double %a) {
; CHECK-LABEL: @fabs_uge(
; CHECK-NEXT:    ret i1 true
;
  %call = call double @llvm.fabs.f64(double %a)
  %cmp = fcmp uge double %call, 0.0
  ret i1 %cmp
}

define i1 @fabs_olt(half %a) {
; CHECK-LABEL: @fabs_olt(
; CHECK-NEXT:    ret i1 false
;
  %call = call half @llvm.fabs.f16(half %a)
  %cmp = fcmp olt half %call, 0.0
  ret i1 %cmp
}

define <2 x i1> @fabs_ole(<2 x float> %a) {
; CHECK-LABEL: @fabs_ole(
; CHECK-NEXT:    [[CMP:%.*]] = fcmp ninf oeq <2 x float> [[A:%.*]], zeroinitializer
; CHECK-NEXT:    ret <2 x i1> [[CMP]]
;
  %call = call <2 x float> @llvm.fabs.v2f32(<2 x float> %a)
  %cmp = fcmp ninf ole <2 x float> %call, zeroinitializer
  ret <2 x i1> %cmp
}

define <2 x i1> @fabs_ule(<2 x float> %a) {
; CHECK-LABEL: @fabs_ule(
; CHECK-NEXT:    [[CMP:%.*]] = fcmp ninf arcp ueq <2 x float> [[A:%.*]], zeroinitializer
; CHECK-NEXT:    ret <2 x i1> [[CMP]]
;
  %call = call <2 x float> @llvm.fabs.v2f32(<2 x float> %a)
  %cmp = fcmp ninf arcp ule <2 x float> %call, zeroinitializer
  ret <2 x i1> %cmp
}

define i1 @fabs_ogt(double %a) {
; CHECK-LABEL: @fabs_ogt(
; CHECK-NEXT:    [[CMP:%.*]] = fcmp reassoc one double [[A:%.*]], 0.000000e+00
; CHECK-NEXT:    ret i1 [[CMP]]
;
  %call = call double @llvm.fabs.f64(double %a)
  %cmp = fcmp reassoc ogt double %call, 0.0
  ret i1 %cmp
}

define i1 @fabs_ugt(double %a) {
; CHECK-LABEL: @fabs_ugt(
; CHECK-NEXT:    [[CMP:%.*]] = fcmp reassoc ninf une double [[A:%.*]], 0.000000e+00
; CHECK-NEXT:    ret i1 [[CMP]]
;
  %call = call double @llvm.fabs.f64(double %a)
  %cmp = fcmp ninf reassoc ugt double %call, 0.0
  ret i1 %cmp
}

define i1 @fabs_oge(double %a) {
; CHECK-LABEL: @fabs_oge(
; CHECK-NEXT:    [[CMP:%.*]] = fcmp afn ord double [[A:%.*]], 0.000000e+00
; CHECK-NEXT:    ret i1 [[CMP]]
;
  %call = call double @llvm.fabs.f64(double %a)
  %cmp = fcmp afn oge double %call, 0.0
  ret i1 %cmp
}

define i1 @fabs_ult(double %a) {
; CHECK-LABEL: @fabs_ult(
; CHECK-NEXT:    [[CMP:%.*]] = fcmp reassoc arcp uno double [[A:%.*]], 0.000000e+00
; CHECK-NEXT:    ret i1 [[CMP]]
;
  %call = call double @llvm.fabs.f64(double %a)
  %cmp = fcmp reassoc arcp ult double %call, 0.0
  ret i1 %cmp
}

define <2 x i1> @fabs_ult_nnan(<2 x float> %a) {
; CHECK-LABEL: @fabs_ult_nnan(
; CHECK-NEXT:    ret <2 x i1> zeroinitializer
;
  %call = call <2 x float> @llvm.fabs.v2f32(<2 x float> %a)
  %cmp = fcmp nnan reassoc arcp ult <2 x float> %call, zeroinitializer
  ret <2 x i1> %cmp
}

define i1 @fabs_une(half %a) {
; CHECK-LABEL: @fabs_une(
; CHECK-NEXT:    [[CMP:%.*]] = fcmp ninf une half [[A:%.*]], 0xH0000
; CHECK-NEXT:    ret i1 [[CMP]]
;
  %call = call half @llvm.fabs.f16(half %a)
  %cmp = fcmp ninf une half %call, 0.0
  ret i1 %cmp
}

define i1 @fabs_oeq(double %a) {
; CHECK-LABEL: @fabs_oeq(
; CHECK-NEXT:    [[CMP:%.*]] = fcmp reassoc ninf oeq double [[A:%.*]], 0.000000e+00
; CHECK-NEXT:    ret i1 [[CMP]]
;
  %call = call double @llvm.fabs.f64(double %a)
  %cmp = fcmp ninf reassoc oeq double %call, 0.0
  ret i1 %cmp
}

define i1 @fabs_one(double %a) {
; CHECK-LABEL: @fabs_one(
; CHECK-NEXT:    [[CMP:%.*]] = fcmp fast one double [[A:%.*]], 0.000000e+00
; CHECK-NEXT:    ret i1 [[CMP]]
;
  %call = call double @llvm.fabs.f64(double %a)
  %cmp = fcmp fast one double %call, 0.0
  ret i1 %cmp
}

define <2 x i1> @fabs_ueq(<2 x float> %a) {
; CHECK-LABEL: @fabs_ueq(
; CHECK-NEXT:    [[CMP:%.*]] = fcmp arcp ueq <2 x float> [[A:%.*]], zeroinitializer
; CHECK-NEXT:    ret <2 x i1> [[CMP]]
;
  %call = call <2 x float> @llvm.fabs.v2f32(<2 x float> %a)
  %cmp = fcmp arcp ueq <2 x float> %call, zeroinitializer
  ret <2 x i1> %cmp
}

define <2 x i1> @fabs_ord(<2 x float> %a) {
; CHECK-LABEL: @fabs_ord(
; CHECK-NEXT:    [[CMP:%.*]] = fcmp arcp ord <2 x float> [[A:%.*]], zeroinitializer
; CHECK-NEXT:    ret <2 x i1> [[CMP]]
;
  %call = call <2 x float> @llvm.fabs.v2f32(<2 x float> %a)
  %cmp = fcmp arcp ord <2 x float> %call, zeroinitializer
  ret <2 x i1> %cmp
}

define <2 x i1> @fabs_uno(<2 x float> %a) {
; CHECK-LABEL: @fabs_uno(
; CHECK-NEXT:    [[CMP:%.*]] = fcmp arcp uno <2 x float> [[A:%.*]], zeroinitializer
; CHECK-NEXT:    ret <2 x i1> [[CMP]]
;
  %call = call <2 x float> @llvm.fabs.v2f32(<2 x float> %a)
  %cmp = fcmp arcp uno <2 x float> %call, zeroinitializer
  ret <2 x i1> %cmp
}

; Don't crash.
define i32 @test17(double %a, ptr %p) {
; CHECK-LABEL: @test17(
; CHECK-NEXT:    [[CALL:%.*]] = tail call double [[P:%.*]](double [[A:%.*]])
; CHECK-NEXT:    [[CMP:%.*]] = fcmp ueq double [[CALL]], 0.000000e+00
; CHECK-NEXT:    [[CONV:%.*]] = zext i1 [[CMP]] to i32
; CHECK-NEXT:    ret i32 [[CONV]]
;
  %call = tail call double %p(double %a)
  %cmp = fcmp ueq double %call, 0.000000e+00
  %conv = zext i1 %cmp to i32
  ret i32 %conv
}

; Can fold fcmp with undef on one side by choosing NaN for the undef
define i32 @test18_undef_unordered(float %a) {
; CHECK-LABEL: @test18_undef_unordered(
; CHECK-NEXT:    ret i32 1
;
  %cmp = fcmp ueq float %a, undef
  %conv = zext i1 %cmp to i32
  ret i32 %conv
}
; Can fold fcmp with undef on one side by choosing NaN for the undef
define i32 @test18_undef_ordered(float %a) {
; CHECK-LABEL: @test18_undef_ordered(
; CHECK-NEXT:    ret i32 0
;
  %cmp = fcmp oeq float %a, undef
  %conv = zext i1 %cmp to i32
  ret i32 %conv
}

; Can fold fcmp with undef on both side
;   fcmp u_pred undef, undef -> true
;   fcmp o_pred undef, undef -> false
; because whatever you choose for the first undef
; you can choose NaN for the other undef
define i1 @test19_undef_unordered() {
; CHECK-LABEL: @test19_undef_unordered(
; CHECK-NEXT:    ret i1 true
;
  %cmp = fcmp ueq float undef, undef
  ret i1 %cmp
}

define i1 @test19_undef_ordered() {
; CHECK-LABEL: @test19_undef_ordered(
; CHECK-NEXT:    ret i1 false
;
  %cmp = fcmp oeq float undef, undef
  ret i1 %cmp
}

; Can fold 1.0 / X < 0.0 --> X < 0 with ninf
define i1 @test20_recipX_olt_0(float %X) {
; CHECK-LABEL: @test20_recipX_olt_0(
; CHECK-NEXT:    [[CMP:%.*]] = fcmp ninf olt float [[X:%.*]], 0.000000e+00
; CHECK-NEXT:    ret i1 [[CMP]]
;
  %div = fdiv ninf float 1.0, %X
  %cmp = fcmp ninf olt float %div, 0.0
  ret i1 %cmp
}

; Can fold -2.0 / X <= 0.0 --> X >= 0 with ninf
define i1 @test21_recipX_ole_0(float %X) {
; CHECK-LABEL: @test21_recipX_ole_0(
; CHECK-NEXT:    [[CMP:%.*]] = fcmp ninf oge float [[X:%.*]], 0.000000e+00
; CHECK-NEXT:    ret i1 [[CMP]]
;
  %div = fdiv ninf float -2.0, %X
  %cmp = fcmp ninf ole float %div, 0.0
  ret i1 %cmp
}

; Can fold 2.0 / X > 0.0 --> X > 0 with ninf
define i1 @test22_recipX_ogt_0(float %X) {
; CHECK-LABEL: @test22_recipX_ogt_0(
; CHECK-NEXT:    [[CMP:%.*]] = fcmp ninf ogt float [[X:%.*]], 0.000000e+00
; CHECK-NEXT:    ret i1 [[CMP]]
;
  %div = fdiv ninf float 2.0, %X
  %cmp = fcmp ninf ogt float %div, 0.0
  ret i1 %cmp
}

; Can fold -1.0 / X >= 0.0 --> X <= 0 with ninf
define i1 @test23_recipX_oge_0(float %X) {
; CHECK-LABEL: @test23_recipX_oge_0(
; CHECK-NEXT:    [[CMP:%.*]] = fcmp ninf ole float [[X:%.*]], 0.000000e+00
; CHECK-NEXT:    ret i1 [[CMP]]
;
  %div = fdiv ninf float -1.0, %X
  %cmp = fcmp ninf oge float %div, 0.0
  ret i1 %cmp
}

; Do not fold 1.0 / X > 0.0 when ninf is missing
define i1 @test24_recipX_noninf_cmp(float %X) {
; CHECK-LABEL: @test24_recipX_noninf_cmp(
; CHECK-NEXT:    [[DIV:%.*]] = fdiv ninf float 2.000000e+00, [[X:%.*]]
; CHECK-NEXT:    [[CMP:%.*]] = fcmp ogt float [[DIV]], 0.000000e+00
; CHECK-NEXT:    ret i1 [[CMP]]
;
  %div = fdiv ninf float 2.0, %X
  %cmp = fcmp ogt float %div, 0.0
  ret i1 %cmp
}

; Do not fold 1.0 / X > 0.0 when ninf is missing
define i1 @test25_recipX_noninf_div(float %X) {
; CHECK-LABEL: @test25_recipX_noninf_div(
; CHECK-NEXT:    [[DIV:%.*]] = fdiv float 2.000000e+00, [[X:%.*]]
; CHECK-NEXT:    [[CMP:%.*]] = fcmp ninf ogt float [[DIV]], 0.000000e+00
; CHECK-NEXT:    ret i1 [[CMP]]
;
  %div = fdiv float 2.0, %X
  %cmp = fcmp ninf ogt float %div, 0.0
  ret i1 %cmp
}

; Do not fold 1.0 / X > 0.0 with unordered predicates
define i1 @test26_recipX_unorderd(float %X) {
; CHECK-LABEL: @test26_recipX_unorderd(
; CHECK-NEXT:    [[DIV:%.*]] = fdiv ninf float 2.000000e+00, [[X:%.*]]
; CHECK-NEXT:    [[CMP:%.*]] = fcmp ninf ugt float [[DIV]], 0.000000e+00
; CHECK-NEXT:    ret i1 [[CMP]]
;
  %div = fdiv ninf float 2.0, %X
  %cmp = fcmp ninf ugt float %div, 0.0
  ret i1 %cmp
}

; Fold <-1.0, -1.0> / X > <-0.0, -0.0>
define <2 x i1> @test27_recipX_gt_vecsplat(<2 x float> %X) {
; CHECK-LABEL: @test27_recipX_gt_vecsplat(
; CHECK-NEXT:    [[CMP:%.*]] = fcmp ninf olt <2 x float> [[X:%.*]], zeroinitializer
; CHECK-NEXT:    ret <2 x i1> [[CMP]]
;
  %div = fdiv ninf <2 x float> <float -1.0, float -1.0>, %X
  %cmp = fcmp ninf ogt <2 x float> %div, <float -0.0, float -0.0>
  ret <2 x i1> %cmp
}

define i1 @is_signbit_set(double %x) {
; CHECK-LABEL: @is_signbit_set(
; CHECK-NEXT:    [[TMP1:%.*]] = bitcast double [[X:%.*]] to i64
; CHECK-NEXT:    [[R:%.*]] = icmp slt i64 [[TMP1]], 0
; CHECK-NEXT:    ret i1 [[R]]
;
  %s = call double @llvm.copysign.f64(double 1.0, double %x)
  %r = fcmp olt double %s, 0.0
  ret i1 %r
}

define i1 @is_signbit_set_1(double %x) {
; CHECK-LABEL: @is_signbit_set_1(
; CHECK-NEXT:    [[S:%.*]] = call double @llvm.copysign.f64(double 1.000000e+00, double [[X:%.*]])
; CHECK-NEXT:    [[R:%.*]] = fcmp ult double [[S]], 0.000000e+00
; CHECK-NEXT:    ret i1 [[R]]
;
  %s = call double @llvm.copysign.f64(double 1.0, double %x)
  %r = fcmp ult double %s, 0.0
  ret i1 %r
}

define i1 @is_signbit_set_2(double %x) {
; CHECK-LABEL: @is_signbit_set_2(
; CHECK-NEXT:    [[S:%.*]] = call double @llvm.copysign.f64(double 1.000000e+00, double [[X:%.*]])
; CHECK-NEXT:    [[R:%.*]] = fcmp ole double [[S]], 0.000000e+00
; CHECK-NEXT:    ret i1 [[R]]
;
  %s = call double @llvm.copysign.f64(double 1.0, double %x)
  %r = fcmp ole double %s, 0.0
  ret i1 %r
}

define i1 @is_signbit_set_3(double %x) {
; CHECK-LABEL: @is_signbit_set_3(
; CHECK-NEXT:    [[S:%.*]] = call double @llvm.copysign.f64(double 1.000000e+00, double [[X:%.*]])
; CHECK-NEXT:    [[R:%.*]] = fcmp ule double [[S]], 0.000000e+00
; CHECK-NEXT:    ret i1 [[R]]
;
  %s = call double @llvm.copysign.f64(double 1.0, double %x)
  %r = fcmp ule double %s, 0.0
  ret i1 %r
}

; Vectors are ok; the sign of zero in the compare doesn't matter; the copysign constant can be any non-zero number.

define <2 x i1> @is_signbit_set_anyzero(<2 x double> %x) {
; CHECK-LABEL: @is_signbit_set_anyzero(
; CHECK-NEXT:    [[TMP1:%.*]] = bitcast <2 x double> [[X:%.*]] to <2 x i64>
; CHECK-NEXT:    [[R:%.*]] = icmp slt <2 x i64> [[TMP1]], zeroinitializer
; CHECK-NEXT:    ret <2 x i1> [[R]]
;
  %s = call <2 x double> @llvm.copysign.v2f64(<2 x double> <double 42.0, double 42.0>, <2 x double> %x)
  %r = fcmp olt <2 x double> %s, <double -0.0, double 0.0>
  ret <2 x i1> %r
}

; TODO: Handle different predicates.

define i1 @is_signbit_clear(double %x) {
; CHECK-LABEL: @is_signbit_clear(
; CHECK-NEXT:    [[S:%.*]] = call double @llvm.copysign.f64(double -4.200000e+01, double [[X:%.*]])
; CHECK-NEXT:    [[R:%.*]] = fcmp ogt double [[S]], 0.000000e+00
; CHECK-NEXT:    ret i1 [[R]]
;
  %s = call double @llvm.copysign.f64(double -42.0, double %x)
  %r = fcmp ogt double %s, 0.0
  ret i1 %r
}

define i1 @is_signbit_clear_1(double %x) {
; CHECK-LABEL: @is_signbit_clear_1(
; CHECK-NEXT:    [[S:%.*]] = call double @llvm.copysign.f64(double -4.200000e+01, double [[X:%.*]])
; CHECK-NEXT:    [[R:%.*]] = fcmp ugt double [[S]], 0.000000e+00
; CHECK-NEXT:    ret i1 [[R]]
;
  %s = call double @llvm.copysign.f64(double -42.0, double %x)
  %r = fcmp ugt double %s, 0.0
  ret i1 %r
}

define i1 @is_signbit_clear_2(double %x) {
; CHECK-LABEL: @is_signbit_clear_2(
; CHECK-NEXT:    [[S:%.*]] = call double @llvm.copysign.f64(double -4.200000e+01, double [[X:%.*]])
; CHECK-NEXT:    [[R:%.*]] = fcmp oge double [[S]], 0.000000e+00
; CHECK-NEXT:    ret i1 [[R]]
;
  %s = call double @llvm.copysign.f64(double -42.0, double %x)
  %r = fcmp oge double %s, 0.0
  ret i1 %r
}

define i1 @is_signbit_clear_3(double %x) {
; CHECK-LABEL: @is_signbit_clear_3(
; CHECK-NEXT:    [[S:%.*]] = call double @llvm.copysign.f64(double -4.200000e+01, double [[X:%.*]])
; CHECK-NEXT:    [[R:%.*]] = fcmp uge double [[S]], 0.000000e+00
; CHECK-NEXT:    ret i1 [[R]]
;
  %s = call double @llvm.copysign.f64(double -42.0, double %x)
  %r = fcmp uge double %s, 0.0
  ret i1 %r
}

; Negative test - uses

define i1 @is_signbit_set_extra_use(double %x, ptr %p) {
; CHECK-LABEL: @is_signbit_set_extra_use(
; CHECK-NEXT:    [[S:%.*]] = call double @llvm.copysign.f64(double 1.000000e+00, double [[X:%.*]])
; CHECK-NEXT:    store double [[S]], ptr [[P:%.*]], align 8
; CHECK-NEXT:    [[R:%.*]] = fcmp olt double [[S]], 0.000000e+00
; CHECK-NEXT:    ret i1 [[R]]
;
  %s = call double @llvm.copysign.f64(double 1.0, double %x)
  store double %s, ptr %p
  %r = fcmp olt double %s, 0.0
  ret i1 %r
}

; TODO: Handle non-zero compare constant.

define i1 @is_signbit_clear_nonzero(double %x) {
; CHECK-LABEL: @is_signbit_clear_nonzero(
; CHECK-NEXT:    [[S:%.*]] = call double @llvm.copysign.f64(double -4.200000e+01, double [[X:%.*]])
; CHECK-NEXT:    [[R:%.*]] = fcmp ogt double [[S]], 1.000000e+00
; CHECK-NEXT:    ret i1 [[R]]
;
  %s = call double @llvm.copysign.f64(double -42.0, double %x)
  %r = fcmp ogt double %s, 1.0
  ret i1 %r
}

; TODO: Handle zero copysign constant.

define i1 @is_signbit_set_simplify_zero(double %x) {
; CHECK-LABEL: @is_signbit_set_simplify_zero(
; CHECK-NEXT:    [[S:%.*]] = call double @llvm.copysign.f64(double 0.000000e+00, double [[X:%.*]])
; CHECK-NEXT:    [[R:%.*]] = fcmp ogt double [[S]], 0.000000e+00
; CHECK-NEXT:    ret i1 [[R]]
;
  %s = call double @llvm.copysign.f64(double 0.0, double %x)
  %r = fcmp ogt double %s, 0.0
  ret i1 %r
}

; TODO: Handle NaN copysign constant.

define i1 @is_signbit_set_simplify_nan(double %x) {
; CHECK-LABEL: @is_signbit_set_simplify_nan(
; CHECK-NEXT:    [[S:%.*]] = call double @llvm.copysign.f64(double 0xFFFFFFFFFFFFFFFF, double [[X:%.*]])
; CHECK-NEXT:    [[R:%.*]] = fcmp ogt double [[S]], 0.000000e+00
; CHECK-NEXT:    ret i1 [[R]]
;
  %s = call double @llvm.copysign.f64(double 0xffffffffffffffff, double %x)
  %r = fcmp ogt double %s, 0.0
  ret i1 %r
}

define <2 x i1> @lossy_oeq(<2 x float> %x) {
; CHECK-LABEL: @lossy_oeq(
; CHECK-NEXT:    ret <2 x i1> zeroinitializer
;
  %e = fpext <2 x float> %x to <2 x double>
  %r = fcmp oeq <2 x double> %e, <double 0.1, double 0.1>
  ret <2 x i1> %r
}

define i1 @lossy_one(float %x, ptr %p) {
; CHECK-LABEL: @lossy_one(
; CHECK-NEXT:    [[E:%.*]] = fpext float [[X:%.*]] to double
; CHECK-NEXT:    store double [[E]], ptr [[P:%.*]], align 8
; CHECK-NEXT:    [[R:%.*]] = fcmp ord float [[X]], 0.000000e+00
; CHECK-NEXT:    ret i1 [[R]]
;
  %e = fpext float %x to double
  store double %e, ptr %p
  %r = fcmp one double %e, 0.1
  ret i1 %r
}

define i1 @lossy_ueq(half %x) {
; CHECK-LABEL: @lossy_ueq(
; CHECK-NEXT:    [[R:%.*]] = fcmp uno half [[X:%.*]], 0xH0000
; CHECK-NEXT:    ret i1 [[R]]
;
  %e = fpext half %x to double
  %r = fcmp ueq double %e, 65536.0
  ret i1 %r
}

define i1 @lossy_une(half %x) {
; CHECK-LABEL: @lossy_une(
; CHECK-NEXT:    ret i1 true
;
  %e = fpext half %x to float
  %r = fcmp une float %e, 2049.0
  ret i1 %r
}

define <2 x i1> @lossy_ogt(<2 x float> %x) {
; CHECK-LABEL: @lossy_ogt(
; CHECK-NEXT:    [[E:%.*]] = fpext <2 x float> [[X:%.*]] to <2 x double>
; CHECK-NEXT:    [[R:%.*]] = fcmp ogt <2 x double> [[E]], <double 1.000000e-01, double 1.000000e-01>
; CHECK-NEXT:    ret <2 x i1> [[R]]
;
  %e = fpext <2 x float> %x to <2 x double>
  %r = fcmp ogt <2 x double> %e, <double 0.1, double 0.1>
  ret <2 x i1> %r
}

define i1 @lossy_oge(float %x, ptr %p) {
; CHECK-LABEL: @lossy_oge(
; CHECK-NEXT:    [[E:%.*]] = fpext float [[X:%.*]] to double
; CHECK-NEXT:    store double [[E]], ptr [[P:%.*]], align 8
; CHECK-NEXT:    [[R:%.*]] = fcmp oge double [[E]], 1.000000e-01
; CHECK-NEXT:    ret i1 [[R]]
;
  %e = fpext float %x to double
  store double %e, ptr %p
  %r = fcmp oge double %e, 0.1
  ret i1 %r
}

define i1 @lossy_olt(half %x) {
; CHECK-LABEL: @lossy_olt(
; CHECK-NEXT:    [[E:%.*]] = fpext half [[X:%.*]] to double
; CHECK-NEXT:    [[R:%.*]] = fcmp olt double [[E]], 6.553600e+04
; CHECK-NEXT:    ret i1 [[R]]
;
  %e = fpext half %x to double
  %r = fcmp olt double %e, 65536.0
  ret i1 %r
}

define i1 @lossy_ole(half %x) {
; CHECK-LABEL: @lossy_ole(
; CHECK-NEXT:    [[E:%.*]] = fpext half [[X:%.*]] to float
; CHECK-NEXT:    [[R:%.*]] = fcmp ole float [[E]], 2.049000e+03
; CHECK-NEXT:    ret i1 [[R]]
;
  %e = fpext half %x to float
  %r = fcmp ole float %e, 2049.0
  ret i1 %r
}

define <2 x i1> @lossy_ugt(<2 x float> %x) {
; CHECK-LABEL: @lossy_ugt(
; CHECK-NEXT:    [[E:%.*]] = fpext <2 x float> [[X:%.*]] to <2 x double>
; CHECK-NEXT:    [[R:%.*]] = fcmp ugt <2 x double> [[E]], <double 1.000000e-01, double 1.000000e-01>
; CHECK-NEXT:    ret <2 x i1> [[R]]
;
  %e = fpext <2 x float> %x to <2 x double>
  %r = fcmp ugt <2 x double> %e, <double 0.1, double 0.1>
  ret <2 x i1> %r
}

define i1 @lossy_uge(float %x, ptr %p) {
; CHECK-LABEL: @lossy_uge(
; CHECK-NEXT:    [[E:%.*]] = fpext float [[X:%.*]] to double
; CHECK-NEXT:    store double [[E]], ptr [[P:%.*]], align 8
; CHECK-NEXT:    [[R:%.*]] = fcmp uge double [[E]], 1.000000e-01
; CHECK-NEXT:    ret i1 [[R]]
;
  %e = fpext float %x to double
  store double %e, ptr %p
  %r = fcmp uge double %e, 0.1
  ret i1 %r
}

define i1 @lossy_ult(half %x) {
; CHECK-LABEL: @lossy_ult(
; CHECK-NEXT:    [[E:%.*]] = fpext half [[X:%.*]] to double
; CHECK-NEXT:    [[R:%.*]] = fcmp ult double [[E]], 6.553600e+04
; CHECK-NEXT:    ret i1 [[R]]
;
  %e = fpext half %x to double
  %r = fcmp ult double %e, 65536.0
  ret i1 %r
}

define i1 @lossy_ule(half %x) {
; CHECK-LABEL: @lossy_ule(
; CHECK-NEXT:    [[E:%.*]] = fpext half [[X:%.*]] to float
; CHECK-NEXT:    [[R:%.*]] = fcmp ule float [[E]], 2.049000e+03
; CHECK-NEXT:    ret i1 [[R]]
;
  %e = fpext half %x to float
  %r = fcmp ule float %e, 2049.0
  ret i1 %r
}

define i1 @lossy_ord(half %x) {
; CHECK-LABEL: @lossy_ord(
; CHECK-NEXT:    [[R:%.*]] = fcmp ord half [[X:%.*]], 0xH0000
; CHECK-NEXT:    ret i1 [[R]]
;
  %e = fpext half %x to double
  %r = fcmp ord double %e, 65536.0
  ret i1 %r
}

define i1 @lossy_uno(half %x) {
; CHECK-LABEL: @lossy_uno(
; CHECK-NEXT:    [[R:%.*]] = fcmp uno half [[X:%.*]], 0xH0000
; CHECK-NEXT:    ret i1 [[R]]
;
  %e = fpext half %x to float
  %r = fcmp uno float %e, 2049.0
  ret i1 %r
}

define i1 @fneg_oeq(float %a) {
; CHECK-LABEL: @fneg_oeq(
; CHECK-NEXT:    [[CMP:%.*]] = fcmp oeq float [[A:%.*]], 0.000000e+00
; CHECK-NEXT:    ret i1 [[CMP]]
;
  %fneg = fneg float %a
  %cmp = fcmp oeq float %fneg, %a
  ret i1 %cmp
}

define i1 @fneg_ogt(half %a) {
; CHECK-LABEL: @fneg_ogt(
; CHECK-NEXT:    [[CMP:%.*]] = fcmp fast olt half [[A:%.*]], 0xH0000
; CHECK-NEXT:    ret i1 [[CMP]]
;
  %fneg = fneg half %a
  %cmp = fcmp fast ogt half %fneg, %a
  ret i1 %cmp
}

define <2 x i1> @fneg_oge(<2 x float> %a) {
; CHECK-LABEL: @fneg_oge(
; CHECK-NEXT:    [[CMP:%.*]] = fcmp ole <2 x float> [[A:%.*]], zeroinitializer
; CHECK-NEXT:    ret <2 x i1> [[CMP]]
;
  %fneg = fneg fast <2 x float> %a
  %cmp = fcmp oge <2 x float> %fneg, %a
  ret <2 x i1> %cmp
}

define i1 @fneg_olt(float %a, ptr %q) {
; CHECK-LABEL: @fneg_olt(
; CHECK-NEXT:    [[FNEG:%.*]] = fneg float [[A:%.*]]
; CHECK-NEXT:    store float [[FNEG]], ptr [[Q:%.*]], align 4
; CHECK-NEXT:    [[CMP:%.*]] = fcmp ogt float [[A]], 0.000000e+00
; CHECK-NEXT:    ret i1 [[CMP]]
;
  %fneg = fneg float %a
  store float %fneg, ptr %q
  %cmp = fcmp olt float %fneg, %a
  ret i1 %cmp
}

define i1 @fneg_ole(float %a) {
; CHECK-LABEL: @fneg_ole(
; CHECK-NEXT:    [[CMP:%.*]] = fcmp nsz oge float [[A:%.*]], 0.000000e+00
; CHECK-NEXT:    ret i1 [[CMP]]
;
  %fneg = fneg float %a
  %cmp = fcmp nsz ole float %fneg, %a
  ret i1 %cmp
}

define i1 @fneg_one(float %a) {
; CHECK-LABEL: @fneg_one(
; CHECK-NEXT:    [[CMP:%.*]] = fcmp nnan one float [[A:%.*]], 0.000000e+00
; CHECK-NEXT:    ret i1 [[CMP]]
;
  %fneg = fneg float %a
  %cmp = fcmp nnan one float %fneg, %a
  ret i1 %cmp
}

define i1 @fneg_ord(float %a) {
; CHECK-LABEL: @fneg_ord(
; CHECK-NEXT:    [[CMP:%.*]] = fcmp ninf ord float [[A:%.*]], 0.000000e+00
; CHECK-NEXT:    ret i1 [[CMP]]
;
  %fneg = fneg float %a
  %cmp = fcmp ninf ord float %fneg, %a
  ret i1 %cmp
}

define i1 @fneg_uno(float %a) {
; CHECK-LABEL: @fneg_uno(
; CHECK-NEXT:    [[CMP:%.*]] = fcmp uno float [[A:%.*]], 0.000000e+00
; CHECK-NEXT:    ret i1 [[CMP]]
;
  %fneg = fneg float %a
  %cmp = fcmp uno float %fneg, %a
  ret i1 %cmp
}

define i1 @fneg_ueq(half %a) {
; CHECK-LABEL: @fneg_ueq(
; CHECK-NEXT:    [[CMP:%.*]] = fcmp fast ueq half [[A:%.*]], 0xH0000
; CHECK-NEXT:    ret i1 [[CMP]]
;
  %fneg = fneg half %a
  %cmp = fcmp fast ueq half %fneg, %a
  ret i1 %cmp
}

define <2 x i1> @fneg_ugt(<2 x float> %a) {
; CHECK-LABEL: @fneg_ugt(
; CHECK-NEXT:    [[CMP:%.*]] = fcmp ult <2 x float> [[A:%.*]], zeroinitializer
; CHECK-NEXT:    ret <2 x i1> [[CMP]]
;
  %fneg = fneg fast <2 x float> %a
  %cmp = fcmp ugt <2 x float> %fneg, %a
  ret <2 x i1> %cmp
}

define i1 @fneg_uge(float %a, ptr %q) {
; CHECK-LABEL: @fneg_uge(
; CHECK-NEXT:    [[FNEG:%.*]] = fneg float [[A:%.*]]
; CHECK-NEXT:    store float [[FNEG]], ptr [[Q:%.*]], align 4
; CHECK-NEXT:    [[CMP:%.*]] = fcmp ule float [[A]], 0.000000e+00
; CHECK-NEXT:    ret i1 [[CMP]]
;
  %fneg = fneg float %a
  store float %fneg, ptr %q
  %cmp = fcmp uge float %fneg, %a
  ret i1 %cmp
}

define i1 @fneg_ult(float %a) {
; CHECK-LABEL: @fneg_ult(
; CHECK-NEXT:    [[CMP:%.*]] = fcmp nsz ugt float [[A:%.*]], 0.000000e+00
; CHECK-NEXT:    ret i1 [[CMP]]
;
  %fneg = fneg float %a
  %cmp = fcmp nsz ult float %fneg, %a
  ret i1 %cmp
}

define i1 @fneg_ule(float %a) {
; CHECK-LABEL: @fneg_ule(
; CHECK-NEXT:    [[CMP:%.*]] = fcmp nnan uge float [[A:%.*]], 0.000000e+00
; CHECK-NEXT:    ret i1 [[CMP]]
;
  %fneg = fneg float %a
  %cmp = fcmp nnan ule float %fneg, %a
  ret i1 %cmp
}

define i1 @fneg_une(float %a) {
; CHECK-LABEL: @fneg_une(
; CHECK-NEXT:    [[CMP:%.*]] = fcmp ninf une float [[A:%.*]], 0.000000e+00
; CHECK-NEXT:    ret i1 [[CMP]]
;
  %fneg = fneg float %a
  %cmp = fcmp ninf une float %fneg, %a
  ret i1 %cmp
}

define i1 @fneg_oeq_swap(float %p) {
; CHECK-LABEL: @fneg_oeq_swap(
; CHECK-NEXT:    [[A:%.*]] = fadd float [[P:%.*]], [[P]]
; CHECK-NEXT:    [[CMP:%.*]] = fcmp oeq float [[A]], 0.000000e+00
; CHECK-NEXT:    ret i1 [[CMP]]
;
  %a = fadd float %p, %p ; thwart complexity-based canonicalization
  %fneg = fneg float %a
  %cmp = fcmp oeq float %a, %fneg
  ret i1 %cmp
}

define i1 @fneg_ogt_swap(half %p) {
; CHECK-LABEL: @fneg_ogt_swap(
; CHECK-NEXT:    [[A:%.*]] = fadd half [[P:%.*]], [[P]]
; CHECK-NEXT:    [[CMP:%.*]] = fcmp fast ogt half [[A]], 0xH0000
; CHECK-NEXT:    ret i1 [[CMP]]
;
  %a = fadd half %p, %p ; thwart complexity-based canonicalization
  %fneg = fneg half %a
  %cmp = fcmp fast ogt half %a, %fneg
  ret i1 %cmp
}

define <2 x i1> @fneg_oge_swap(<2 x float> %p) {
; CHECK-LABEL: @fneg_oge_swap(
; CHECK-NEXT:    [[A:%.*]] = fadd <2 x float> [[P:%.*]], [[P]]
; CHECK-NEXT:    [[CMP:%.*]] = fcmp oge <2 x float> [[A]], zeroinitializer
; CHECK-NEXT:    ret <2 x i1> [[CMP]]
;
  %a = fadd <2 x float> %p, %p ; thwart complexity-based canonicalization
  %fneg = fneg fast <2 x float> %a
  %cmp = fcmp oge <2 x float> %a, %fneg
  ret <2 x i1> %cmp
}

define i1 @fneg_olt_swap(float %p, ptr %q) {
; CHECK-LABEL: @fneg_olt_swap(
; CHECK-NEXT:    [[A:%.*]] = fadd float [[P:%.*]], [[P]]
; CHECK-NEXT:    [[FNEG:%.*]] = fneg float [[A]]
; CHECK-NEXT:    store float [[FNEG]], ptr [[Q:%.*]], align 4
; CHECK-NEXT:    [[CMP:%.*]] = fcmp olt float [[A]], 0.000000e+00
; CHECK-NEXT:    ret i1 [[CMP]]
;
  %a = fadd float %p, %p ; thwart complexity-based canonicalization
  %fneg = fneg float %a
  store float %fneg, ptr %q
  %cmp = fcmp olt float %a, %fneg
  ret i1 %cmp
}

define i1 @fneg_ole_swap(float %p) {
; CHECK-LABEL: @fneg_ole_swap(
; CHECK-NEXT:    [[A:%.*]] = fadd float [[P:%.*]], [[P]]
; CHECK-NEXT:    [[CMP:%.*]] = fcmp nsz ole float [[A]], 0.000000e+00
; CHECK-NEXT:    ret i1 [[CMP]]
;
  %a = fadd float %p, %p ; thwart complexity-based canonicalization
  %fneg = fneg float %a
  %cmp = fcmp nsz ole float %a, %fneg
  ret i1 %cmp
}

define i1 @fneg_one_swap(float %p) {
; CHECK-LABEL: @fneg_one_swap(
; CHECK-NEXT:    [[A:%.*]] = fadd float [[P:%.*]], [[P]]
; CHECK-NEXT:    [[CMP:%.*]] = fcmp nnan one float [[A]], 0.000000e+00
; CHECK-NEXT:    ret i1 [[CMP]]
;
  %a = fadd float %p, %p ; thwart complexity-based canonicalization
  %fneg = fneg float %a
  %cmp = fcmp nnan one float %a, %fneg
  ret i1 %cmp
}

define i1 @fneg_ord_swap(float %p) {
; CHECK-LABEL: @fneg_ord_swap(
; CHECK-NEXT:    [[A:%.*]] = fadd float [[P:%.*]], [[P]]
; CHECK-NEXT:    [[CMP:%.*]] = fcmp ninf ord float [[A]], 0.000000e+00
; CHECK-NEXT:    ret i1 [[CMP]]
;
  %a = fadd float %p, %p ; thwart complexity-based canonicalization
  %fneg = fneg float %a
  %cmp = fcmp ninf ord float %a, %fneg
  ret i1 %cmp
}

define i1 @fneg_uno_swap(float %p) {
; CHECK-LABEL: @fneg_uno_swap(
; CHECK-NEXT:    [[A:%.*]] = fadd float [[P:%.*]], [[P]]
; CHECK-NEXT:    [[CMP:%.*]] = fcmp uno float [[A]], 0.000000e+00
; CHECK-NEXT:    ret i1 [[CMP]]
;
  %a = fadd float %p, %p ; thwart complexity-based canonicalization
  %fneg = fneg float %a
  %cmp = fcmp uno float %a, %fneg
  ret i1 %cmp
}

define i1 @fneg_ueq_swap(half %p) {
; CHECK-LABEL: @fneg_ueq_swap(
; CHECK-NEXT:    [[A:%.*]] = fadd half [[P:%.*]], [[P]]
; CHECK-NEXT:    [[CMP:%.*]] = fcmp fast ueq half [[A]], 0xH0000
; CHECK-NEXT:    ret i1 [[CMP]]
;
  %a = fadd half %p, %p ; thwart complexity-based canonicalization
  %fneg = fneg half %a
  %cmp = fcmp fast ueq half %a, %fneg
  ret i1 %cmp
}

define <2 x i1> @fneg_ugt_swap(<2 x float> %p) {
; CHECK-LABEL: @fneg_ugt_swap(
; CHECK-NEXT:    [[A:%.*]] = fadd <2 x float> [[P:%.*]], [[P]]
; CHECK-NEXT:    [[CMP:%.*]] = fcmp ugt <2 x float> [[A]], zeroinitializer
; CHECK-NEXT:    ret <2 x i1> [[CMP]]
;
  %a = fadd <2 x float> %p, %p ; thwart complexity-based canonicalization
  %fneg = fneg fast <2 x float> %a
  %cmp = fcmp ugt <2 x float> %a, %fneg
  ret <2 x i1> %cmp
}

define i1 @fneg_uge_swap(float %p, ptr %q) {
; CHECK-LABEL: @fneg_uge_swap(
; CHECK-NEXT:    [[A:%.*]] = fadd float [[P:%.*]], [[P]]
; CHECK-NEXT:    [[FNEG:%.*]] = fneg float [[A]]
; CHECK-NEXT:    store float [[FNEG]], ptr [[Q:%.*]], align 4
; CHECK-NEXT:    [[CMP:%.*]] = fcmp uge float [[A]], 0.000000e+00
; CHECK-NEXT:    ret i1 [[CMP]]
;
  %a = fadd float %p, %p ; thwart complexity-based canonicalization
  %fneg = fneg float %a
  store float %fneg, ptr %q
  %cmp = fcmp uge float %a, %fneg
  ret i1 %cmp
}

define i1 @fneg_ult_swap(float %p) {
; CHECK-LABEL: @fneg_ult_swap(
; CHECK-NEXT:    [[A:%.*]] = fadd float [[P:%.*]], [[P]]
; CHECK-NEXT:    [[CMP:%.*]] = fcmp nsz ult float [[A]], 0.000000e+00
; CHECK-NEXT:    ret i1 [[CMP]]
;
  %a = fadd float %p, %p ; thwart complexity-based canonicalization
  %fneg = fneg float %a
  %cmp = fcmp nsz ult float %a, %fneg
  ret i1 %cmp
}

define i1 @fneg_ule_swap(float %p) {
; CHECK-LABEL: @fneg_ule_swap(
; CHECK-NEXT:    [[A:%.*]] = fadd float [[P:%.*]], [[P]]
; CHECK-NEXT:    [[CMP:%.*]] = fcmp nnan ule float [[A]], 0.000000e+00
; CHECK-NEXT:    ret i1 [[CMP]]
;
  %a = fadd float %p, %p ; thwart complexity-based canonicalization
  %fneg = fneg float %a
  %cmp = fcmp nnan ule float %a, %fneg
  ret i1 %cmp
}

define i1 @fneg_une_swap(float %p) {
; CHECK-LABEL: @fneg_une_swap(
; CHECK-NEXT:    [[A:%.*]] = fadd float [[P:%.*]], [[P]]
; CHECK-NEXT:    [[CMP:%.*]] = fcmp ninf une float [[A]], 0.000000e+00
; CHECK-NEXT:    ret i1 [[CMP]]
;
  %a = fadd float %p, %p ; thwart complexity-based canonicalization
  %fneg = fneg float %a
  %cmp = fcmp ninf une float %a, %fneg
  ret i1 %cmp
}

define i1 @bitcast_eq0(i32 %x) {
; CHECK-LABEL: @bitcast_eq0(
; CHECK-NEXT:    [[TMP1:%.*]] = and i32 [[X:%.*]], 2147483647
; CHECK-NEXT:    [[R:%.*]] = icmp eq i32 [[TMP1]], 0
; CHECK-NEXT:    ret i1 [[R]]
;
  %f = bitcast i32 %x to float
  %r = fcmp oeq float %f, 0.0
  ret i1 %r
}

define <2 x i1> @bitcast_ne0(<2 x i32> %x) {
; CHECK-LABEL: @bitcast_ne0(
; CHECK-NEXT:    [[TMP1:%.*]] = and <2 x i32> [[X:%.*]], <i32 2147483647, i32 2147483647>
; CHECK-NEXT:    [[R:%.*]] = icmp ne <2 x i32> [[TMP1]], zeroinitializer
; CHECK-NEXT:    ret <2 x i1> [[R]]
;
  %f = bitcast <2 x i32> %x to <2 x float>
  %r = fcmp une <2 x float> %f, <float 0.0, float 0.0>
  ret <2 x i1> %r
}

; negative test - extra use

define i1 @bitcast_eq0_use(i32 %x) {
; CHECK-LABEL: @bitcast_eq0_use(
; CHECK-NEXT:    [[F:%.*]] = bitcast i32 [[X:%.*]] to float
; CHECK-NEXT:    call void @use(float [[F]])
; CHECK-NEXT:    [[R:%.*]] = fcmp oeq float [[F]], 0.000000e+00
; CHECK-NEXT:    ret i1 [[R]]
;
  %f = bitcast i32 %x to float
  call void @use(float %f)
  %r = fcmp oeq float %f, 0.0
  ret i1 %r
}

; negative test - this could be transformed, but requires a new bitcast

define i1 @bitcast_nonint_eq0(<2 x i16> %x) {
; CHECK-LABEL: @bitcast_nonint_eq0(
; CHECK-NEXT:    [[F:%.*]] = bitcast <2 x i16> [[X:%.*]] to float
; CHECK-NEXT:    [[R:%.*]] = fcmp ogt float [[F]], 0.000000e+00
; CHECK-NEXT:    ret i1 [[R]]
;
  %f = bitcast <2 x i16> %x to float
  %r = fcmp ogt float %f, 0.0
  ret i1 %r
}

; negative test - wrong predicate

define i1 @bitcast_gt0(i32 %x) {
; CHECK-LABEL: @bitcast_gt0(
; CHECK-NEXT:    [[F:%.*]] = bitcast i32 [[X:%.*]] to float
; CHECK-NEXT:    [[R:%.*]] = fcmp ogt float [[F]], 0.000000e+00
; CHECK-NEXT:    ret i1 [[R]]
;
  %f = bitcast i32 %x to float
  %r = fcmp ogt float %f, 0.0
  ret i1 %r
}

; negative test - this could be transformed, but requires a new bitcast

define <1 x i1> @bitcast_1vec_eq0(i32 %x) {
; CHECK-LABEL: @bitcast_1vec_eq0(
; CHECK-NEXT:    [[F:%.*]] = bitcast i32 [[X:%.*]] to <1 x float>
; CHECK-NEXT:    [[CMP:%.*]] = fcmp oeq <1 x float> [[F]], zeroinitializer
; CHECK-NEXT:    ret <1 x i1> [[CMP]]
;
  %f = bitcast i32 %x to <1 x float>
  %cmp = fcmp oeq <1 x float> %f, zeroinitializer
  ret <1 x i1> %cmp
}