@@ -14,6 +14,7 @@ declare float @exp2f(float)
14
14
declare double @llvm.exp2.f64 (double )
15
15
declare float @llvm.exp2.f32 (float )
16
16
declare <2 x float > @llvm.exp2.v2f32 (<2 x float >)
17
+ declare fp128 @exp2l (fp128 )
17
18
18
19
19
20
; Check exp2(sitofp(x)) -> ldexp(1.0, sext(x)).
@@ -330,3 +331,97 @@ define <2 x float> @sitofp_vector_intrinsic_with_FMF(<2 x i8> %x) {
330
331
%r = call nnan <2 x float > @llvm.exp2.v2f32 (<2 x float > %s )
331
332
ret <2 x float > %r
332
333
}
334
+
335
+ define double @test_readonly_exp2_f64_of_sitofp (i32 %x ) {
336
+ ; LDEXP32-LABEL: @test_readonly_exp2_f64_of_sitofp(
337
+ ; LDEXP32-NEXT: [[LDEXP:%.*]] = call double @ldexp(double 1.000000e+00, i32 [[X:%.*]])
338
+ ; LDEXP32-NEXT: ret double [[LDEXP]]
339
+ ;
340
+ ; LDEXP16-LABEL: @test_readonly_exp2_f64_of_sitofp(
341
+ ; LDEXP16-NEXT: [[CONV:%.*]] = sitofp i32 [[X:%.*]] to double
342
+ ; LDEXP16-NEXT: [[RET:%.*]] = call double @exp2(double [[CONV]]) #[[ATTR2:[0-9]+]]
343
+ ; LDEXP16-NEXT: ret double [[RET]]
344
+ ;
345
+ ; NOLDEXPF-LABEL: @test_readonly_exp2_f64_of_sitofp(
346
+ ; NOLDEXPF-NEXT: [[LDEXP:%.*]] = call double @ldexp(double 1.000000e+00, i32 [[X:%.*]])
347
+ ; NOLDEXPF-NEXT: ret double [[LDEXP]]
348
+ ;
349
+ ; NOLDEXP-LABEL: @test_readonly_exp2_f64_of_sitofp(
350
+ ; NOLDEXP-NEXT: [[CONV:%.*]] = sitofp i32 [[X:%.*]] to double
351
+ ; NOLDEXP-NEXT: [[RET:%.*]] = call double @exp2(double [[CONV]]) #[[ATTR1:[0-9]+]]
352
+ ; NOLDEXP-NEXT: ret double [[RET]]
353
+ ;
354
+ %conv = sitofp i32 %x to double
355
+ %ret = call double @exp2 (double %conv ) readonly
356
+ ret double %ret
357
+ }
358
+
359
+ define float @test_readonly_exp2f_f32_of_sitofp (i32 %x ) {
360
+ ; LDEXP32-LABEL: @test_readonly_exp2f_f32_of_sitofp(
361
+ ; LDEXP32-NEXT: [[LDEXPF:%.*]] = call float @ldexpf(float 1.000000e+00, i32 [[X:%.*]])
362
+ ; LDEXP32-NEXT: ret float [[LDEXPF]]
363
+ ;
364
+ ; LDEXP16-LABEL: @test_readonly_exp2f_f32_of_sitofp(
365
+ ; LDEXP16-NEXT: [[CONV:%.*]] = sitofp i32 [[X:%.*]] to float
366
+ ; LDEXP16-NEXT: [[RET:%.*]] = call float @exp2f(float [[CONV]]) #[[ATTR2]]
367
+ ; LDEXP16-NEXT: ret float [[RET]]
368
+ ;
369
+ ; NOLDEXPF-LABEL: @test_readonly_exp2f_f32_of_sitofp(
370
+ ; NOLDEXPF-NEXT: [[CONV:%.*]] = sitofp i32 [[X:%.*]] to float
371
+ ; NOLDEXPF-NEXT: [[RET:%.*]] = call float @exp2f(float [[CONV]]) #[[ATTR2:[0-9]+]]
372
+ ; NOLDEXPF-NEXT: ret float [[RET]]
373
+ ;
374
+ ; NOLDEXP-LABEL: @test_readonly_exp2f_f32_of_sitofp(
375
+ ; NOLDEXP-NEXT: [[CONV:%.*]] = sitofp i32 [[X:%.*]] to float
376
+ ; NOLDEXP-NEXT: [[RET:%.*]] = call float @exp2f(float [[CONV]]) #[[ATTR1]]
377
+ ; NOLDEXP-NEXT: ret float [[RET]]
378
+ ;
379
+ %conv = sitofp i32 %x to float
380
+ %ret = call float @exp2f (float %conv ) readonly
381
+ ret float %ret
382
+ }
383
+
384
+ define fp128 @test_readonly_exp2l_fp128_of_sitofp (i32 %x ) {
385
+ ; LDEXP32-LABEL: @test_readonly_exp2l_fp128_of_sitofp(
386
+ ; LDEXP32-NEXT: [[LDEXPL:%.*]] = call fp128 @ldexpl(fp128 0xL00000000000000003FFF000000000000, i32 [[X:%.*]])
387
+ ; LDEXP32-NEXT: ret fp128 [[LDEXPL]]
388
+ ;
389
+ ; LDEXP16-LABEL: @test_readonly_exp2l_fp128_of_sitofp(
390
+ ; LDEXP16-NEXT: [[CONV:%.*]] = sitofp i32 [[X:%.*]] to fp128
391
+ ; LDEXP16-NEXT: [[RET:%.*]] = call fp128 @exp2l(fp128 [[CONV]]) #[[ATTR2]]
392
+ ; LDEXP16-NEXT: ret fp128 [[RET]]
393
+ ;
394
+ ; NOLDEXP-LABEL: @test_readonly_exp2l_fp128_of_sitofp(
395
+ ; NOLDEXP-NEXT: [[CONV:%.*]] = sitofp i32 [[X:%.*]] to fp128
396
+ ; NOLDEXP-NEXT: [[RET:%.*]] = call fp128 @exp2l(fp128 [[CONV]]) #[[ATTR1]]
397
+ ; NOLDEXP-NEXT: ret fp128 [[RET]]
398
+ ;
399
+ %conv = sitofp i32 %x to fp128
400
+ %ret = call fp128 @exp2l (fp128 %conv ) readonly
401
+ ret fp128 %ret
402
+ }
403
+
404
+ define float @test_readonly_exp2f_f32_of_sitofp_flags (i32 %x ) {
405
+ ; LDEXP32-LABEL: @test_readonly_exp2f_f32_of_sitofp_flags(
406
+ ; LDEXP32-NEXT: [[LDEXPF:%.*]] = call nnan ninf float @ldexpf(float 1.000000e+00, i32 [[X:%.*]])
407
+ ; LDEXP32-NEXT: ret float [[LDEXPF]]
408
+ ;
409
+ ; LDEXP16-LABEL: @test_readonly_exp2f_f32_of_sitofp_flags(
410
+ ; LDEXP16-NEXT: [[CONV:%.*]] = sitofp i32 [[X:%.*]] to float
411
+ ; LDEXP16-NEXT: [[RET:%.*]] = call nnan ninf float @exp2f(float [[CONV]]) #[[ATTR2]]
412
+ ; LDEXP16-NEXT: ret float [[RET]]
413
+ ;
414
+ ; NOLDEXPF-LABEL: @test_readonly_exp2f_f32_of_sitofp_flags(
415
+ ; NOLDEXPF-NEXT: [[CONV:%.*]] = sitofp i32 [[X:%.*]] to float
416
+ ; NOLDEXPF-NEXT: [[RET:%.*]] = call nnan ninf float @exp2f(float [[CONV]]) #[[ATTR2]]
417
+ ; NOLDEXPF-NEXT: ret float [[RET]]
418
+ ;
419
+ ; NOLDEXP-LABEL: @test_readonly_exp2f_f32_of_sitofp_flags(
420
+ ; NOLDEXP-NEXT: [[CONV:%.*]] = sitofp i32 [[X:%.*]] to float
421
+ ; NOLDEXP-NEXT: [[RET:%.*]] = call nnan ninf float @exp2f(float [[CONV]]) #[[ATTR1]]
422
+ ; NOLDEXP-NEXT: ret float [[RET]]
423
+ ;
424
+ %conv = sitofp i32 %x to float
425
+ %ret = call nnan ninf float @exp2f (float %conv ) readonly
426
+ ret float %ret
427
+ }
0 commit comments