brintos

brintos / llvm-project-archived public Read only

0
0
Text · 21.6 KiB · e9f6feb Raw
737 lines · plain
1; NOTE: Assertions have been autogenerated by utils/update_test_checks.py2; RUN: opt < %s -passes=instcombine -S | FileCheck %s3 4; This is https://bugs.llvm.org/show_bug.cgi?id=366825 6; In *all* of these, sitofp and bitcast should be instcombine'd out.7; "sle 0" is canonicalized to "slt 1",  so we don't test "sle 0" case.8; "sge 0" is canonicalized to "sgt -1", so we don't test "sge 0" case.9; "sge 1" is canonicalized to "sgt 0",  so we don't test "sge 1" case.10; "sle -1" is canonicalized to "slt 0", so we don't test "sle -1" case.11 12define i1 @i32_cast_cmp_eq_int_0_sitofp_float(i32 %i) {13; CHECK-LABEL: @i32_cast_cmp_eq_int_0_sitofp_float(14; CHECK-NEXT:    [[CMP:%.*]] = icmp eq i32 [[I:%.*]], 015; CHECK-NEXT:    ret i1 [[CMP]]16;17  %f = sitofp i32 %i to float18  %b = bitcast float %f to i3219  %cmp = icmp eq i32 %b, 020  ret i1 %cmp21}22 23define i1 @i32_cast_cmp_ne_int_0_sitofp_float(i32 %i) {24; CHECK-LABEL: @i32_cast_cmp_ne_int_0_sitofp_float(25; CHECK-NEXT:    [[CMP:%.*]] = icmp ne i32 [[I:%.*]], 026; CHECK-NEXT:    ret i1 [[CMP]]27;28  %f = sitofp i32 %i to float29  %b = bitcast float %f to i3230  %cmp = icmp ne i32 %b, 031  ret i1 %cmp32}33 34define i1 @i32_cast_cmp_slt_int_0_sitofp_float(i32 %i) {35; CHECK-LABEL: @i32_cast_cmp_slt_int_0_sitofp_float(36; CHECK-NEXT:    [[CMP:%.*]] = icmp slt i32 [[I:%.*]], 037; CHECK-NEXT:    ret i1 [[CMP]]38;39  %f = sitofp i32 %i to float40  %b = bitcast float %f to i3241  %cmp = icmp slt i32 %b, 042  ret i1 %cmp43}44 45define i1 @i32_cast_cmp_sgt_int_0_sitofp_float(i32 %i) {46; CHECK-LABEL: @i32_cast_cmp_sgt_int_0_sitofp_float(47; CHECK-NEXT:    [[CMP:%.*]] = icmp sgt i32 [[I:%.*]], 048; CHECK-NEXT:    ret i1 [[CMP]]49;50  %f = sitofp i32 %i to float51  %b = bitcast float %f to i3252  %cmp = icmp sgt i32 %b, 053  ret i1 %cmp54}55 56define i1 @i32_cast_cmp_slt_int_1_sitofp_float(i32 %i) {57; CHECK-LABEL: @i32_cast_cmp_slt_int_1_sitofp_float(58; CHECK-NEXT:    [[CMP:%.*]] = icmp slt i32 [[I:%.*]], 159; CHECK-NEXT:    ret i1 [[CMP]]60;61  %f = sitofp i32 %i to float62  %b = bitcast float %f to i3263  %cmp = icmp slt i32 %b, 164  ret i1 %cmp65}66 67define i1 @i32_cast_cmp_sgt_int_m1_sitofp_float(i32 %i) {68; CHECK-LABEL: @i32_cast_cmp_sgt_int_m1_sitofp_float(69; CHECK-NEXT:    [[CMP:%.*]] = icmp sgt i32 [[I:%.*]], -170; CHECK-NEXT:    ret i1 [[CMP]]71;72  %f = sitofp i32 %i to float73  %b = bitcast float %f to i3274  %cmp = icmp sgt i32 %b, -175  ret i1 %cmp76}77 78define i1 @i32_cast_cmp_eq_int_0_sitofp_double(i32 %i) {79; CHECK-LABEL: @i32_cast_cmp_eq_int_0_sitofp_double(80; CHECK-NEXT:    [[CMP:%.*]] = icmp eq i32 [[I:%.*]], 081; CHECK-NEXT:    ret i1 [[CMP]]82;83  %f = sitofp i32 %i to double84  %b = bitcast double %f to i6485  %cmp = icmp eq i64 %b, 086  ret i1 %cmp87}88 89define i1 @i32_cast_cmp_ne_int_0_sitofp_double(i32 %i) {90; CHECK-LABEL: @i32_cast_cmp_ne_int_0_sitofp_double(91; CHECK-NEXT:    [[CMP:%.*]] = icmp ne i32 [[I:%.*]], 092; CHECK-NEXT:    ret i1 [[CMP]]93;94  %f = sitofp i32 %i to double95  %b = bitcast double %f to i6496  %cmp = icmp ne i64 %b, 097  ret i1 %cmp98}99 100define i1 @i32_cast_cmp_slt_int_0_sitofp_double(i32 %i) {101; CHECK-LABEL: @i32_cast_cmp_slt_int_0_sitofp_double(102; CHECK-NEXT:    [[CMP:%.*]] = icmp slt i32 [[I:%.*]], 0103; CHECK-NEXT:    ret i1 [[CMP]]104;105  %f = sitofp i32 %i to double106  %b = bitcast double %f to i64107  %cmp = icmp slt i64 %b, 0108  ret i1 %cmp109}110 111define i1 @i32_cast_cmp_sgt_int_0_sitofp_double(i32 %i) {112; CHECK-LABEL: @i32_cast_cmp_sgt_int_0_sitofp_double(113; CHECK-NEXT:    [[CMP:%.*]] = icmp sgt i32 [[I:%.*]], 0114; CHECK-NEXT:    ret i1 [[CMP]]115;116  %f = sitofp i32 %i to double117  %b = bitcast double %f to i64118  %cmp = icmp sgt i64 %b, 0119  ret i1 %cmp120}121 122define i1 @i32_cast_cmp_slt_int_1_sitofp_double(i32 %i) {123; CHECK-LABEL: @i32_cast_cmp_slt_int_1_sitofp_double(124; CHECK-NEXT:    [[CMP:%.*]] = icmp slt i32 [[I:%.*]], 1125; CHECK-NEXT:    ret i1 [[CMP]]126;127  %f = sitofp i32 %i to double128  %b = bitcast double %f to i64129  %cmp = icmp slt i64 %b, 1130  ret i1 %cmp131}132 133define i1 @i32_cast_cmp_sgt_int_m1_sitofp_double(i32 %i) {134; CHECK-LABEL: @i32_cast_cmp_sgt_int_m1_sitofp_double(135; CHECK-NEXT:    [[CMP:%.*]] = icmp sgt i32 [[I:%.*]], -1136; CHECK-NEXT:    ret i1 [[CMP]]137;138  %f = sitofp i32 %i to double139  %b = bitcast double %f to i64140  %cmp = icmp sgt i64 %b, -1141  ret i1 %cmp142}143 144define i1 @i32_cast_cmp_eq_int_0_sitofp_half(i32 %i) {145; CHECK-LABEL: @i32_cast_cmp_eq_int_0_sitofp_half(146; CHECK-NEXT:    [[CMP:%.*]] = icmp eq i32 [[I:%.*]], 0147; CHECK-NEXT:    ret i1 [[CMP]]148;149  %f = sitofp i32 %i to half150  %b = bitcast half %f to i16151  %cmp = icmp eq i16 %b, 0152  ret i1 %cmp153}154 155define i1 @i32_cast_cmp_ne_int_0_sitofp_half(i32 %i) {156; CHECK-LABEL: @i32_cast_cmp_ne_int_0_sitofp_half(157; CHECK-NEXT:    [[CMP:%.*]] = icmp ne i32 [[I:%.*]], 0158; CHECK-NEXT:    ret i1 [[CMP]]159;160  %f = sitofp i32 %i to half161  %b = bitcast half %f to i16162  %cmp = icmp ne i16 %b, 0163  ret i1 %cmp164}165 166define i1 @i32_cast_cmp_slt_int_0_sitofp_half(i32 %i) {167; CHECK-LABEL: @i32_cast_cmp_slt_int_0_sitofp_half(168; CHECK-NEXT:    [[CMP:%.*]] = icmp slt i32 [[I:%.*]], 0169; CHECK-NEXT:    ret i1 [[CMP]]170;171  %f = sitofp i32 %i to half172  %b = bitcast half %f to i16173  %cmp = icmp slt i16 %b, 0174  ret i1 %cmp175}176 177define i1 @i32_cast_cmp_sgt_int_0_sitofp_half(i32 %i) {178; CHECK-LABEL: @i32_cast_cmp_sgt_int_0_sitofp_half(179; CHECK-NEXT:    [[CMP:%.*]] = icmp sgt i32 [[I:%.*]], 0180; CHECK-NEXT:    ret i1 [[CMP]]181;182  %f = sitofp i32 %i to half183  %b = bitcast half %f to i16184  %cmp = icmp sgt i16 %b, 0185  ret i1 %cmp186}187 188define i1 @i32_cast_cmp_slt_int_1_sitofp_half(i32 %i) {189; CHECK-LABEL: @i32_cast_cmp_slt_int_1_sitofp_half(190; CHECK-NEXT:    [[CMP:%.*]] = icmp slt i32 [[I:%.*]], 1191; CHECK-NEXT:    ret i1 [[CMP]]192;193  %f = sitofp i32 %i to half194  %b = bitcast half %f to i16195  %cmp = icmp slt i16 %b, 1196  ret i1 %cmp197}198 199define i1 @i32_cast_cmp_sgt_int_m1_sitofp_half(i32 %i) {200; CHECK-LABEL: @i32_cast_cmp_sgt_int_m1_sitofp_half(201; CHECK-NEXT:    [[CMP:%.*]] = icmp sgt i32 [[I:%.*]], -1202; CHECK-NEXT:    ret i1 [[CMP]]203;204  %f = sitofp i32 %i to half205  %b = bitcast half %f to i16206  %cmp = icmp sgt i16 %b, -1207  ret i1 %cmp208}209 210define i1 @i64_cast_cmp_eq_int_0_sitofp_float(i64 %i) {211; CHECK-LABEL: @i64_cast_cmp_eq_int_0_sitofp_float(212; CHECK-NEXT:    [[CMP:%.*]] = icmp eq i64 [[I:%.*]], 0213; CHECK-NEXT:    ret i1 [[CMP]]214;215  %f = sitofp i64 %i to float216  %b = bitcast float %f to i32217  %cmp = icmp eq i32 %b, 0218  ret i1 %cmp219}220 221define i1 @i64_cast_cmp_ne_int_0_sitofp_float(i64 %i) {222; CHECK-LABEL: @i64_cast_cmp_ne_int_0_sitofp_float(223; CHECK-NEXT:    [[CMP:%.*]] = icmp ne i64 [[I:%.*]], 0224; CHECK-NEXT:    ret i1 [[CMP]]225;226  %f = sitofp i64 %i to float227  %b = bitcast float %f to i32228  %cmp = icmp ne i32 %b, 0229  ret i1 %cmp230}231 232define i1 @i64_cast_cmp_slt_int_0_sitofp_float(i64 %i) {233; CHECK-LABEL: @i64_cast_cmp_slt_int_0_sitofp_float(234; CHECK-NEXT:    [[CMP:%.*]] = icmp slt i64 [[I:%.*]], 0235; CHECK-NEXT:    ret i1 [[CMP]]236;237  %f = sitofp i64 %i to float238  %b = bitcast float %f to i32239  %cmp = icmp slt i32 %b, 0240  ret i1 %cmp241}242 243define i1 @i64_cast_cmp_sgt_int_0_sitofp_float(i64 %i) {244; CHECK-LABEL: @i64_cast_cmp_sgt_int_0_sitofp_float(245; CHECK-NEXT:    [[CMP:%.*]] = icmp sgt i64 [[I:%.*]], 0246; CHECK-NEXT:    ret i1 [[CMP]]247;248  %f = sitofp i64 %i to float249  %b = bitcast float %f to i32250  %cmp = icmp sgt i32 %b, 0251  ret i1 %cmp252}253 254define i1 @i64_cast_cmp_slt_int_1_sitofp_float(i64 %i) {255; CHECK-LABEL: @i64_cast_cmp_slt_int_1_sitofp_float(256; CHECK-NEXT:    [[CMP:%.*]] = icmp slt i64 [[I:%.*]], 1257; CHECK-NEXT:    ret i1 [[CMP]]258;259  %f = sitofp i64 %i to float260  %b = bitcast float %f to i32261  %cmp = icmp slt i32 %b, 1262  ret i1 %cmp263}264 265define i1 @i64_cast_cmp_sgt_int_m1_sitofp_float(i64 %i) {266; CHECK-LABEL: @i64_cast_cmp_sgt_int_m1_sitofp_float(267; CHECK-NEXT:    [[CMP:%.*]] = icmp sgt i64 [[I:%.*]], -1268; CHECK-NEXT:    ret i1 [[CMP]]269;270  %f = sitofp i64 %i to float271  %b = bitcast float %f to i32272  %cmp = icmp sgt i32 %b, -1273  ret i1 %cmp274}275 276define i1 @i64_cast_cmp_eq_int_0_sitofp_double(i64 %i) {277; CHECK-LABEL: @i64_cast_cmp_eq_int_0_sitofp_double(278; CHECK-NEXT:    [[CMP:%.*]] = icmp eq i64 [[I:%.*]], 0279; CHECK-NEXT:    ret i1 [[CMP]]280;281  %f = sitofp i64 %i to double282  %b = bitcast double %f to i64283  %cmp = icmp eq i64 %b, 0284  ret i1 %cmp285}286 287define i1 @i64_cast_cmp_ne_int_0_sitofp_double(i64 %i) {288; CHECK-LABEL: @i64_cast_cmp_ne_int_0_sitofp_double(289; CHECK-NEXT:    [[CMP:%.*]] = icmp ne i64 [[I:%.*]], 0290; CHECK-NEXT:    ret i1 [[CMP]]291;292  %f = sitofp i64 %i to double293  %b = bitcast double %f to i64294  %cmp = icmp ne i64 %b, 0295  ret i1 %cmp296}297 298define i1 @i64_cast_cmp_slt_int_0_sitofp_double(i64 %i) {299; CHECK-LABEL: @i64_cast_cmp_slt_int_0_sitofp_double(300; CHECK-NEXT:    [[CMP:%.*]] = icmp slt i64 [[I:%.*]], 0301; CHECK-NEXT:    ret i1 [[CMP]]302;303  %f = sitofp i64 %i to double304  %b = bitcast double %f to i64305  %cmp = icmp slt i64 %b, 0306  ret i1 %cmp307}308 309define i1 @i64_cast_cmp_sgt_int_0_sitofp_double(i64 %i) {310; CHECK-LABEL: @i64_cast_cmp_sgt_int_0_sitofp_double(311; CHECK-NEXT:    [[CMP:%.*]] = icmp sgt i64 [[I:%.*]], 0312; CHECK-NEXT:    ret i1 [[CMP]]313;314  %f = sitofp i64 %i to double315  %b = bitcast double %f to i64316  %cmp = icmp sgt i64 %b, 0317  ret i1 %cmp318}319 320define i1 @i64_cast_cmp_slt_int_1_sitofp_double(i64 %i) {321; CHECK-LABEL: @i64_cast_cmp_slt_int_1_sitofp_double(322; CHECK-NEXT:    [[CMP:%.*]] = icmp slt i64 [[I:%.*]], 1323; CHECK-NEXT:    ret i1 [[CMP]]324;325  %f = sitofp i64 %i to double326  %b = bitcast double %f to i64327  %cmp = icmp slt i64 %b, 1328  ret i1 %cmp329}330 331define i1 @i64_cast_cmp_sgt_int_m1_sitofp_double(i64 %i) {332; CHECK-LABEL: @i64_cast_cmp_sgt_int_m1_sitofp_double(333; CHECK-NEXT:    [[CMP:%.*]] = icmp sgt i64 [[I:%.*]], -1334; CHECK-NEXT:    ret i1 [[CMP]]335;336  %f = sitofp i64 %i to double337  %b = bitcast double %f to i64338  %cmp = icmp sgt i64 %b, -1339  ret i1 %cmp340}341 342define i1 @i64_cast_cmp_eq_int_0_sitofp_half(i64 %i) {343; CHECK-LABEL: @i64_cast_cmp_eq_int_0_sitofp_half(344; CHECK-NEXT:    [[CMP:%.*]] = icmp eq i64 [[I:%.*]], 0345; CHECK-NEXT:    ret i1 [[CMP]]346;347  %f = sitofp i64 %i to half348  %b = bitcast half %f to i16349  %cmp = icmp eq i16 %b, 0350  ret i1 %cmp351}352 353define i1 @i64_cast_cmp_ne_int_0_sitofp_half(i64 %i) {354; CHECK-LABEL: @i64_cast_cmp_ne_int_0_sitofp_half(355; CHECK-NEXT:    [[CMP:%.*]] = icmp ne i64 [[I:%.*]], 0356; CHECK-NEXT:    ret i1 [[CMP]]357;358  %f = sitofp i64 %i to half359  %b = bitcast half %f to i16360  %cmp = icmp ne i16 %b, 0361  ret i1 %cmp362}363 364define i1 @i64_cast_cmp_slt_int_0_sitofp_half(i64 %i) {365; CHECK-LABEL: @i64_cast_cmp_slt_int_0_sitofp_half(366; CHECK-NEXT:    [[CMP:%.*]] = icmp slt i64 [[I:%.*]], 0367; CHECK-NEXT:    ret i1 [[CMP]]368;369  %f = sitofp i64 %i to half370  %b = bitcast half %f to i16371  %cmp = icmp slt i16 %b, 0372  ret i1 %cmp373}374 375define i1 @i64_cast_cmp_sgt_int_0_sitofp_half(i64 %i) {376; CHECK-LABEL: @i64_cast_cmp_sgt_int_0_sitofp_half(377; CHECK-NEXT:    [[CMP:%.*]] = icmp sgt i64 [[I:%.*]], 0378; CHECK-NEXT:    ret i1 [[CMP]]379;380  %f = sitofp i64 %i to half381  %b = bitcast half %f to i16382  %cmp = icmp sgt i16 %b, 0383  ret i1 %cmp384}385 386define i1 @i64_cast_cmp_slt_int_1_sitofp_half(i64 %i) {387; CHECK-LABEL: @i64_cast_cmp_slt_int_1_sitofp_half(388; CHECK-NEXT:    [[CMP:%.*]] = icmp slt i64 [[I:%.*]], 1389; CHECK-NEXT:    ret i1 [[CMP]]390;391  %f = sitofp i64 %i to half392  %b = bitcast half %f to i16393  %cmp = icmp slt i16 %b, 1394  ret i1 %cmp395}396 397define i1 @i64_cast_cmp_sgt_int_m1_sitofp_half(i64 %i) {398; CHECK-LABEL: @i64_cast_cmp_sgt_int_m1_sitofp_half(399; CHECK-NEXT:    [[CMP:%.*]] = icmp sgt i64 [[I:%.*]], -1400; CHECK-NEXT:    ret i1 [[CMP]]401;402  %f = sitofp i64 %i to half403  %b = bitcast half %f to i16404  %cmp = icmp sgt i16 %b, -1405  ret i1 %cmp406}407 408define i1 @i16_cast_cmp_eq_int_0_sitofp_float(i16 %i) {409; CHECK-LABEL: @i16_cast_cmp_eq_int_0_sitofp_float(410; CHECK-NEXT:    [[CMP:%.*]] = icmp eq i16 [[I:%.*]], 0411; CHECK-NEXT:    ret i1 [[CMP]]412;413  %f = sitofp i16 %i to float414  %b = bitcast float %f to i32415  %cmp = icmp eq i32 %b, 0416  ret i1 %cmp417}418 419define i1 @i16_cast_cmp_ne_int_0_sitofp_float(i16 %i) {420; CHECK-LABEL: @i16_cast_cmp_ne_int_0_sitofp_float(421; CHECK-NEXT:    [[CMP:%.*]] = icmp ne i16 [[I:%.*]], 0422; CHECK-NEXT:    ret i1 [[CMP]]423;424  %f = sitofp i16 %i to float425  %b = bitcast float %f to i32426  %cmp = icmp ne i32 %b, 0427  ret i1 %cmp428}429 430define i1 @i16_cast_cmp_slt_int_0_sitofp_float(i16 %i) {431; CHECK-LABEL: @i16_cast_cmp_slt_int_0_sitofp_float(432; CHECK-NEXT:    [[CMP:%.*]] = icmp slt i16 [[I:%.*]], 0433; CHECK-NEXT:    ret i1 [[CMP]]434;435  %f = sitofp i16 %i to float436  %b = bitcast float %f to i32437  %cmp = icmp slt i32 %b, 0438  ret i1 %cmp439}440 441define i1 @i16_cast_cmp_sgt_int_0_sitofp_float(i16 %i) {442; CHECK-LABEL: @i16_cast_cmp_sgt_int_0_sitofp_float(443; CHECK-NEXT:    [[CMP:%.*]] = icmp sgt i16 [[I:%.*]], 0444; CHECK-NEXT:    ret i1 [[CMP]]445;446  %f = sitofp i16 %i to float447  %b = bitcast float %f to i32448  %cmp = icmp sgt i32 %b, 0449  ret i1 %cmp450}451 452define i1 @i16_cast_cmp_slt_int_1_sitofp_float(i16 %i) {453; CHECK-LABEL: @i16_cast_cmp_slt_int_1_sitofp_float(454; CHECK-NEXT:    [[CMP:%.*]] = icmp slt i16 [[I:%.*]], 1455; CHECK-NEXT:    ret i1 [[CMP]]456;457  %f = sitofp i16 %i to float458  %b = bitcast float %f to i32459  %cmp = icmp slt i32 %b, 1460  ret i1 %cmp461}462 463define i1 @i16_cast_cmp_sgt_int_m1_sitofp_float(i16 %i) {464; CHECK-LABEL: @i16_cast_cmp_sgt_int_m1_sitofp_float(465; CHECK-NEXT:    [[CMP:%.*]] = icmp sgt i16 [[I:%.*]], -1466; CHECK-NEXT:    ret i1 [[CMP]]467;468  %f = sitofp i16 %i to float469  %b = bitcast float %f to i32470  %cmp = icmp sgt i32 %b, -1471  ret i1 %cmp472}473 474define i1 @i16_cast_cmp_eq_int_0_sitofp_double(i16 %i) {475; CHECK-LABEL: @i16_cast_cmp_eq_int_0_sitofp_double(476; CHECK-NEXT:    [[CMP:%.*]] = icmp eq i16 [[I:%.*]], 0477; CHECK-NEXT:    ret i1 [[CMP]]478;479  %f = sitofp i16 %i to double480  %b = bitcast double %f to i64481  %cmp = icmp eq i64 %b, 0482  ret i1 %cmp483}484 485define i1 @i16_cast_cmp_ne_int_0_sitofp_double(i16 %i) {486; CHECK-LABEL: @i16_cast_cmp_ne_int_0_sitofp_double(487; CHECK-NEXT:    [[CMP:%.*]] = icmp ne i16 [[I:%.*]], 0488; CHECK-NEXT:    ret i1 [[CMP]]489;490  %f = sitofp i16 %i to double491  %b = bitcast double %f to i64492  %cmp = icmp ne i64 %b, 0493  ret i1 %cmp494}495 496define i1 @i16_cast_cmp_slt_int_0_sitofp_double(i16 %i) {497; CHECK-LABEL: @i16_cast_cmp_slt_int_0_sitofp_double(498; CHECK-NEXT:    [[CMP:%.*]] = icmp slt i16 [[I:%.*]], 0499; CHECK-NEXT:    ret i1 [[CMP]]500;501  %f = sitofp i16 %i to double502  %b = bitcast double %f to i64503  %cmp = icmp slt i64 %b, 0504  ret i1 %cmp505}506 507define i1 @i16_cast_cmp_sgt_int_0_sitofp_double(i16 %i) {508; CHECK-LABEL: @i16_cast_cmp_sgt_int_0_sitofp_double(509; CHECK-NEXT:    [[CMP:%.*]] = icmp sgt i16 [[I:%.*]], 0510; CHECK-NEXT:    ret i1 [[CMP]]511;512  %f = sitofp i16 %i to double513  %b = bitcast double %f to i64514  %cmp = icmp sgt i64 %b, 0515  ret i1 %cmp516}517 518define i1 @i16_cast_cmp_slt_int_1_sitofp_double(i16 %i) {519; CHECK-LABEL: @i16_cast_cmp_slt_int_1_sitofp_double(520; CHECK-NEXT:    [[CMP:%.*]] = icmp slt i16 [[I:%.*]], 1521; CHECK-NEXT:    ret i1 [[CMP]]522;523  %f = sitofp i16 %i to double524  %b = bitcast double %f to i64525  %cmp = icmp slt i64 %b, 1526  ret i1 %cmp527}528 529define i1 @i16_cast_cmp_sgt_int_m1_sitofp_double(i16 %i) {530; CHECK-LABEL: @i16_cast_cmp_sgt_int_m1_sitofp_double(531; CHECK-NEXT:    [[CMP:%.*]] = icmp sgt i16 [[I:%.*]], -1532; CHECK-NEXT:    ret i1 [[CMP]]533;534  %f = sitofp i16 %i to double535  %b = bitcast double %f to i64536  %cmp = icmp sgt i64 %b, -1537  ret i1 %cmp538}539 540define i1 @i16_cast_cmp_eq_int_0_sitofp_half(i16 %i) {541; CHECK-LABEL: @i16_cast_cmp_eq_int_0_sitofp_half(542; CHECK-NEXT:    [[CMP:%.*]] = icmp eq i16 [[I:%.*]], 0543; CHECK-NEXT:    ret i1 [[CMP]]544;545  %f = sitofp i16 %i to half546  %b = bitcast half %f to i16547  %cmp = icmp eq i16 %b, 0548  ret i1 %cmp549}550 551define i1 @i16_cast_cmp_ne_int_0_sitofp_half(i16 %i) {552; CHECK-LABEL: @i16_cast_cmp_ne_int_0_sitofp_half(553; CHECK-NEXT:    [[CMP:%.*]] = icmp ne i16 [[I:%.*]], 0554; CHECK-NEXT:    ret i1 [[CMP]]555;556  %f = sitofp i16 %i to half557  %b = bitcast half %f to i16558  %cmp = icmp ne i16 %b, 0559  ret i1 %cmp560}561 562define i1 @i16_cast_cmp_slt_int_0_sitofp_half(i16 %i) {563; CHECK-LABEL: @i16_cast_cmp_slt_int_0_sitofp_half(564; CHECK-NEXT:    [[CMP:%.*]] = icmp slt i16 [[I:%.*]], 0565; CHECK-NEXT:    ret i1 [[CMP]]566;567  %f = sitofp i16 %i to half568  %b = bitcast half %f to i16569  %cmp = icmp slt i16 %b, 0570  ret i1 %cmp571}572 573define i1 @i16_cast_cmp_sgt_int_0_sitofp_half(i16 %i) {574; CHECK-LABEL: @i16_cast_cmp_sgt_int_0_sitofp_half(575; CHECK-NEXT:    [[CMP:%.*]] = icmp sgt i16 [[I:%.*]], 0576; CHECK-NEXT:    ret i1 [[CMP]]577;578  %f = sitofp i16 %i to half579  %b = bitcast half %f to i16580  %cmp = icmp sgt i16 %b, 0581  ret i1 %cmp582}583 584define i1 @i16_cast_cmp_slt_int_1_sitofp_half(i16 %i) {585; CHECK-LABEL: @i16_cast_cmp_slt_int_1_sitofp_half(586; CHECK-NEXT:    [[CMP:%.*]] = icmp slt i16 [[I:%.*]], 1587; CHECK-NEXT:    ret i1 [[CMP]]588;589  %f = sitofp i16 %i to half590  %b = bitcast half %f to i16591  %cmp = icmp slt i16 %b, 1592  ret i1 %cmp593}594 595define i1 @i16_cast_cmp_sgt_int_m1_sitofp_half(i16 %i) {596; CHECK-LABEL: @i16_cast_cmp_sgt_int_m1_sitofp_half(597; CHECK-NEXT:    [[CMP:%.*]] = icmp sgt i16 [[I:%.*]], -1598; CHECK-NEXT:    ret i1 [[CMP]]599;600  %f = sitofp i16 %i to half601  %b = bitcast half %f to i16602  %cmp = icmp sgt i16 %b, -1603  ret i1 %cmp604}605 606; Verify that vector types and vector constants including poison elements are transformed too.607 608define <3 x i1> @i32_cast_cmp_ne_int_0_sitofp_double_vec(<3 x i32> %i) {609; CHECK-LABEL: @i32_cast_cmp_ne_int_0_sitofp_double_vec(610; CHECK-NEXT:    [[CMP:%.*]] = icmp ne <3 x i32> [[I:%.*]], zeroinitializer611; CHECK-NEXT:    ret <3 x i1> [[CMP]]612;613  %f = sitofp <3 x i32> %i to  <3 x double>614  %b = bitcast <3 x double> %f to <3 x i64>615  %cmp = icmp ne <3 x i64> %b, <i64 0, i64 0, i64 0>616  ret <3 x i1> %cmp617}618 619; TODO: Can we propagate the constant vector with poison element?620 621define <3 x i1> @i32_cast_cmp_eq_int_0_sitofp_float_vec_poison(<3 x i32> %i) {622; CHECK-LABEL: @i32_cast_cmp_eq_int_0_sitofp_float_vec_poison(623; CHECK-NEXT:    [[CMP:%.*]] = icmp eq <3 x i32> [[I:%.*]], zeroinitializer624; CHECK-NEXT:    ret <3 x i1> [[CMP]]625;626  %f = sitofp <3 x i32> %i to  <3 x float>627  %b = bitcast <3 x float> %f to <3 x i32>628  %cmp = icmp eq <3 x i32> %b, <i32 0, i32 poison, i32 0>629  ret <3 x i1> %cmp630}631 632define <3 x i1> @i64_cast_cmp_slt_int_1_sitofp_half_vec_poison(<3 x i64> %i) {633; CHECK-LABEL: @i64_cast_cmp_slt_int_1_sitofp_half_vec_poison(634; CHECK-NEXT:    [[CMP:%.*]] = icmp slt <3 x i64> [[I:%.*]], splat (i64 1)635; CHECK-NEXT:    ret <3 x i1> [[CMP]]636;637  %f = sitofp <3 x i64> %i to  <3 x half>638  %b = bitcast <3 x half> %f to <3 x i16>639  %cmp = icmp slt <3 x i16> %b, <i16 1, i16 poison, i16 1>640  ret <3 x i1> %cmp641}642 643define <3 x i1> @i16_cast_cmp_sgt_int_m1_sitofp_float_vec_poison(<3 x i16> %i) {644; CHECK-LABEL: @i16_cast_cmp_sgt_int_m1_sitofp_float_vec_poison(645; CHECK-NEXT:    [[CMP:%.*]] = icmp sgt <3 x i16> [[I:%.*]], splat (i16 -1)646; CHECK-NEXT:    ret <3 x i1> [[CMP]]647;648  %f = sitofp <3 x i16> %i to  <3 x float>649  %b = bitcast <3 x float> %f to <3 x i32>650  %cmp = icmp sgt <3 x i32> %b, <i32 -1, i32 poison, i32 -1>651  ret <3 x i1> %cmp652}653 654; Verify that the various forms of this transform are not applied when the655; bitcast changes the number of vector elements:656;   icmp (bitcast ([su]itofp X)), Y -> icmp X, Y657 658define <6 x i1> @i16_cast_cmp_sgt_int_m1_bitcast_vector_num_elements_sitofp(<3 x i16> %i) {659; CHECK-LABEL: @i16_cast_cmp_sgt_int_m1_bitcast_vector_num_elements_sitofp(660; CHECK-NEXT:    [[F:%.*]] = sitofp <3 x i16> [[I:%.*]] to <3 x float>661; CHECK-NEXT:    [[B:%.*]] = bitcast <3 x float> [[F]] to <6 x i16>662; CHECK-NEXT:    [[CMP:%.*]] = icmp sgt <6 x i16> [[B]], splat (i16 -1)663; CHECK-NEXT:    ret <6 x i1> [[CMP]]664;665  %f = sitofp <3 x i16> %i to  <3 x float>666  %b = bitcast <3 x float> %f to <6 x i16>667  %cmp = icmp sgt <6 x i16> %b, <i16 -1, i16 -1, i16 -1, i16 -1, i16 -1, i16 -1>668  ret <6 x i1> %cmp669}670 671define i1 @i16_cast_cmp_sgt_int_m1_bitcast_vector_to_scalar_sitofp(<3 x i16> %i) {672; CHECK-LABEL: @i16_cast_cmp_sgt_int_m1_bitcast_vector_to_scalar_sitofp(673; CHECK-NEXT:    [[F:%.*]] = sitofp <3 x i16> [[I:%.*]] to <3 x float>674; CHECK-NEXT:    [[B:%.*]] = bitcast <3 x float> [[F]] to i96675; CHECK-NEXT:    [[CMP:%.*]] = icmp sgt i96 [[B]], -1676; CHECK-NEXT:    ret i1 [[CMP]]677;678  %f = sitofp <3 x i16> %i to  <3 x float>679  %b = bitcast <3 x float> %f to i96680  %cmp = icmp sgt i96 %b, -1681  ret i1 %cmp682}683 684 685define <6 x i1> @i16_cast_cmp_eq_int_0_bitcast_vector_num_elements_uitofp(<3 x i16> %i) {686; CHECK-LABEL: @i16_cast_cmp_eq_int_0_bitcast_vector_num_elements_uitofp(687; CHECK-NEXT:    [[F:%.*]] = uitofp <3 x i16> [[I:%.*]] to <3 x float>688; CHECK-NEXT:    [[B:%.*]] = bitcast <3 x float> [[F]] to <6 x i16>689; CHECK-NEXT:    [[CMP:%.*]] = icmp eq <6 x i16> [[B]], zeroinitializer690; CHECK-NEXT:    ret <6 x i1> [[CMP]]691;692  %f = uitofp <3 x i16> %i to <3 x float>693  %b = bitcast <3 x float> %f to <6 x i16>694  %cmp = icmp eq <6 x i16> %b, <i16 0, i16 0, i16 0, i16 0, i16 0, i16 0>695  ret <6 x i1> %cmp696}697 698define i1 @i16_cast_cmp_eq_int_0_bitcast_vector_to_scalar_uitofp(<3 x i16> %i) {699; CHECK-LABEL: @i16_cast_cmp_eq_int_0_bitcast_vector_to_scalar_uitofp(700; CHECK-NEXT:    [[F:%.*]] = uitofp <3 x i16> [[I:%.*]] to <3 x float>701; CHECK-NEXT:    [[B:%.*]] = bitcast <3 x float> [[F]] to i96702; CHECK-NEXT:    [[CMP:%.*]] = icmp eq i96 [[B]], 0703; CHECK-NEXT:    ret i1 [[CMP]]704;705  %f = uitofp <3 x i16> %i to <3 x float>706  %b = bitcast <3 x float> %f to i96707  %cmp = icmp eq i96 %b, 0708  ret i1 %cmp709}710 711; Don't crash trying to fold scalar <-> vector bitcast.712 713define <1 x i1> @PR55516(i64 %x) {714; CHECK-LABEL: @PR55516(715; CHECK-NEXT:    [[T0:%.*]] = sitofp i64 [[X:%.*]] to double716; CHECK-NEXT:    [[BC:%.*]] = bitcast double [[T0]] to <1 x i64>717; CHECK-NEXT:    [[R:%.*]] = icmp eq <1 x i64> [[BC]], zeroinitializer718; CHECK-NEXT:    ret <1 x i1> [[R]]719;720  %t0 = sitofp i64 %x to double721  %bc = bitcast double %t0 to <1 x i64>722  %r = icmp eq <1 x i64> %bc, zeroinitializer723  ret <1 x i1> %r724}725 726define i1 @PR55516_alt(<1 x i64> %x) {727; CHECK-LABEL: @PR55516_alt(728; CHECK-NEXT:    [[TMP1:%.*]] = extractelement <1 x i64> [[X:%.*]], i64 0729; CHECK-NEXT:    [[R:%.*]] = icmp eq i64 [[TMP1]], 0730; CHECK-NEXT:    ret i1 [[R]]731;732  %t0 = sitofp <1 x i64> %x to <1 x double>733  %bc = bitcast <1 x double> %t0 to i64734  %r = icmp eq i64 %bc, zeroinitializer735  ret i1 %r736}737