Repository navigation
Preserve signed zero in floating unary negation - #152
Merged
Merged
Conversation
Emit LLVM fneg through existing SSA/debug output and preserve scalar checks. Reuse float fixture comparison for signed-zero and exceptional-value regressions. Validation passed: focused and full Go tests, vet, fresh bundle, executable fixtures, and Clang object checks for 32-/64-bit targets.
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.
Summary
fnegfor floating unary minus, add regressions, extend the existing float fixture, and specify signed-zero behavior.-(+0.0)produced+0.0, while constant folding produced-0.0; their reciprocal results disagreed.emitValueExprunary-minus branch ininternal/backend/llvm.Production ownership
GenerateLLVMIRMIR Assign emission callsemitValueExpr.emitValueExpr.emitRef,isFloatType,nextValue, and debug-taggedlineinsidewithLLVMLocation. Replace only floating subtraction from positive zero. CanonicalFoldUnaryandNewFloatremain the constant-evaluation owners; the fixture reusesMatches.fsubbranch is replaced directly.Design and behavior
fsub float/double 0.0, valueloses the negative-zero result for a positive-zero operand.fnegreverses sign at the existing operand width, including signed zeros and infinities. NaN remains NaN; no payload/sign encoding guarantee is added.Validation
Run and report the exact commands used. Do not summarize a command as passing unless it was actually executed.
TestGenerateLLVMIRLowersUnaryNegation,TestLLVMEmitterRejectsNonScalarFloatNegation,TestFoldFloatUnaryNegation, and existingruntime_float_remainderfixture. Before repair, four f32/f64 emission cases failed and the freshly bundled fixture exited 33. All 20 new constant-folding cases already passed on baseline. After repair, emission and executable regressions pass.Diff sanity
Risks and follow-up
nszflags. Parameter-backed runtime functions prevent literal folding from hiding the original emitter defect.