[llvm-commits] [llvm] r56286 - in /llvm/trunk: lib/Transforms/Utils/SimplifyCFG.cpp test/Transforms/SimplifyCFG/2008-09-17-SpeculativeHoist.ll
Evan Cheng
evan.cheng at apple.com
Thu Sep 18 10:21:06 PDT 2008
On Sep 18, 2008, at 10:12 AM, Devang Patel wrote:
>
> On Sep 18, 2008, at 9:57 AM, Evan Cheng wrote:
>
>>> - // If we get here, we can hoist the instruction. Try to place it
>>> before the
>>> - // icmp instruction preceeding the conditional branch.
>>> - BasicBlock::iterator InsertPos = BI;
>>> - if (InsertPos != BIParent->begin())
>>> - --InsertPos;
>>> - if (InsertPos == BrCond && !isa<PHINode>(BrCond))
>>> - BIParent->getInstList().splice(InsertPos, BB1->getInstList(),
>>> I);
>>> - else
>>> - BIParent->getInstList().splice(BI, BB1->getInstList(), I);
>>> + // If we get here, we can hoist the instruction.
>>> + BIParent->getInstList().splice(BI, BB1->getInstList(), I);
>>
>> Rather than removing the logic, why not check if the instruction uses
>> the branch condition?
>
> What's the advantage of hoisting this instruction by one additional
> instruction in some cases ?
As the comment said, it's trying to place it before the icmp
instruction which produces the predicate. This is a micro-optimization
for performance reason. Some optimization passes do not look very far,
it may prefer the icmp and branch to be next to each other. Also fast-
isel codegen will also prefer them to be together.
Evan
>
> -
> Devang
> _______________________________________________
> llvm-commits mailing list
> llvm-commits at cs.uiuc.edu
> http://lists.cs.uiuc.edu/mailman/listinfo/llvm-commits
More information about the llvm-commits
mailing list