Reactor: Fix Round (float) generic code generation

This commit fixes `Round(Float)` and `Round(Float4)` generic LLVM code
generation.

Bug: b/115344057
Test: dEQP-GLES3.functional.shaders.builtin_functions.precision.sin
Test: dEQP-GLES3.functional.shaders.builtin_functions.precision.cos
Change-Id: I9758ac4ca69bb0f5a5b192b4be3310827625fac0
Reviewed-on: https://swiftshader-review.googlesource.com/20932
Tested-by: Chris Forbes <chrisforbes@google.com>
Reviewed-by: Nicolas Capens <nicolascapens@google.com>
Reviewed-by: Chris Forbes <chrisforbes@google.com>
diff --git a/src/Reactor/LLVMReactor.cpp b/src/Reactor/LLVMReactor.cpp
index a9eee3e..7d75fe9 100644
--- a/src/Reactor/LLVMReactor.cpp
+++ b/src/Reactor/LLVMReactor.cpp
@@ -183,6 +183,13 @@
 		return ::builder->CreateSelect(::builder->CreateFCmp(pred, x, y), x, y);
 	}
 
+	llvm::Value *lowerRound(llvm::Value *x)
+	{
+		llvm::Function *nearbyint = llvm::Intrinsic::getDeclaration(
+			::module, llvm::Intrinsic::nearbyint, {x->getType()});
+		return ::builder->CreateCall(nearbyint, ARGS(x));
+	}
+
 	llvm::Value *lowerFloor(llvm::Value *x)
 	{
 		llvm::Function *floor = llvm::Intrinsic::getDeclaration(
@@ -522,6 +529,7 @@
 		ExternalFunctionSymbolResolver()
 		{
 			func_.emplace("floorf", reinterpret_cast<void*>(floorf));
+			func_.emplace("nearbyintf", reinterpret_cast<void*>(nearbyintf));
 		}
 
 		void *findSymbol(const std::string &name) const
@@ -6245,10 +6253,12 @@
 			return x86::roundss(x, 0);
 		}
 		else
-#endif
 		{
 			return Float4(Round(Float4(x))).x;
 		}
+#else
+		return RValue<Float>(V(lowerRound(V(x.value))));
+#endif
 	}
 
 	RValue<Float> Trunc(RValue<Float> x)
@@ -6710,10 +6720,12 @@
 			return x86::roundps(x, 0);
 		}
 		else
-#endif
 		{
 			return Float4(RoundInt(x));
 		}
+#else
+		return RValue<Float4>(V(lowerRound(V(x.value))));
+#endif
 	}
 
 	RValue<Float4> Trunc(RValue<Float4> x)