Skip to content

Commit e8fbefe

Browse files
authored
[TLI] Add basic support for remquo libcall (#99611)
This patch adds basic support for `remquo`. Constant folding support will be submitted in a subsequent patch. Related issue: #99497
1 parent 270f5e4 commit e8fbefe

File tree

6 files changed

+50
-4
lines changed

6 files changed

+50
-4
lines changed

llvm/include/llvm/Analysis/TargetLibraryInfo.def

Lines changed: 15 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1953,6 +1953,21 @@ TLI_DEFINE_ENUM_INTERNAL(remainderl)
19531953
TLI_DEFINE_STRING_INTERNAL("remainderl")
19541954
TLI_DEFINE_SIG_INTERNAL(LDbl, LDbl, LDbl)
19551955

1956+
/// double remquo(double x, double y, int *quo);
1957+
TLI_DEFINE_ENUM_INTERNAL(remquo)
1958+
TLI_DEFINE_STRING_INTERNAL("remquo")
1959+
TLI_DEFINE_SIG_INTERNAL(Dbl, Dbl, Dbl, Ptr)
1960+
1961+
/// float remquof(float x, float y, int *quo);
1962+
TLI_DEFINE_ENUM_INTERNAL(remquof)
1963+
TLI_DEFINE_STRING_INTERNAL("remquof")
1964+
TLI_DEFINE_SIG_INTERNAL(Flt, Flt, Flt, Ptr)
1965+
1966+
/// long double remquol(long double x, long double y, int *quo);
1967+
TLI_DEFINE_ENUM_INTERNAL(remquol)
1968+
TLI_DEFINE_STRING_INTERNAL("remquol")
1969+
TLI_DEFINE_SIG_INTERNAL(LDbl, LDbl, LDbl, Ptr)
1970+
19561971
/// int remove(const char *path);
19571972
TLI_DEFINE_ENUM_INTERNAL(remove)
19581973
TLI_DEFINE_STRING_INTERNAL("remove")

llvm/lib/Analysis/TargetLibraryInfo.cpp

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -305,6 +305,7 @@ static void initializeLibCalls(TargetLibraryInfoImpl &TLI, const Triple &T,
305305
TLI.setUnavailable(LibFunc_modff);
306306
TLI.setUnavailable(LibFunc_powf);
307307
TLI.setUnavailable(LibFunc_remainderf);
308+
TLI.setUnavailable(LibFunc_remquof);
308309
TLI.setUnavailable(LibFunc_sinf);
309310
TLI.setUnavailable(LibFunc_sinhf);
310311
TLI.setUnavailable(LibFunc_sqrtf);
@@ -335,6 +336,7 @@ static void initializeLibCalls(TargetLibraryInfoImpl &TLI, const Triple &T,
335336
TLI.setUnavailable(LibFunc_modfl);
336337
TLI.setUnavailable(LibFunc_powl);
337338
TLI.setUnavailable(LibFunc_remainderl);
339+
TLI.setUnavailable(LibFunc_remquol);
338340
TLI.setUnavailable(LibFunc_sinl);
339341
TLI.setUnavailable(LibFunc_sinhl);
340342
TLI.setUnavailable(LibFunc_sqrtl);

llvm/lib/Transforms/Utils/BuildLibCalls.cpp

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1098,6 +1098,11 @@ bool llvm::inferNonMandatoryLibFuncAttrs(Function &F,
10981098
case LibFunc_ldexpl:
10991099
Changed |= setWillReturn(F);
11001100
break;
1101+
case LibFunc_remquo:
1102+
case LibFunc_remquof:
1103+
case LibFunc_remquol:
1104+
Changed |= setDoesNotCapture(F, 2);
1105+
[[fallthrough]];
11011106
case LibFunc_abs:
11021107
case LibFunc_acos:
11031108
case LibFunc_acosf:

llvm/test/Transforms/InferFunctionAttrs/annotate.ll

Lines changed: 9 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -812,6 +812,15 @@ declare x86_fp80 @remainderl(x86_fp80, x86_fp80)
812812
; CHECK: declare noundef i32 @remove(ptr nocapture noundef readonly) [[NOFREE_NOUNWIND]]
813813
declare i32 @remove(ptr)
814814

815+
; CHECK: declare double @remquo(double, double, ptr nocapture) [[NOFREE_NOUNWIND_WILLRETURN_WRITEONLY]]
816+
declare double @remquo(double, double, ptr)
817+
818+
; CHECK: declare float @remquof(float, float, ptr nocapture) [[NOFREE_NOUNWIND_WILLRETURN_WRITEONLY]]
819+
declare float @remquof(float, float, ptr)
820+
821+
; CHECK: declare x86_fp80 @remquol(x86_fp80, x86_fp80, ptr nocapture) [[NOFREE_NOUNWIND_WILLRETURN_WRITEONLY]]
822+
declare x86_fp80 @remquol(x86_fp80, x86_fp80, ptr)
823+
815824
; CHECK: declare noundef i32 @rename(ptr nocapture noundef readonly, ptr nocapture noundef readonly) [[NOFREE_NOUNWIND]]
816825
declare i32 @rename(ptr, ptr)
817826

llvm/test/tools/llvm-tli-checker/ps4-tli-check.yaml

Lines changed: 16 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -34,21 +34,21 @@
3434
#
3535
# CHECK: << Total TLI yes SDK no: 8
3636
# CHECK: >> Total TLI no SDK yes: 0
37-
# CHECK: == Total TLI yes SDK yes: 239
37+
# CHECK: == Total TLI yes SDK yes: 242
3838
#
3939
# WRONG_DETAIL: << TLI yes SDK no : '_ZdaPv' aka operator delete[](void*)
4040
# WRONG_DETAIL: >> TLI no SDK yes: '_ZdaPvj' aka operator delete[](void*, unsigned int)
4141
# WRONG_DETAIL-COUNT-8: << TLI yes SDK no : {{.*}}__hot_cold_t
4242
# WRONG_SUMMARY: << Total TLI yes SDK no: 9{{$}}
4343
# WRONG_SUMMARY: >> Total TLI no SDK yes: 1{{$}}
44-
# WRONG_SUMMARY: == Total TLI yes SDK yes: 238
44+
# WRONG_SUMMARY: == Total TLI yes SDK yes: 241
4545
#
4646
## The -COUNT suffix doesn't care if there are too many matches, so check
4747
## the exact count first; the two directives should add up to that.
4848
## Yes, this means additions to TLI will fail this test, but the argument
4949
## to -COUNT can't be an expression.
50-
# AVAIL: TLI knows 480 symbols, 247 available
51-
# AVAIL-COUNT-247: {{^}} available
50+
# AVAIL: TLI knows 483 symbols, 250 available
51+
# AVAIL-COUNT-250: {{^}} available
5252
# AVAIL-NOT: {{^}} available
5353
# UNAVAIL-COUNT-233: not available
5454
# UNAVAIL-NOT: not available
@@ -763,6 +763,18 @@ DynamicSymbols:
763763
Type: STT_FUNC
764764
Section: .text
765765
Binding: STB_GLOBAL
766+
- Name: remquo
767+
Type: STT_FUNC
768+
Section: .text
769+
Binding: STB_GLOBAL
770+
- Name: remquof
771+
Type: STT_FUNC
772+
Section: .text
773+
Binding: STB_GLOBAL
774+
- Name: remquol
775+
Type: STT_FUNC
776+
Section: .text
777+
Binding: STB_GLOBAL
766778
- Name: rewind
767779
Type: STT_FUNC
768780
Section: .text

llvm/unittests/Analysis/TargetLibraryInfoTest.cpp

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -281,6 +281,9 @@ TEST_F(TargetLibraryInfoTest, ValidProto) {
281281
"declare float @remainderf(float, float)\n"
282282
"declare x86_fp80 @remainderl(x86_fp80, x86_fp80)\n"
283283
"declare i32 @remove(i8*)\n"
284+
"declare double @remquo(double, double, ptr)\n"
285+
"declare float @remquof(float, float, ptr)\n"
286+
"declare x86_fp80 @remquol(x86_fp80, x86_fp80, ptr)\n"
284287
"declare i32 @rename(i8*, i8*)\n"
285288
"declare void @rewind(%struct*)\n"
286289
"declare double @rint(double)\n"

0 commit comments

Comments
 (0)