From 70c68a6b0e515967dba5b30f6a60e220a8cd8d2c Mon Sep 17 00:00:00 2001 From: Philip Reames Date: Tue, 19 Nov 2019 14:43:13 -0800 Subject: [NFC] Factor out utilities for manipulating widenable branches With the widenable condition construct, we have the ability to reason about branches which can be 'widened' (i.e. made to fail more often). We've got a couple o transforms which leverage this. This patch just cleans up the API a bit. This is prep work for generalizing our definition of a widenable branch slightly. At the moment "br i1 (and A, wc()), ..." is considered widenable, but oddly, neither "br i1 (and wc(), B), ..." or "br i1 wc(), ..." is. That clearly needs addressed, so first, let's centralize the code in one place. --- llvm/lib/Transforms/Scalar/LoopPredication.cpp | 10 ++-------- 1 file changed, 2 insertions(+), 8 deletions(-) (limited to 'llvm/lib/Transforms/Scalar/LoopPredication.cpp') diff --git a/llvm/lib/Transforms/Scalar/LoopPredication.cpp b/llvm/lib/Transforms/Scalar/LoopPredication.cpp index 9d67046..1962c8b 100644 --- a/llvm/lib/Transforms/Scalar/LoopPredication.cpp +++ b/llvm/lib/Transforms/Scalar/LoopPredication.cpp @@ -196,6 +196,7 @@ #include "llvm/Support/CommandLine.h" #include "llvm/Support/Debug.h" #include "llvm/Transforms/Scalar.h" +#include "llvm/Transforms/Utils/GuardUtils.h" #include "llvm/Transforms/Utils/Local.h" #include "llvm/Transforms/Utils/LoopUtils.h" @@ -1144,14 +1145,7 @@ bool LoopPredication::predicateLoopExits(Loop *L, SCEVExpander &Rewriter) { // context. NewCond = B.CreateFreeze(NewCond); - Value *Cond, *WC; - BasicBlock *IfTrueBB, *IfFalseBB; - bool Success = - parseWidenableBranch(WidenableBR, Cond, WC, IfTrueBB, IfFalseBB); - assert(Success && "implied from above"); - (void)Success; - Instruction *WCAnd = cast(WidenableBR->getCondition()); - WCAnd->setOperand(0, B.CreateAnd(NewCond, Cond)); + widenWidenableBranch(WidenableBR, NewCond); Value *OldCond = BI->getCondition(); BI->setCondition(ConstantInt::get(OldCond->getType(), !ExitIfTrue)); -- cgit v1.1