From 520a89e9d38bb1c9cc2de3f875eae3ac69f9f08a Mon Sep 17 00:00:00 2001 From: Dimitry Andric Date: Wed, 24 Jan 2018 20:25:37 +0000 Subject: Vendor import of clang release_60 branch r323338: https://llvm.org/svn/llvm-project/cfe/branches/release_60@323338 --- lib/CodeGen/CGBuiltin.cpp | 6 +++++- 1 file changed, 5 insertions(+), 1 deletion(-) (limited to 'lib/CodeGen/CGBuiltin.cpp') diff --git a/lib/CodeGen/CGBuiltin.cpp b/lib/CodeGen/CGBuiltin.cpp index ba54f8342f1b..35ae114c4f25 100644 --- a/lib/CodeGen/CGBuiltin.cpp +++ b/lib/CodeGen/CGBuiltin.cpp @@ -915,7 +915,11 @@ EmitCheckedMixedSignMultiply(CodeGenFunction &CGF, const clang::Expr *Op1, Overflow = CGF.Builder.CreateOr(Overflow, TruncOverflow); } - Result = CGF.Builder.CreateTrunc(UnsignedResult, ResTy); + // Negate the product if it would be negative in infinite precision. + Result = CGF.Builder.CreateSelect( + IsNegative, CGF.Builder.CreateNeg(UnsignedResult), UnsignedResult); + + Result = CGF.Builder.CreateTrunc(Result, ResTy); } assert(Overflow && Result && "Missing overflow or result"); -- cgit v1.3