Skip to content
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

Emit jumps rather than a mix of mov/set/jump for conditions #4159

Merged
merged 2 commits into from
Jan 7, 2025
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
3 changes: 2 additions & 1 deletion geometry/hilbert_body.hpp
Original file line number Diff line number Diff line change
Expand Up @@ -48,7 +48,8 @@ auto Hilbert<T, T>::Norm(T const& t) -> NormType {
_MSC_FULL_VER == 193'933'523 || \
_MSC_FULL_VER == 194'033'813 || \
_MSC_FULL_VER == 194'134'120 || \
_MSC_FULL_VER == 194'134'123)
_MSC_FULL_VER == 194'134'123 || \
_MSC_FULL_VER == 194'234'435)
template<typename T1, typename T2>
requires hilbert<T1, T2>
auto Hilbert<T1, T2>::InnerProduct(T1 const& t1, T2 const& t2)
Expand Down
27 changes: 16 additions & 11 deletions numerics/osaca.hpp
Original file line number Diff line number Diff line change
Expand Up @@ -175,21 +175,26 @@ static bool volatile OSACA_loop_terminator = false;

// The branch not taken, determined by evaluating the condition
// `UNDER_OSACA_HYPOTHESES`, is eliminated by `if constexpr`; the condition is
// also compiled normally and assigned to a boolean; whether this results in any
// generated code depends on `OSACA_EVALUATE_CONDITIONS`. Note that, with
// `OSACA_EVALUATE_CONDITIONS`, in `OSACA_IF(p) { } OSACA_ELSE_IF(q) { }`, if
// `p` holds `UNDER_OSACA_HYPOTHESES`, code is generated to evaluate `p`, but
// not `q`.

#define OSACA_IF(condition) \
if constexpr (bool OSACA_CONDITION_QUALIFIER OSACA_computed_condition = \
(condition); \
// also compiled normally. Whether this results in any generated code depends
// on `OSACA_EVALUATE_CONDITIONS`. Note that, with `OSACA_EVALUATE_CONDITIONS`,
// in `OSACA_IF(p) { } OSACA_ELSE_IF(q) { }`, if `p` holds
// `UNDER_OSACA_HYPOTHESES`, code is generated to evaluate `p`, but not `q`.

#define OSACA_IF(condition) \
if constexpr (int const OSACA_evaluate = \
UNDER_OSACA_HYPOTHESES(condition) \
? ((condition) ? 0 : OSACA_branch_not_taken()) \
: ((condition) ? OSACA_branch_not_taken() : 0); \
UNDER_OSACA_HYPOTHESES(condition))

#if OSACA_EVALUATE_CONDITIONS
#define OSACA_CONDITION_QUALIFIER volatile
[[noreturn]] inline int OSACA_branch_not_taken() {
std::abort();
}
#else
#define OSACA_CONDITION_QUALIFIER
inline int OSACA_branch_not_taken() {
return 0;
}
#endif

#else // if !PRINCIPIA_USE_OSACA
Expand Down