target-mips: Implement correct NaN propagation rules
Implement the correct NaN propagation rules for MIPS targets by providing an appropriate pickNaN function. Signed-off-by: Aurelien Jarno <aurelien@aurel32.net>
This commit is contained in:
		
							parent
							
								
									1f398e0825
								
							
						
					
					
						commit
						084d19ba71
					
				@ -192,6 +192,33 @@ static int pickNaN(flag aIsQNaN, flag aIsSNaN, flag bIsQNaN, flag bIsSNaN,
 | 
				
			|||||||
        return 1;
 | 
					        return 1;
 | 
				
			||||||
    }
 | 
					    }
 | 
				
			||||||
}
 | 
					}
 | 
				
			||||||
 | 
					#elif defined(TARGET_MIPS)
 | 
				
			||||||
 | 
					static int pickNaN(flag aIsQNaN, flag aIsSNaN, flag bIsQNaN, flag bIsSNaN,
 | 
				
			||||||
 | 
					                    flag aIsLargerSignificand)
 | 
				
			||||||
 | 
					{
 | 
				
			||||||
 | 
					    /* According to MIPS specifications, if one of the two operands is
 | 
				
			||||||
 | 
					     * a sNaN, a new qNaN has to be generated. This is done in
 | 
				
			||||||
 | 
					     * floatXX_maybe_silence_nan(). For qNaN inputs the specifications
 | 
				
			||||||
 | 
					     * says: "When possible, this QNaN result is one of the operand QNaN
 | 
				
			||||||
 | 
					     * values." In practice it seems that most implementations choose
 | 
				
			||||||
 | 
					     * the first operand if both operands are qNaN. In short this gives
 | 
				
			||||||
 | 
					     * the following rules:
 | 
				
			||||||
 | 
					     *  1. A if it is signaling
 | 
				
			||||||
 | 
					     *  2. B if it is signaling
 | 
				
			||||||
 | 
					     *  3. A (quiet)
 | 
				
			||||||
 | 
					     *  4. B (quiet)
 | 
				
			||||||
 | 
					     * A signaling NaN is always silenced before returning it.
 | 
				
			||||||
 | 
					     */
 | 
				
			||||||
 | 
					    if (aIsSNaN) {
 | 
				
			||||||
 | 
					        return 0;
 | 
				
			||||||
 | 
					    } else if (bIsSNaN) {
 | 
				
			||||||
 | 
					        return 1;
 | 
				
			||||||
 | 
					    } else if (aIsQNaN) {
 | 
				
			||||||
 | 
					        return 0;
 | 
				
			||||||
 | 
					    } else {
 | 
				
			||||||
 | 
					        return 1;
 | 
				
			||||||
 | 
					    }
 | 
				
			||||||
 | 
					}
 | 
				
			||||||
#else
 | 
					#else
 | 
				
			||||||
static int pickNaN(flag aIsQNaN, flag aIsSNaN, flag bIsQNaN, flag bIsSNaN,
 | 
					static int pickNaN(flag aIsQNaN, flag aIsSNaN, flag bIsQNaN, flag bIsSNaN,
 | 
				
			||||||
                    flag aIsLargerSignificand)
 | 
					                    flag aIsLargerSignificand)
 | 
				
			||||||
 | 
				
			|||||||
		Loading…
	
	
			
			x
			
			
		
	
		Reference in New Issue
	
	Block a user