-
Notifications
You must be signed in to change notification settings - Fork 15.3k
[SimplifyLibCalls] Add f128 type for merging sqrt into the power of exp #112373
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
base: main
Are you sure you want to change the base?
Changes from all commits
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
| Original file line number | Diff line number | Diff line change |
|---|---|---|
|
|
@@ -201,6 +201,25 @@ define <2 x float> @sqrt_exp_vec(<2 x float> %x) { | |
| ret <2 x float> %res | ||
| } | ||
|
|
||
| define dso_local fp128 @sqrt_exp_long_double(fp128 %x, fp128 %y) { | ||
|
Contributor
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Don't need dso_local |
||
| ; CHECK-LABEL: @sqrt_exp_long_double( | ||
| ; CHECK-NEXT: entry: | ||
| ; CHECK-NEXT: [[MERGED_SQRT:%.*]] = fmul fast fp128 [[X:%.*]], 0xL00000000000000003FFE000000000000 | ||
| ; CHECK-NEXT: [[TMP0:%.*]] = call fast fp128 @llvm.exp.f128(fp128 [[MERGED_SQRT]]) | ||
| ; CHECK-NEXT: [[MERGED_SQRT1:%.*]] = fmul fast fp128 [[Y:%.*]], 0xL00000000000000003FFE000000000000 | ||
| ; CHECK-NEXT: [[TMP1:%.*]] = call fast fp128 @llvm.exp2.f128(fp128 [[MERGED_SQRT1]]) | ||
| ; CHECK-NEXT: [[ADD:%.*]] = fadd fast fp128 [[TMP0]], [[TMP1]] | ||
| ; CHECK-NEXT: ret fp128 [[ADD]] | ||
| ; | ||
| entry: | ||
| %0 = call fast fp128 @llvm.exp.f128(fp128 %x) | ||
| %1 = call fast fp128 @llvm.sqrt.f128(fp128 %0) | ||
| %2 = call fast fp128 @llvm.exp2.f128(fp128 %y) | ||
| %3 = call fast fp128 @llvm.sqrt.f128(fp128 %2) | ||
| %add = fadd fast fp128 %1, %3 | ||
|
Comment on lines
+215
to
+219
Contributor
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Test the different cases in different functions. Use minimal fast math flags, this looks like it only requires reassoc. Add an additional test which shows the preservation behavior of other fast math flags. Also test the same situation with equivalent library calls instead of intrinsics (and the mixed intrinsic + libcall case) |
||
| ret fp128 %add | ||
| } | ||
|
|
||
| declare i32 @foo(double) | ||
| declare double @sqrt(double) readnone | ||
| declare float @sqrtf(float) | ||
|
|
@@ -212,3 +231,6 @@ declare double @exp2(double) | |
| declare double @exp10(double) | ||
| declare <2 x float> @llvm.exp.v2f32(<2 x float>) | ||
| declare <2 x float> @llvm.sqrt.v2f32(<2 x float>) | ||
| declare fp128 @llvm.exp.f128(fp128) | ||
| declare fp128 @llvm.sqrt.f128(fp128) | ||
| declare fp128 @llvm.exp2.f128(fp128) | ||
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
This intrinsic->intrinsic transform really shouldn't depend on the libcall availability...