Condition Code Handling for NaN Values in Compiler Execution

Resolve Bottlenecks,
Find Innovative Solutions
Generate Solutions

Solution Overview

Problem

Conventional condition codes fail to produce deterministic results when non-numeric values, such as NaN, are present, leading to inconsistent results across different processors due to varying condition code values.

Innovation Solution

Introducing a fourth condition code value to represent NaN and defining new condition tests that explicitly handle non-numeric values, allowing compilers to generate code that produces deterministic results by using explicit condition tests and predicated commands.

Engineering Contradictions & Design Principles

VSEngineering Contradiction Analysis

1Reliability

If conventional condition codes are used to represent comparison results, then the system can handle standard numeric comparisons, but the system produces non-deterministic results when NaN values are present

Engineering Contradiction:
Improvedeterminism of condition code resultsVSAvoidhandling of non-numeric values
Core Design Contradiction:
ReliabilityVSAdaptability or versatility

Solution Approach 1:

The condition code representation is segmented into four distinct values (positive, negative, zero, NaN) instead of three, allowing explicit representation of non-numeric comparison results. This segmentation enables the system to distinguish between different types of comparison outcomes, including unordered relationships involving NaN values.

Inventive Principle:
Principle #1Segmentation

Solution Approach 2:

The condition code system transitions from a three-value state space to a four-value state space by adding the NaN dimension. This dimensional expansion allows the system to represent unordered relationships as a distinct state rather than forcing them into existing ordered categories.

Inventive Principle:
Principle #17Another dimension (Dimensionality change)

2Adaptability or versatility

If the IEEE floating point format with NaN is used, then the system can represent non-numeric values, but condition tests produce unexpected results because NaN has no order relative to numeric values

Engineering Contradiction:
Improverepresentation of non-numeric valuesVSAvoidpredictability of condition test results
Core Design Contradiction:
Adaptability or versatilityVSReliability

Solution Approach 1:

The unordered relationship involving NaN is extracted from the conventional three-way comparison logic and handled as a separate, explicit condition. By isolating the NaN case into its own condition code value and associated test logic, the system avoids forcing unordered relationships into ordered comparison frameworks.

Inventive Principle:
Principle #2Taking out (Extraction)

Solution Approach 2:

The system performs preliminary classification of comparison results into four categories before executing condition tests. This preliminary action ensures that NaN-related unordered relationships are identified and handled according to predefined rules before any conditional branching occurs, making results predictable.

Inventive Principle:
Principle #10Preliminary action

3Productivity

If conventional condition tests are used with NaN values, then the system can process all comparison operations, but different processors produce different condition code values leading to inconsistency

Engineering Contradiction:
Improveprocessing of comparison operationsVSAvoidconsistency across processors
Core Design Contradiction:
ProductivityVSReliability

Solution Approach 1:

The four-value condition code system serves as a universal interface for all comparison operations, including those involving NaN. By standardizing the representation of unordered relationships across all processors, the system ensures consistent behavior regardless of the specific processor architecture or implementation details.

Inventive Principle:
Principle #6Universality (Multi-functionality)

Data Source

PatentUS9195460B1Using condition codes in the presence of non-numeric values
Publication Date: 2015.11.24 NVIDIA CORP
  • US9195460B1 patent drawing
  • US9195460B1 patent drawing
  • US9195460B1 patent drawing

AI summary

Systems and methods for compiling programs using condition codes and executing those programs when non-numeric values are present allow for explicit handling of non-numeric values. In addition to the conventional condition code values of positive, negative, and zero, a fourth value may be encoded, not a number (NaN) representing a non-numeric value. New condition tests are defined that explicitly account for condition code values of NaN. A compiler may produce code using the new condition tests to represent if and if-else statements. The code including the new condition tests generates deterministic results during execution when non-numeric values are present.