@@ -14,6 +14,7 @@ declare float @exp2f(float)
1414declare double @llvm.exp2.f64 (double )
1515declare float @llvm.exp2.f32 (float )
1616declare <2 x float > @llvm.exp2.v2f32 (<2 x float >)
17+ declare fp128 @exp2l (fp128 )
1718
1819
1920; Check exp2(sitofp(x)) -> ldexp(1.0, sext(x)).
@@ -227,18 +228,18 @@ define float @test_simplify8(i8 zeroext %x) {
227228define double @test_simplify9 (i8 zeroext %x ) {
228229; LDEXP32-LABEL: @test_simplify9(
229230; LDEXP32-NEXT: [[TMP1:%.*]] = zext i8 [[X:%.*]] to i32
230- ; LDEXP32-NEXT: [[LDEXP :%.*]] = call double @ldexp(double 1.000000e+00, i32 [[TMP1]])
231- ; LDEXP32-NEXT: ret double [[LDEXP ]]
231+ ; LDEXP32-NEXT: [[RET :%.*]] = call double @llvm. ldexp.f64.i32 (double 1.000000e+00, i32 [[TMP1]])
232+ ; LDEXP32-NEXT: ret double [[RET ]]
232233;
233234; LDEXP16-LABEL: @test_simplify9(
234235; LDEXP16-NEXT: [[TMP1:%.*]] = zext i8 [[X:%.*]] to i16
235- ; LDEXP16-NEXT: [[LDEXP :%.*]] = call double @ldexp(double 1.000000e+00, i16 [[TMP1]])
236- ; LDEXP16-NEXT: ret double [[LDEXP ]]
236+ ; LDEXP16-NEXT: [[RET :%.*]] = call double @llvm. ldexp.f64.i16 (double 1.000000e+00, i16 [[TMP1]])
237+ ; LDEXP16-NEXT: ret double [[RET ]]
237238;
238239; NOLDEXPF-LABEL: @test_simplify9(
239240; NOLDEXPF-NEXT: [[TMP1:%.*]] = zext i8 [[X:%.*]] to i32
240- ; NOLDEXPF-NEXT: [[LDEXP :%.*]] = call double @ldexp(double 1.000000e+00, i32 [[TMP1]])
241- ; NOLDEXPF-NEXT: ret double [[LDEXP ]]
241+ ; NOLDEXPF-NEXT: [[RET :%.*]] = call double @llvm. ldexp.f64.i32 (double 1.000000e+00, i32 [[TMP1]])
242+ ; NOLDEXPF-NEXT: ret double [[RET ]]
242243;
243244; NOLDEXP-LABEL: @test_simplify9(
244245; NOLDEXP-NEXT: [[CONV:%.*]] = uitofp i8 [[X:%.*]] to double
@@ -253,13 +254,13 @@ define double @test_simplify9(i8 zeroext %x) {
253254define float @test_simplify10 (i8 zeroext %x ) {
254255; LDEXP32-LABEL: @test_simplify10(
255256; LDEXP32-NEXT: [[TMP1:%.*]] = zext i8 [[X:%.*]] to i32
256- ; LDEXP32-NEXT: [[LDEXPF :%.*]] = call float @ldexpf (float 1.000000e+00, i32 [[TMP1]])
257- ; LDEXP32-NEXT: ret float [[LDEXPF ]]
257+ ; LDEXP32-NEXT: [[RET :%.*]] = call float @llvm.ldexp.f32.i32 (float 1.000000e+00, i32 [[TMP1]])
258+ ; LDEXP32-NEXT: ret float [[RET ]]
258259;
259260; LDEXP16-LABEL: @test_simplify10(
260261; LDEXP16-NEXT: [[TMP1:%.*]] = zext i8 [[X:%.*]] to i16
261- ; LDEXP16-NEXT: [[LDEXPF :%.*]] = call float @ldexpf (float 1.000000e+00, i16 [[TMP1]])
262- ; LDEXP16-NEXT: ret float [[LDEXPF ]]
262+ ; LDEXP16-NEXT: [[RET :%.*]] = call float @llvm.ldexp.f32.i16 (float 1.000000e+00, i16 [[TMP1]])
263+ ; LDEXP16-NEXT: ret float [[RET ]]
263264;
264265; NOLDEXPF-LABEL: @test_simplify10(
265266; NOLDEXPF-NEXT: [[CONV:%.*]] = uitofp i8 [[X:%.*]] to float
@@ -279,13 +280,13 @@ define float @test_simplify10(i8 zeroext %x) {
279280define float @sitofp_scalar_intrinsic_with_FMF (i8 %x ) {
280281; LDEXP32-LABEL: @sitofp_scalar_intrinsic_with_FMF(
281282; LDEXP32-NEXT: [[TMP1:%.*]] = sext i8 [[X:%.*]] to i32
282- ; LDEXP32-NEXT: [[LDEXPF :%.*]] = tail call nnan float @ldexpf (float 1.000000e+00, i32 [[TMP1]])
283- ; LDEXP32-NEXT: ret float [[LDEXPF ]]
283+ ; LDEXP32-NEXT: [[R :%.*]] = tail call nnan float @llvm.ldexp.f32.i32 (float 1.000000e+00, i32 [[TMP1]])
284+ ; LDEXP32-NEXT: ret float [[R ]]
284285;
285286; LDEXP16-LABEL: @sitofp_scalar_intrinsic_with_FMF(
286287; LDEXP16-NEXT: [[TMP1:%.*]] = sext i8 [[X:%.*]] to i16
287- ; LDEXP16-NEXT: [[LDEXPF :%.*]] = tail call nnan float @ldexpf (float 1.000000e+00, i16 [[TMP1]])
288- ; LDEXP16-NEXT: ret float [[LDEXPF ]]
288+ ; LDEXP16-NEXT: [[R :%.*]] = tail call nnan float @llvm.ldexp.f32.i16 (float 1.000000e+00, i16 [[TMP1]])
289+ ; LDEXP16-NEXT: ret float [[R ]]
289290;
290291; NOLDEXPF-LABEL: @sitofp_scalar_intrinsic_with_FMF(
291292; NOLDEXPF-NEXT: [[S:%.*]] = sitofp i8 [[X:%.*]] to float
@@ -330,3 +331,97 @@ define <2 x float> @sitofp_vector_intrinsic_with_FMF(<2 x i8> %x) {
330331 %r = call nnan <2 x float > @llvm.exp2.v2f32 (<2 x float > %s )
331332 ret <2 x float > %r
332333}
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