================
@@ -75,6 +75,74 @@ static Value *getMaskVecValue(CodeGenFunction &CGF, Value
*Mask,
return MaskVec;
}
+// Emit rounding for the value X according to the rounding RoundingControl.
+static Value *emitX86Round(CodeGenFunction &CGF, Value *X,
+ unsigned RoundingControl) {
+ unsigned RoundingMask = 0b11;
+ unsigned UseMXCSRBit = 0b1000;
+
+ unsigned RoundingMode = RoundingControl & RoundingMask;
+ bool UseMXCSR = RoundingControl & UseMXCSRBit;
+
+ Intrinsic::ID ID = Intrinsic::not_intrinsic;
+ LLVMContext &Ctx = CGF.CGM.getLLVMContext();
+ if (CGF.Builder.getIsFPConstrained()) {
+
+ Value *ExceptMode =
+ MetadataAsValue::get(Ctx, MDString::get(Ctx, "fpexcept.ignore"));
+
+ if (UseMXCSR) {
+ ID = Intrinsic::experimental_constrained_nearbyint;
----------------
phoebewang wrote:
>From LLVM test, constrained_nearbyint generates 12, while constrained_rint
>generates 4 which is the mattched value. But I agree using `x86.*.round.*`
>looks better.
https://github.com/llvm/llvm-project/pull/171227
_______________________________________________
cfe-commits mailing list
[email protected]
https://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits