Use OpFUnordNotEqual for floating-point !=

The normal IEEE not equal operation tests whether operands are unordered
or not equal (so comparison with a NaN returns true). This corresponds
to the SPIR-V OpFUnordNotEqual, so change to using that.
This commit is contained in:
Graeme Leese 2020-06-05 13:32:51 +01:00
parent adacba3ee9
commit 65ce566cbc
2 changed files with 5 additions and 5 deletions

View File

@ -5616,7 +5616,7 @@ spv::Id TGlslangToSpvTraverser::createBinaryOperation(glslang::TOperator op, OpD
case glslang::EOpNotEqual:
case glslang::EOpVectorNotEqual:
if (isFloat)
binOp = spv::OpFOrdNotEqual;
binOp = spv::OpFUnordNotEqual;
else if (isBool)
binOp = spv::OpLogicalNotEqual;
else
@ -6314,7 +6314,7 @@ spv::Id TGlslangToSpvTraverser::createConversion(glslang::TOperator op, OpDecora
case glslang::EOpConvFloatToBool:
zero = builder.makeFloatConstant(0.0F);
zero = makeSmearedConstant(zero, vectorSize);
return builder.createBinOp(spv::OpFOrdNotEqual, destType, operand, zero);
return builder.createBinOp(spv::OpFUnordNotEqual, destType, operand, zero);
case glslang::EOpConvBoolToFloat:
convOp = spv::OpSelect;
zero = builder.makeFloatConstant(0.0F);
@ -6463,11 +6463,11 @@ spv::Id TGlslangToSpvTraverser::createConversion(glslang::TOperator op, OpDecora
case glslang::EOpConvDoubleToBool:
zero = builder.makeDoubleConstant(0.0);
zero = makeSmearedConstant(zero, vectorSize);
return builder.createBinOp(spv::OpFOrdNotEqual, destType, operand, zero);
return builder.createBinOp(spv::OpFUnordNotEqual, destType, operand, zero);
case glslang::EOpConvFloat16ToBool:
zero = builder.makeFloat16Constant(0.0F);
zero = makeSmearedConstant(zero, vectorSize);
return builder.createBinOp(spv::OpFOrdNotEqual, destType, operand, zero);
return builder.createBinOp(spv::OpFUnordNotEqual, destType, operand, zero);
case glslang::EOpConvBoolToDouble:
convOp = spv::OpSelect;
zero = builder.makeDoubleConstant(0.0);

View File

@ -2166,7 +2166,7 @@ Id Builder::createCompositeCompare(Decoration precision, Id value1, Id value2, b
Op op;
switch (getMostBasicTypeClass(valueType)) {
case OpTypeFloat:
op = equal ? OpFOrdEqual : OpFOrdNotEqual;
op = equal ? OpFOrdEqual : OpFUnordNotEqual;
break;
case OpTypeInt:
default: