Repository navigation
Conversation
Define unittest-cov explicitly with mir_core_test enabled so the existing CI coverage command runs the gated unit tests. Previously, DUB's default coverage build omitted this version identifier. AI-Assisted-By: Codex (GPT-6 Astra Medium)
Delegate pow and powi to Phobos during CTFE while retaining LLVM intrinsics at runtime. Preserve function signatures, return types, and attributes. This enables compile-time calculations in downstream code, including mir-stat's Weibull PDF and raw moments. Add regression tests covering floating-point types, exponent boundaries, and function-pointer use. Prefer LLVM_major when available to avoid deprecation diagnostics, with a fallback for older LDC releases. AI-Assisted-By: Codex (GPT-6 Astra Medium)
On Microsoft runtime targets, LLVM lowers float powi to powf after converting the exponent to float. Beyond 2^24, this can round odd exponents to even values, making powi(-1.0f, int.max) return +1. Use the double-precision intrinsic outside float's exact integer range, then convert the result back to the original type. Double represents every int exponent exactly. Keep the fallback out of line to prevent LLVM from evaluating both precision paths before selecting a result. Retain the existing float intrinsic path for exponents within the exact range. Add regressions for exponent boundaries, negative powers, signed zero, infinities, and NaN. AI-Assisted-By: Codex (GPT-6 Astra Medium)
Phobos runtime pow differs from LLVM and compile-time evaluation for several special inputs, including pow(1, NaN), unit bases with infinite exponents, and infinite bases with fractional exponents. Handle these cases before invoking the Phobos fallback, following libm conventions. Preserve signed-zero results and determine exponent parity without integer casts, allowing extended-precision real exponents beyond long.max. Apply the same normalization to LDC's CTFE fallback while retaining its runtime LLVM intrinsic. Leave ordinary finite calculations with their existing backends. Document the conventions and add explicit expected-value tests across float, double, and real at runtime and during CTFE. AI-Assisted-By: Codex (GPT-6 Astra Medium)
This was referenced Oct 14, 2026
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Enable compile-time evaluation of
powandpowiwith LDC, preserve large integer exponents in Windows floatpowi, and align special-value behavior across runtime and CTFE.LDC now delegates power calculations to Phobos during CTFE while retaining LLVM intrinsics at runtime. Public signatures, return types, and attributes remain unchanged.
On Microsoft runtime targets, LLVM lowers float
powithroughpowf, rounding integer exponents beyond float’s exact range. This can makepowi(-1.0f, int.max)return +1. Use the double-precision intrinsic for these exponents, with an out-of-line helper to prevent speculative evaluation of both paths.Normalize special values before the Phobos fallback, including
pow(1, NaN), unit bases with infinite exponents, signed zero, and infinite bases with fractional exponents. Determine parity without integer casts so extended-precision exponents beyondlong.maxremain supported.Add runtime and CTFE regressions across float, double, and real. Enable
mir_core_testin coverage builds so the existing CI command runs the version-gated tests.Validation:
AI-Assisted-By: Codex (GPT-6 Astra Medium)