@@ -1342,6 +1342,19 @@ define float @test_fabs_used_by_fpop_nsz(float %x, float %y) {
1342
1342
ret float %add
1343
1343
}
1344
1344
1345
+ define float @test_fabs_used_by_fcopysign_mag (float %x , float %y ) {
1346
+ ; CHECK-LABEL: @test_fabs_used_by_fcopysign_mag(
1347
+ ; CHECK-NEXT: [[COPYSIGN:%.*]] = call float @llvm.copysign.f32(float [[X:%.*]], float [[Y:%.*]])
1348
+ ; CHECK-NEXT: ret float [[COPYSIGN]]
1349
+ ;
1350
+ %cmp = fcmp oge float %x , 0 .000000e+00
1351
+ %neg = fneg float %x
1352
+ %sel = select i1 %cmp , float %x , float %neg
1353
+ %copysign = call float @llvm.copysign.f32 (float %sel , float %y )
1354
+ ret float %copysign
1355
+ }
1356
+
1357
+
1345
1358
; Negative tests
1346
1359
1347
1360
define float @test_fabs_used_by_fpop_nnan (float %x , float %y ) {
@@ -1375,3 +1388,63 @@ define i1 @test_fabs_used_by_fcmp_multiuse(float %x, float %y) {
1375
1388
call void @use (float %sel )
1376
1389
ret i1 %cmp2
1377
1390
}
1391
+
1392
+ define float @test_fabs_used_by_fcopysign_sign (float %x , float %y ) {
1393
+ ; CHECK-LABEL: @test_fabs_used_by_fcopysign_sign(
1394
+ ; CHECK-NEXT: [[CMP:%.*]] = fcmp oge float [[X:%.*]], 0.000000e+00
1395
+ ; CHECK-NEXT: [[NEG:%.*]] = fneg float [[X]]
1396
+ ; CHECK-NEXT: [[SEL:%.*]] = select i1 [[CMP]], float [[X]], float [[NEG]]
1397
+ ; CHECK-NEXT: [[COPYSIGN:%.*]] = call float @llvm.copysign.f32(float [[Y:%.*]], float [[SEL]])
1398
+ ; CHECK-NEXT: ret float [[COPYSIGN]]
1399
+ ;
1400
+ %cmp = fcmp oge float %x , 0 .000000e+00
1401
+ %neg = fneg float %x
1402
+ %sel = select i1 %cmp , float %x , float %neg
1403
+ %copysign = call float @llvm.copysign.f32 (float %y , float %sel )
1404
+ ret float %copysign
1405
+ }
1406
+
1407
+ define float @test_fabs_used_by_maxnum (float %x , float %y ) {
1408
+ ; CHECK-LABEL: @test_fabs_used_by_maxnum(
1409
+ ; CHECK-NEXT: [[CMP:%.*]] = fcmp oge float [[X:%.*]], 0.000000e+00
1410
+ ; CHECK-NEXT: [[NEG:%.*]] = fneg float [[X]]
1411
+ ; CHECK-NEXT: [[SEL:%.*]] = select i1 [[CMP]], float [[X]], float [[NEG]]
1412
+ ; CHECK-NEXT: [[MAX:%.*]] = call float @llvm.maxnum.f32(float [[Y:%.*]], float [[SEL]])
1413
+ ; CHECK-NEXT: ret float [[MAX]]
1414
+ ;
1415
+ %cmp = fcmp oge float %x , 0 .000000e+00
1416
+ %neg = fneg float %x
1417
+ %sel = select i1 %cmp , float %x , float %neg
1418
+ %max = call float @llvm.maxnum.f32 (float %y , float %sel )
1419
+ ret float %max
1420
+ }
1421
+
1422
+ define float @test_fabs_used_by_canonicalize (float %x ) {
1423
+ ; CHECK-LABEL: @test_fabs_used_by_canonicalize(
1424
+ ; CHECK-NEXT: [[CMP:%.*]] = fcmp oge float [[X:%.*]], 0.000000e+00
1425
+ ; CHECK-NEXT: [[NEG:%.*]] = fneg float [[X]]
1426
+ ; CHECK-NEXT: [[SEL:%.*]] = select i1 [[CMP]], float [[X]], float [[NEG]]
1427
+ ; CHECK-NEXT: [[CANON:%.*]] = call float @llvm.canonicalize.f32(float [[SEL]])
1428
+ ; CHECK-NEXT: ret float [[CANON]]
1429
+ ;
1430
+ %cmp = fcmp oge float %x , 0 .000000e+00
1431
+ %neg = fneg float %x
1432
+ %sel = select i1 %cmp , float %x , float %neg
1433
+ %canon = call float @llvm.canonicalize.f32 (float %sel )
1434
+ ret float %canon
1435
+ }
1436
+
1437
+ define float @test_fabs_used_by_select (float %x , i1 %cond ) {
1438
+ ; CHECK-LABEL: @test_fabs_used_by_select(
1439
+ ; CHECK-NEXT: [[CMP:%.*]] = fcmp oge float [[X:%.*]], 0.000000e+00
1440
+ ; CHECK-NEXT: [[NEG:%.*]] = fneg float [[X]]
1441
+ ; CHECK-NEXT: [[SEL:%.*]] = select i1 [[CMP]], float [[X]], float [[NEG]]
1442
+ ; CHECK-NEXT: [[SEL2:%.*]] = select i1 [[COND:%.*]], float [[SEL]], float 0.000000e+00
1443
+ ; CHECK-NEXT: ret float [[SEL2]]
1444
+ ;
1445
+ %cmp = fcmp oge float %x , 0 .000000e+00
1446
+ %neg = fneg float %x
1447
+ %sel = select i1 %cmp , float %x , float %neg
1448
+ %sel2 = select i1 %cond , float %sel , float 0 .000000e+00
1449
+ ret float %sel2
1450
+ }
0 commit comments