[llvm-commits] [dragonegg] r92703 - /dragonegg/trunk/llvm-convert.cpp
Duncan Sands
baldrick at free.fr
Mon Jan 4 23:18:03 PST 2010
Author: baldrick
Date: Tue Jan 5 01:18:02 2010
New Revision: 92703
URL: http://llvm.org/viewvc/llvm-project?rev=92703&view=rev
Log:
Port commit 91660 (djg) from llvm-gcc:
Set the NSW flag on signed-integer subtract operators.
Modified:
dragonegg/trunk/llvm-convert.cpp
Modified: dragonegg/trunk/llvm-convert.cpp
URL: http://llvm.org/viewvc/llvm-project/dragonegg/trunk/llvm-convert.cpp?rev=92703&r1=92702&r2=92703&view=diff
==============================================================================
--- dragonegg/trunk/llvm-convert.cpp (original)
+++ dragonegg/trunk/llvm-convert.cpp Tue Jan 5 01:18:02 2010
@@ -3324,7 +3324,6 @@
bool RHSIsSigned = !TYPE_UNSIGNED(TREE_TYPE(op1));
bool TyIsSigned = !TYPE_UNSIGNED(type);
bool IsExactDiv = code == EXACT_DIV_EXPR;
- bool IsPlus = code == PLUS_EXPR;
const Type *Ty = ConvertType(type);
LHS = CastToAnyType(LHS, LHSIsSigned, Ty, TyIsSigned);
@@ -3347,8 +3346,10 @@
Value *V;
if (Opc == Instruction::SDiv && IsExactDiv)
V = Builder.CreateExactSDiv(LHS, RHS);
- else if (Opc == Instruction::Add && IsPlus && TyIsSigned && !flag_wrapv)
+ else if (Opc == Instruction::Add && TyIsSigned && !flag_wrapv)
V = Builder.CreateNSWAdd(LHS, RHS);
+ else if (Opc == Instruction::Sub && TyIsSigned && !flag_wrapv)
+ V = Builder.CreateNSWSub(LHS, RHS);
else
V = Builder.CreateBinOp((Instruction::BinaryOps)Opc, LHS, RHS);
if (ResTy != Ty)
More information about the llvm-commits
mailing list