[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 09:57:02 PDT 2008


On Sep 17, 2008, at 11:21 AM, Devang Patel wrote:

> Author: dpatel
> Date: Wed Sep 17 13:21:49 2008
> New Revision: 56286
>
> URL: http://llvm.org/viewvc/llvm-project?rev=56286&view=rev
> Log:
> Do not hoist instruction above branch condition. The instruction may  
> use branch condition.

Ok.

>
>
> Added:
>    llvm/trunk/test/Transforms/SimplifyCFG/2008-09-17- 
> SpeculativeHoist.ll
> Modified:
>    llvm/trunk/lib/Transforms/Utils/SimplifyCFG.cpp
>
> Modified: llvm/trunk/lib/Transforms/Utils/SimplifyCFG.cpp
> URL: http://llvm.org/viewvc/llvm-project/llvm/trunk/lib/Transforms/Utils/SimplifyCFG.cpp?rev=56286&r1=56285&r2=56286&view=diff
>
> = 
> = 
> = 
> = 
> = 
> = 
> = 
> = 
> ======================================================================
> --- llvm/trunk/lib/Transforms/Utils/SimplifyCFG.cpp (original)
> +++ llvm/trunk/lib/Transforms/Utils/SimplifyCFG.cpp Wed Sep 17  
> 13:21:49 2008
> @@ -1046,15 +1046,8 @@
>       return false;
>   }
>
> -  // 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?

Evan

>
>
>   // Create a select whose true value is the speculatively executed  
> value and
>   // false value is the previously determined FalseV.
>
> Added: llvm/trunk/test/Transforms/SimplifyCFG/2008-09-17- 
> SpeculativeHoist.ll
> URL: http://llvm.org/viewvc/llvm-project/llvm/trunk/test/Transforms/SimplifyCFG/2008-09-17-SpeculativeHoist.ll?rev=56286&view=auto
>
> = 
> = 
> = 
> = 
> = 
> = 
> = 
> = 
> ======================================================================
> --- llvm/trunk/test/Transforms/SimplifyCFG/2008-09-17- 
> SpeculativeHoist.ll (added)
> +++ llvm/trunk/test/Transforms/SimplifyCFG/2008-09-17- 
> SpeculativeHoist.ll Wed Sep 17 13:21:49 2008
> @@ -0,0 +1,18 @@
> +; RUN: llvm-as < %s | opt -simplifycfg -disable-output
> +; PR 2800
> +
> +define void @foo() {
> +start:
> +	%tmp = call i1 @bar( )		; <i1> [#uses=4]
> +	br i1 %tmp, label %brtrue, label %brfalse
> +
> +brtrue:		; preds = %start
> +	%tmpnew = and i1 %tmp, %tmp		; <i1> [#uses=1]
> +	br label %brfalse
> +
> +brfalse:		; preds = %brtrue, %start
> +	%andandtmp.0 = phi i1 [ %tmp, %start ], [ %tmpnew, %brtrue ]		;  
> <i1> [#uses=0]
> +	ret void
> +}
> +
> +declare i1 @bar()
>
>
> _______________________________________________
> 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