Skip to content

Commit 12bf835

Browse files
committed
function definition tweak
1 parent efbc83e commit 12bf835

File tree

4 files changed

+28
-24
lines changed

4 files changed

+28
-24
lines changed

flang/include/flang/Evaluate/target.h

Lines changed: 4 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -52,9 +52,10 @@ class TargetCharacteristics {
5252
}
5353
void set_areSubnormalsFlushedToZero(bool yes = true);
5454

55-
// Check if a given real kind, any real kind, or all real kinds have
56-
// flushing control.
57-
bool hasSubnormalFlushingControl(int kind, bool any = false) const;
55+
// Check if a given real kind has flushing control.
56+
bool hasSubnormalFlushingControl(int kind) const;
57+
// Check if any or all real kinds have flushing control.
58+
bool hasSubnormalFlushingControl(bool any = false) const;
5859
void set_hasSubnormalFlushingControl(int kind, bool yes = true);
5960

6061
Rounding roundingMode() const { return roundingMode_; }

flang/lib/Evaluate/fold-logical.cpp

Lines changed: 9 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -891,9 +891,15 @@ Expr<Type<TypeCategory::Logical, KIND>> FoldIntrinsicFunction(
891891
IeeeFeature::Subnormal)};
892892
} else if (name == "__builtin_ieee_support_underflow_control") {
893893
// Setting kind=0 checks subnormal flushing control across all type kinds.
894-
int kind{args[0] ? args[0]->GetType().value().kind() : 0};
895-
return Expr<T>{
896-
context.targetCharacteristics().hasSubnormalFlushingControl(kind)};
894+
if (args[0]) {
895+
return Expr<T>{
896+
context.targetCharacteristics().hasSubnormalFlushingControl(
897+
args[0]->GetType().value().kind())};
898+
} else {
899+
return Expr<T>{
900+
context.targetCharacteristics().hasSubnormalFlushingControl(
901+
/*any=*/false)};
902+
}
897903
}
898904
return Expr<T>{std::move(funcRef)};
899905
}

flang/lib/Evaluate/target.cpp

Lines changed: 14 additions & 17 deletions
Original file line numberDiff line numberDiff line change
@@ -108,25 +108,22 @@ void TargetCharacteristics::set_areSubnormalsFlushedToZero(bool yes) {
108108
areSubnormalsFlushedToZero_ = yes;
109109
}
110110

111-
// Check if the target has subnormal flushing control for:
112-
// - a given real kind (kind != 0)
113-
// - any real kind (kind == 0 && any == true)
114-
// - all real kinds (kind == 0 && any == false)
115-
bool TargetCharacteristics::hasSubnormalFlushingControl(
116-
int kind, bool any) const {
117-
CHECK(kind >= 0 && kind <= maxKind);
118-
if (kind == 0) {
119-
for (int kind{1}; kind <= maxKind; ++kind) {
120-
if (CanSupportType(TypeCategory::Real, kind) &&
121-
hasSubnormalFlushingControl_[kind] == any) {
122-
return any;
123-
}
111+
// Check if a given real kind has flushing control.
112+
bool TargetCharacteristics::hasSubnormalFlushingControl(int kind) const {
113+
CHECK(kind > 0 && kind <= maxKind);
114+
CHECK(CanSupportType(TypeCategory::Real, kind));
115+
return hasSubnormalFlushingControl_[kind];
116+
}
117+
118+
// Check if any or all real kinds have flushing control.
119+
bool TargetCharacteristics::hasSubnormalFlushingControl(bool any) const {
120+
for (int kind{1}; kind <= maxKind; ++kind) {
121+
if (CanSupportType(TypeCategory::Real, kind) &&
122+
hasSubnormalFlushingControl_[kind] == any) {
123+
return any;
124124
}
125-
return !any;
126-
} else {
127-
CHECK(CanSupportType(TypeCategory::Real, kind));
128-
return hasSubnormalFlushingControl_[kind];
129125
}
126+
return !any;
130127
}
131128

132129
void TargetCharacteristics::set_hasSubnormalFlushingControl(

flang/lib/Lower/Bridge.cpp

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -5240,7 +5240,7 @@ class FirConverter : public Fortran::lower::AbstractConverter {
52405240
}
52415241
if ((funit.mayModifyUnderflowMode) &&
52425242
(bridge.getTargetCharacteristics().hasSubnormalFlushingControl(
5243-
0, /*any=*/true))) {
5243+
/*any=*/true))) {
52445244
// F18 Clause 17.5p2: In a procedure [...], the processor shall not
52455245
// change the underflow mode on entry, and on return shall ensure that
52465246
// the underflow mode is the same as it was on entry.

0 commit comments

Comments
 (0)