[PATCH] If a conditional branch jumps to the same target, remove the condition
Hal Finkel
hfinkel at anl.gov
Tue Mar 10 15:18:40 PDT 2015
----- Original Message -----
> From: "Philip Reames" <listmail at philipreames.com>
> To: reviews+D8220+public+8ff214d7d1b26317 at reviews.llvm.org, hfinkel at anl.gov
> Cc: llvm-commits at cs.uiuc.edu
> Sent: Tuesday, March 10, 2015 5:12:28 PM
> Subject: Re: [PATCH] If a conditional branch jumps to the same target, remove the condition
>
> @Hal - Unless I'm missing something, this is already handled in
> ConstantFoldTerminator.
>
> if (Dest2 == Dest1) { // Conditional branch to same
> location?
> // This branch matches something like this:
> // br bool %cond, label %Dest, label %Dest
> // and changes it into: br label %Dest
>
> // Let the basic block know that we are letting go of one copy
> of it.
> assert(BI->getParent() && "Terminator not inserted in
> block!");
> Dest1->removePredecessor(BI->getParent());
>
> // Replace the conditional branch with an unconditional one.
> Builder.CreateBr(Dest1);
> Value *Cond = BI->getCondition();
> BI->eraseFromParent();
> if (DeleteDeadConditions)
> RecursivelyDeleteTriviallyDeadInstructions(Cond, TLI);
> return true;
> }
>
> Given this, I plan to submit as is.
Heh; indeed. Missed that. Sounds good, thanks!
-Hal
>
> On 03/10/2015 01:43 PM, hfinkel at anl.gov wrote:
> > LGTM. But, could you also please fix llvm::ConstantFoldTerminator
> > in lib/Transforms/Utils/Local.cpp so that it handles the undef
> > condition and transforms the branch with the undef condition into
> > an unconditional branch. If we don't want to do that, then we
> > should just pick true/false here instead of using undef.
> >
> >
> > http://reviews.llvm.org/D8220
> >
> > EMAIL PREFERENCES
> > http://reviews.llvm.org/settings/panel/emailpreferences/
> >
> >
>
>
--
Hal Finkel
Assistant Computational Scientist
Leadership Computing Facility
Argonne National Laboratory
More information about the llvm-commits
mailing list