[llvm-commits] [llvm-gcc-4.2] r91660 - /llvm-gcc-4.2/trunk/gcc/llvm-convert.cpp
Dan Gohman
gohman at apple.com
Thu Dec 17 18:36:24 PST 2009
Author: djg
Date: Thu Dec 17 20:36:24 2009
New Revision: 91660
URL: http://llvm.org/viewvc/llvm-project?rev=91660&view=rev
Log:
Set the NSW flag on signed-integer subtract operators.
Modified:
llvm-gcc-4.2/trunk/gcc/llvm-convert.cpp
Modified: llvm-gcc-4.2/trunk/gcc/llvm-convert.cpp
URL: http://llvm.org/viewvc/llvm-project/llvm-gcc-4.2/trunk/gcc/llvm-convert.cpp?rev=91660&r1=91659&r2=91660&view=diff
==============================================================================
--- llvm-gcc-4.2/trunk/gcc/llvm-convert.cpp (original)
+++ llvm-gcc-4.2/trunk/gcc/llvm-convert.cpp Thu Dec 17 20:36:24 2009
@@ -3365,7 +3365,6 @@
bool RHSIsSigned = !TYPE_UNSIGNED(TREE_TYPE(TREE_OPERAND(exp, 1)));
bool TyIsSigned = !TYPE_UNSIGNED(TREE_TYPE(exp));
bool IsExactDiv = TREE_CODE(exp) == EXACT_DIV_EXPR;
- bool IsPlus = TREE_CODE(exp) == PLUS_EXPR;
LHS = CastToAnyType(LHS, LHSIsSigned, Ty, TyIsSigned);
RHS = CastToAnyType(RHS, RHSIsSigned, Ty, TyIsSigned);
@@ -3387,8 +3386,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