CodeGen: Simplify code slightly

llvm-svn: 150672
This commit is contained in:
Tobias Grosser 2012-02-16 09:56:10 +00:00
parent 099cb16700
commit 906eafe32c
1 changed files with 4 additions and 8 deletions

View File

@ -803,10 +803,8 @@ Value *ClastExpCodeGen::codegen(const clast_binary *e, Type *Ty) {
case clast_bin_fdiv:
{
// floord(n,d) ((n < 0) ? (n - d + 1) : n) / d
Value *One = ConstantInt::get(Builder.getInt1Ty(), 1);
Value *Zero = ConstantInt::get(Builder.getInt1Ty(), 0);
One = Builder.CreateZExtOrBitCast(One, Ty);
Zero = Builder.CreateZExtOrBitCast(Zero, Ty);
Value *One = ConstantInt::get(Ty, 1);
Value *Zero = ConstantInt::get(Ty, 0);
Value *Sum1 = Builder.CreateSub(LHS, RHS);
Value *Sum2 = Builder.CreateAdd(Sum1, One);
Value *isNegative = Builder.CreateICmpSLT(LHS, Zero);
@ -816,10 +814,8 @@ Value *ClastExpCodeGen::codegen(const clast_binary *e, Type *Ty) {
case clast_bin_cdiv:
{
// ceild(n,d) ((n < 0) ? n : (n + d - 1)) / d
Value *One = ConstantInt::get(Builder.getInt1Ty(), 1);
Value *Zero = ConstantInt::get(Builder.getInt1Ty(), 0);
One = Builder.CreateZExtOrBitCast(One, Ty);
Zero = Builder.CreateZExtOrBitCast(Zero, Ty);
Value *One = ConstantInt::get(Ty, 1);
Value *Zero = ConstantInt::get(Ty, 0);
Value *Sum1 = Builder.CreateAdd(LHS, RHS);
Value *Sum2 = Builder.CreateSub(Sum1, One);
Value *isNegative = Builder.CreateICmpSLT(LHS, Zero);