From 21e8da59900dc32071b09bbbad2834545661f3c0 Mon Sep 17 00:00:00 2001 From: Benjamin Kramer Date: Fri, 25 Jan 2013 19:43:15 +0000 Subject: [PATCH] LoopVectorize: Simplify code. No functionality change. llvm-svn: 173475 --- llvm/lib/Transforms/Vectorize/LoopVectorize.cpp | 43 ++++++++++--------------- 1 file changed, 17 insertions(+), 26 deletions(-) diff --git a/llvm/lib/Transforms/Vectorize/LoopVectorize.cpp b/llvm/lib/Transforms/Vectorize/LoopVectorize.cpp index f53f57c..060b06a 100644 --- a/llvm/lib/Transforms/Vectorize/LoopVectorize.cpp +++ b/llvm/lib/Transforms/Vectorize/LoopVectorize.cpp @@ -941,30 +941,23 @@ InnerLoopVectorizer::addRuntimeCheck(LoopVectorizationLegality *Legal, } } - IRBuilder<> ChkBuilder(Loc->getContext()); - ChkBuilder.SetInsertPoint(Loc); + IRBuilder<> ChkBuilder(Loc); for (unsigned i = 0; i < NumPointers; ++i) { for (unsigned j = i+1; j < NumPointers; ++j) { - Instruction::CastOps Op = Instruction::BitCast; - Value *Start0 = ChkBuilder.CreateCast(Op, Starts[i], PtrArithTy, "bc"); - Value *Start1 = ChkBuilder.CreateCast(Op, Starts[j], PtrArithTy, "bc"); - Value *End0 = ChkBuilder.CreateCast(Op, Ends[i], PtrArithTy, "bc"); - Value *End1 = ChkBuilder.CreateCast(Op, Ends[j], PtrArithTy, "bc"); - - Value *Cmp0 = ChkBuilder.CreateICmp(CmpInst::ICMP_ULE, - Start0, End1, "bound0"); - Value *Cmp1 = ChkBuilder.CreateICmp(CmpInst::ICMP_ULE, - Start1, End0, "bound1"); - Value *IsConflict = ChkBuilder.CreateBinOp(Instruction::And, Cmp0, Cmp1, - "found.conflict"); - if (MemoryRuntimeCheck) { - Value *B = ChkBuilder.CreateBinOp(Instruction::Or, MemoryRuntimeCheck, - IsConflict, "conflict.rdx"); - MemoryRuntimeCheck = cast(B); - } else { - MemoryRuntimeCheck = cast(IsConflict); - } + Value *Start0 = ChkBuilder.CreateBitCast(Starts[i], PtrArithTy, "bc"); + Value *Start1 = ChkBuilder.CreateBitCast(Starts[j], PtrArithTy, "bc"); + Value *End0 = ChkBuilder.CreateBitCast(Ends[i], PtrArithTy, "bc"); + Value *End1 = ChkBuilder.CreateBitCast(Ends[j], PtrArithTy, "bc"); + + Value *Cmp0 = ChkBuilder.CreateICmpULE(Start0, End1, "bound0"); + Value *Cmp1 = ChkBuilder.CreateICmpULE(Start1, End0, "bound1"); + Value *IsConflict = ChkBuilder.CreateAnd(Cmp0, Cmp1, "found.conflict"); + if (MemoryRuntimeCheck) + IsConflict = ChkBuilder.CreateOr(MemoryRuntimeCheck, IsConflict, + "conflict.rdx"); + + MemoryRuntimeCheck = cast(IsConflict); } } @@ -1063,12 +1056,10 @@ InnerLoopVectorizer::createEmptyLoop(LoopVectorizationLegality *Legal) { // This is the IR builder that we use to add all of the logic for bypassing // the new vector loop. - IRBuilder<> BypassBuilder(OldBasicBlock->getContext()); - BypassBuilder.SetInsertPoint(BypassBlock->getTerminator()); + IRBuilder<> BypassBuilder(BypassBlock->getTerminator()); // We may need to extend the index in case there is a type mismatch. // We know that the count starts at zero and does not overflow. - unsigned IdxTyBW = IdxTy->getScalarSizeInBits(); if (Count->getType() != IdxTy) { // The exit count can be of pointer type. Convert it to the correct // integer type. @@ -1090,8 +1081,8 @@ InnerLoopVectorizer::createEmptyLoop(LoopVectorizationLegality *Legal) { // Now, compare the new count to zero. If it is zero skip the vector loop and // jump to the scalar loop. - Value *Cmp = BypassBuilder.CreateICmp(CmpInst::ICMP_EQ, IdxEndRoundDown, - StartIdx, "cmp.zero"); + Value *Cmp = BypassBuilder.CreateICmpEQ(IdxEndRoundDown, StartIdx, + "cmp.zero"); BasicBlock *LastBypassBlock = BypassBlock; -- 2.7.4