<div dir="ltr">This looks reasonable. I've submitted this patch in r187646.</div><div class="gmail_extra"><br><br><div class="gmail_quote">On Thu, Aug 1, 2013 at 10:19 PM, Ye, Mei <span dir="ltr"><<a href="mailto:Mei.Ye@amd.com" target="_blank">Mei.Ye@amd.com</a>></span> wrote:<br>
<blockquote class="gmail_quote" style="margin:0 0 0 .8ex;border-left:1px #ccc solid;padding-left:1ex">Attached patch should fix it.<br>
<span class="HOEnZb"><font color="#888888"><br>
-Mei<br>
</font></span><div class="HOEnZb"><div class="h5"><br>
-----Original Message-----<br>
From: Stellard, Thomas<br>
Sent: Thursday, August 01, 2013 6:52 AM<br>
To: Ye, Mei; Evgeniy Stepanov; Alexey Samsonov<br>
Cc: <a href="mailto:llvm-commits@cs.uiuc.edu">llvm-commits@cs.uiuc.edu</a><br>
Subject: RE: [llvm] r187278 - SimplifyCFG: Use parallel-and and parallel-or mode to consolidate branch conditions<br>
<br>
Mei,<br>
<br>
Are you able to look into this?<br>
<br>
-Tom<br>
________________________________________<br>
From: Evgeniy Stepanov [<a href="mailto:eugenis@google.com">eugenis@google.com</a>]<br>
Sent: Thursday, August 01, 2013 12:58 AM<br>
To: Alexey Samsonov<br>
Cc: Stellard, Thomas; <a href="mailto:llvm-commits@cs.uiuc.edu">llvm-commits@cs.uiuc.edu</a><br>
Subject: Re: [llvm] r187278 - SimplifyCFG: Use parallel-and and parallel-or mode to consolidate branch conditions<br>
<br>
<a href="http://llvm.org/bugs/show_bug.cgi?id=16732" target="_blank">http://llvm.org/bugs/show_bug.cgi?id=16732</a><br>
<br>
On Thu, Aug 1, 2013 at 11:56 AM, Alexey Samsonov <<a href="mailto:samsonov@google.com">samsonov@google.com</a>> wrote:<br>
> Hi Tom!<br>
><br>
> I think this change may be relevant to the failures we see in our ASan<br>
> bootstrap buildbot. Can you take a look?<br>
><br>
> The following tests fail:<br>
>     LLVM :: Transforms/SimplifyCFG/R600/parallelandifcollapse.ll<br>
>     LLVM :: Transforms/SimplifyCFG/R600/parallelorifcollapse.ll<br>
><br>
> with this error report:<br>
><br>
> ==24655==ERROR: AddressSanitizer: heap-buffer-overflow on address<br>
> 0x60700000deb0 at pc 0x25589c7 bp 0x7fff185cd3f0 sp 0x7fff185cd3e8<br>
> READ of size 8 at 0x60700000deb0 thread T0<br>
>     #0 0x25589c6 in getDebugLoc /build/llvm/include/llvm/IR/IRBuilder.h:115<br>
>     #1 0x25589c6 in SetInsertPoint<br>
> /build/llvm/include/llvm/IR/IRBuilder.h:90<br>
>     #2 0x25589c6 in SimplifyParallelAndOr<br>
> /build/llvm/lib/Transforms/Utils/SimplifyCFG.cpp:4323<br>
>     #3 0x25589c6 in (anonymous<br>
> namespace)::SimplifyCFGOpt::run(llvm::BasicBlock*)<br>
> /build/llvm/lib/Transforms/Utils/SimplifyCFG.cpp:4587<br>
>     #4 0x255444c in llvm::SimplifyCFG(llvm::BasicBlock*,<br>
> llvm::TargetTransformInfo const&, llvm::DataLayout const*,<br>
> llvm::AliasAnalysis*) /build/llvm/lib/Transforms/Utils/SimplifyCFG.cpp:4630<br>
>     #5 0x231c281 in iterativelySimplifyCFG<br>
> /build/llvm/lib/Transforms/Scalar/SimplifyCFGPass.cpp:346<br>
>     #6 0x231c281 in (anonymous<br>
> namespace)::CFGSimplifyPass::runOnFunction(llvm::Function&)<br>
> /build/llvm/lib/Transforms/Scalar/SimplifyCFGPass.cpp:368<br>
>     #7 0x2b10cac in llvm::FPPassManager::runOnFunction(llvm::Function&)<br>
> /build/llvm/lib/IR/PassManager.cpp:1530<br>
>     #8 0x2b11275 in llvm::FPPassManager::runOnModule(llvm::Module&)<br>
> /build/llvm/lib/IR/PassManager.cpp:1550<br>
>     #9 0x2b11a9b in llvm::MPPassManager::runOnModule(llvm::Module&)<br>
> /build/llvm/lib/IR/PassManager.cpp:1608<br>
>     #10 0x2b12cb3 in llvm::PassManagerImpl::run(llvm::Module&)<br>
> /build/llvm/lib/IR/PassManager.cpp:1703<br>
>     #11 0x2b1312f in llvm::PassManager::run(llvm::Module&)<br>
> /build/llvm/lib/IR/PassManager.cpp:1738<br>
>     #12 0x61c930 in main /build/llvm/tools/opt/opt.cpp:827<br>
>     #13 0x7f285711b76c (/lib/x86_64-linux-gnu/libc.so.6+0x2176c)<br>
>     #14 0x60d97c in _start (/build/llvm_build_asan/bin/opt+0x60d97c)<br>
> 0x60700000deb0 is located 0 bytes to the right of 80-byte region<br>
> [0x60700000de60,0x60700000deb0)<br>
> allocated by thread T0 here:<br>
>     #0 0x5f7d15 in operator new(unsigned long)<br>
> /build/llvm/projects/compiler-rt/lib/asan/asan_new_delete.cc:52<br>
>     #1 0x148367d in Twine /build/llvm/include/llvm/IR/BasicBlock.h:111<br>
>     #2 0x148367d in llvm::LLParser::PerFunctionState::GetVal(std::string<br>
> const&, llvm::Type*, llvm::SMLoc)<br>
> /build/llvm/lib/AsmParser/LLParser.cpp:2063<br>
>     #3 0x14890b1 in llvm::LLParser::ConvertValIDToValue(llvm::Type*,<br>
> llvm::ValID&, llvm::Value*&, llvm::LLParser::PerFunctionState*)<br>
> /build/llvm/lib/AsmParser/LLParser.cpp:2785<br>
>     #4 0x148b4af in ParseValue /build/llvm/lib/AsmParser/LLParser.cpp:2898<br>
>     #5 0x148b4af in llvm::LLParser::ParseTypeAndValue(llvm::Value*&,<br>
> llvm::LLParser::PerFunctionState*)<br>
> /build/llvm/lib/AsmParser/LLParser.cpp:2904<br>
>     #6 0x148e68a in ParseTypeAndValue<br>
> /build/llvm/lib/AsmParser/LLParser.h:319<br>
>     #7 0x148e68a in ParseTypeAndBasicBlock<br>
> /build/llvm/lib/AsmParser/LLParser.cpp:2911<br>
>     #8 0x148e68a in llvm::LLParser::ParseBr(llvm::Instruction*&,<br>
> llvm::LLParser::PerFunctionState&)<br>
> /build/llvm/lib/AsmParser/LLParser.cpp:3428<br>
>     #9 0x148cce9 in llvm::LLParser::ParseInstruction(llvm::Instruction*&,<br>
> llvm::BasicBlock*, llvm::LLParser::PerFunctionState&)<br>
> /build/llvm/lib/AsmParser/LLParser.cpp:3243<br>
>     #10 0x148bdf8 in<br>
> llvm::LLParser::ParseBasicBlock(llvm::LLParser::PerFunctionState&)<br>
> /build/llvm/lib/AsmParser/LLParser.cpp:3194<br>
>     #11 0x146459f in llvm::LLParser::ParseFunctionBody(llvm::Function&)<br>
> /build/llvm/lib/AsmParser/LLParser.cpp:3147<br>
>     #12 0x1451ad1 in ParseDefine /build/llvm/lib/AsmParser/LLParser.cpp:424<br>
>     #13 0x1451ad1 in llvm::LLParser::ParseTopLevelEntities()<br>
> /build/llvm/lib/AsmParser/LLParser.cpp:226<br>
>     #14 0x145175e in llvm::LLParser::Run()<br>
> /build/llvm/lib/AsmParser/LLParser.cpp:41<br>
>     #15 0x144324b in llvm::ParseAssembly(llvm::MemoryBuffer*, llvm::Module*,<br>
> llvm::SMDiagnostic&, llvm::LLVMContext&)<br>
> /build/llvm/lib/AsmParser/Parser.cpp:38<br>
>     #16 0x11c299b in llvm::ParseIR(llvm::MemoryBuffer*, llvm::SMDiagnostic&,<br>
> llvm::LLVMContext&) /build/llvm/lib/IRReader/IRReader.cpp:76<br>
>     #17 0x11c32bc in llvm::ParseIRFile(std::string const&,<br>
> llvm::SMDiagnostic&, llvm::LLVMContext&)<br>
> /build/llvm/lib/IRReader/IRReader.cpp:88<br>
>     #18 0x617bbe in main /build/llvm/tools/opt/opt.cpp:593<br>
>     #19 0x7f285711b76c (/lib/x86_64-linux-gnu/libc.so.6+0x2176c)<br>
><br>
><br>
> On Sat, Jul 27, 2013 at 4:01 AM, Tom Stellard <<a href="mailto:thomas.stellard@amd.com">thomas.stellard@amd.com</a>><br>
> wrote:<br>
>><br>
>> Author: tstellar<br>
>> Date: Fri Jul 26 19:01:07 2013<br>
>> New Revision: 187278<br>
>><br>
>> URL: <a href="http://llvm.org/viewvc/llvm-project?rev=187278&view=rev" target="_blank">http://llvm.org/viewvc/llvm-project?rev=187278&view=rev</a><br>
>> Log:<br>
>> SimplifyCFG: Use parallel-and and parallel-or mode to consolidate branch<br>
>> conditions<br>
>><br>
>> Merge consecutive if-regions if they contain identical statements.<br>
>> Both transformations reduce number of branches.  The transformation<br>
>> is guarded by a target-hook, and is currently enabled only for +R600,<br>
>> but the correctness has been tested on X86 target using a variety of<br>
>> CPU benchmarks.<br>
>><br>
>> Patch by: Mei Ye<br>
>><br>
>> Added:<br>
>>     llvm/trunk/lib/Target/R600/AMDGPUTargetTransformInfo.cpp<br>
>> Modified:<br>
>>     llvm/trunk/include/llvm/Analysis/TargetTransformInfo.h<br>
>>     llvm/trunk/include/llvm/InitializePasses.h<br>
>>     llvm/trunk/include/llvm/Transforms/Scalar.h<br>
>>     llvm/trunk/include/llvm/Transforms/Utils/Local.h<br>
>>     llvm/trunk/lib/Analysis/TargetTransformInfo.cpp<br>
>>     llvm/trunk/lib/CodeGen/BasicTargetTransformInfo.cpp<br>
>>     llvm/trunk/lib/Target/R600/AMDGPU.h<br>
>>     llvm/trunk/lib/Target/R600/AMDGPUTargetMachine.cpp<br>
>>     llvm/trunk/lib/Target/R600/AMDGPUTargetMachine.h<br>
>>     llvm/trunk/lib/Target/R600/CMakeLists.txt<br>
>>     llvm/trunk/lib/Transforms/IPO/PassManagerBuilder.cpp<br>
>>     llvm/trunk/lib/Transforms/Scalar/Scalar.cpp<br>
>>     llvm/trunk/lib/Transforms/Scalar/SimplifyCFGPass.cpp<br>
>>     llvm/trunk/lib/Transforms/Utils/SimplifyCFG.cpp<br>
>>     llvm/trunk/tools/lto/LTOCodeGenerator.cpp<br>
>>     llvm/trunk/tools/opt/opt.cpp<br>
>><br>
>> Modified: llvm/trunk/include/llvm/Analysis/TargetTransformInfo.h<br>
>> URL:<br>
>> <a href="http://llvm.org/viewvc/llvm-project/llvm/trunk/include/llvm/Analysis/TargetTransformInfo.h?rev=187278&r1=187277&r2=187278&view=diff" target="_blank">http://llvm.org/viewvc/llvm-project/llvm/trunk/include/llvm/Analysis/TargetTransformInfo.h?rev=187278&r1=187277&r2=187278&view=diff</a><br>

>><br>
>> ==============================================================================<br>
>> --- llvm/trunk/include/llvm/Analysis/TargetTransformInfo.h (original)<br>
>> +++ llvm/trunk/include/llvm/Analysis/TargetTransformInfo.h Fri Jul 26<br>
>> 19:01:07 2013<br>
>> @@ -171,6 +171,12 @@ public:<br>
>>    /// comments for a detailed explanation of the cost values.<br>
>>    virtual unsigned getUserCost(const User *U) const;<br>
>><br>
>> +  /// \brief hasBranchDivergence - Return true if branch divergence<br>
>> exists.<br>
>> +  /// Branch divergence has a significantly negative impact on GPU<br>
>> performance<br>
>> +  /// when threads in the same wavefront take different paths due to<br>
>> conditional<br>
>> +  /// branches.<br>
>> +  virtual bool hasBranchDivergence() const;<br>
>> +<br>
>>    /// \brief Test whether calls to a function lower to actual program<br>
>> function<br>
>>    /// calls.<br>
>>    ///<br>
>><br>
>> Modified: llvm/trunk/include/llvm/InitializePasses.h<br>
>> URL:<br>
>> <a href="http://llvm.org/viewvc/llvm-project/llvm/trunk/include/llvm/InitializePasses.h?rev=187278&r1=187277&r2=187278&view=diff" target="_blank">http://llvm.org/viewvc/llvm-project/llvm/trunk/include/llvm/InitializePasses.h?rev=187278&r1=187277&r2=187278&view=diff</a><br>

>><br>
>> ==============================================================================<br>
>> --- llvm/trunk/include/llvm/InitializePasses.h (original)<br>
>> +++ llvm/trunk/include/llvm/InitializePasses.h Fri Jul 26 19:01:07 2013<br>
>> @@ -86,7 +86,8 @@ void initializeCallGraphViewerPass(PassR<br>
>>  void initializeCFGOnlyPrinterPass(PassRegistry&);<br>
>>  void initializeCFGOnlyViewerPass(PassRegistry&);<br>
>>  void initializeCFGPrinterPass(PassRegistry&);<br>
>> -void initializeCFGSimplifyPassPass(PassRegistry&);<br>
>> +void initializeCFGOptimizePass(PassRegistry&);<br>
>> +void initializeCFGCanonicalizePass(PassRegistry&);<br>
>>  void initializeStructurizeCFGPass(PassRegistry&);<br>
>>  void initializeCFGViewerPass(PassRegistry&);<br>
>>  void initializeCalculateSpillWeightsPass(PassRegistry&);<br>
>><br>
>> Modified: llvm/trunk/include/llvm/Transforms/Scalar.h<br>
>> URL:<br>
>> <a href="http://llvm.org/viewvc/llvm-project/llvm/trunk/include/llvm/Transforms/Scalar.h?rev=187278&r1=187277&r2=187278&view=diff" target="_blank">http://llvm.org/viewvc/llvm-project/llvm/trunk/include/llvm/Transforms/Scalar.h?rev=187278&r1=187277&r2=187278&view=diff</a><br>

>><br>
>> ==============================================================================<br>
>> --- llvm/trunk/include/llvm/Transforms/Scalar.h (original)<br>
>> +++ llvm/trunk/include/llvm/Transforms/Scalar.h Fri Jul 26 19:01:07 2013<br>
>> @@ -196,7 +196,7 @@ FunctionPass *createJumpThreadingPass();<br>
>>  // CFGSimplification - Merge basic blocks, eliminate unreachable blocks,<br>
>>  // simplify terminator instructions, etc...<br>
>>  //<br>
>> -FunctionPass *createCFGSimplificationPass();<br>
>> +FunctionPass *createCFGSimplificationPass(bool IsTargetAware = false);<br>
>><br>
>><br>
>> //===----------------------------------------------------------------------===//<br>
>>  //<br>
>><br>
>> Modified: llvm/trunk/include/llvm/Transforms/Utils/Local.h<br>
>> URL:<br>
>> <a href="http://llvm.org/viewvc/llvm-project/llvm/trunk/include/llvm/Transforms/Utils/Local.h?rev=187278&r1=187277&r2=187278&view=diff" target="_blank">http://llvm.org/viewvc/llvm-project/llvm/trunk/include/llvm/Transforms/Utils/Local.h?rev=187278&r1=187277&r2=187278&view=diff</a><br>

>><br>
>> ==============================================================================<br>
>> --- llvm/trunk/include/llvm/Transforms/Utils/Local.h (original)<br>
>> +++ llvm/trunk/include/llvm/Transforms/Utils/Local.h Fri Jul 26 19:01:07<br>
>> 2013<br>
>> @@ -39,6 +39,7 @@ class DataLayout;<br>
>>  class TargetLibraryInfo;<br>
>>  class TargetTransformInfo;<br>
>>  class DIBuilder;<br>
>> +class AliasAnalysis;<br>
>><br>
>>  template<typename T> class SmallVectorImpl;<br>
>><br>
>> @@ -136,7 +137,7 @@ bool EliminateDuplicatePHINodes(BasicBlo<br>
>>  /// the basic block that was pointed to.<br>
>>  ///<br>
>>  bool SimplifyCFG(BasicBlock *BB, const TargetTransformInfo &TTI,<br>
>> -                 const DataLayout *TD = 0);<br>
>> +                 const DataLayout *TD = 0, AliasAnalysis *AA = 0);<br>
>><br>
>>  /// FoldBranchToCommonDest - If this basic block is ONLY a setcc and a<br>
>> branch,<br>
>>  /// and if a predecessor branches to us and one of our successors, fold<br>
>> the<br>
>><br>
>> Modified: llvm/trunk/lib/Analysis/TargetTransformInfo.cpp<br>
>> URL:<br>
>> <a href="http://llvm.org/viewvc/llvm-project/llvm/trunk/lib/Analysis/TargetTransformInfo.cpp?rev=187278&r1=187277&r2=187278&view=diff" target="_blank">http://llvm.org/viewvc/llvm-project/llvm/trunk/lib/Analysis/TargetTransformInfo.cpp?rev=187278&r1=187277&r2=187278&view=diff</a><br>

>><br>
>> ==============================================================================<br>
>> --- llvm/trunk/lib/Analysis/TargetTransformInfo.cpp (original)<br>
>> +++ llvm/trunk/lib/Analysis/TargetTransformInfo.cpp Fri Jul 26 19:01:07<br>
>> 2013<br>
>> @@ -88,6 +88,10 @@ unsigned TargetTransformInfo::getUserCos<br>
>>    return PrevTTI->getUserCost(U);<br>
>>  }<br>
>><br>
>> +bool TargetTransformInfo::hasBranchDivergence() const {<br>
>> +  return PrevTTI->hasBranchDivergence();<br>
>> +}<br>
>> +<br>
>>  bool TargetTransformInfo::isLoweredToCall(const Function *F) const {<br>
>>    return PrevTTI->isLoweredToCall(F);<br>
>>  }<br>
>> @@ -420,6 +424,8 @@ struct NoTTI : ImmutablePass, TargetTran<br>
>>                                  U->getOperand(0)->getType() : 0);<br>
>>    }<br>
>><br>
>> +  bool hasBranchDivergence() const { return false; }<br>
>> +<br>
>>    bool isLoweredToCall(const Function *F) const {<br>
>>      // FIXME: These should almost certainly not be handled here, and<br>
>> instead<br>
>>      // handled with the help of TLI or the target itself. This was<br>
>> largely<br>
>><br>
>> Modified: llvm/trunk/lib/CodeGen/BasicTargetTransformInfo.cpp<br>
>> URL:<br>
>> <a href="http://llvm.org/viewvc/llvm-project/llvm/trunk/lib/CodeGen/BasicTargetTransformInfo.cpp?rev=187278&r1=187277&r2=187278&view=diff" target="_blank">http://llvm.org/viewvc/llvm-project/llvm/trunk/lib/CodeGen/BasicTargetTransformInfo.cpp?rev=187278&r1=187277&r2=187278&view=diff</a><br>

>><br>
>> ==============================================================================<br>
>> --- llvm/trunk/lib/CodeGen/BasicTargetTransformInfo.cpp (original)<br>
>> +++ llvm/trunk/lib/CodeGen/BasicTargetTransformInfo.cpp Fri Jul 26<br>
>> 19:01:07 2013<br>
>> @@ -65,6 +65,8 @@ public:<br>
>>      return this;<br>
>>    }<br>
>><br>
>> +  virtual bool hasBranchDivergence() const;<br>
>> +<br>
>>    /// \name Scalar TTI Implementations<br>
>>    /// @{<br>
>><br>
>> @@ -124,6 +126,7 @@ llvm::createBasicTargetTransformInfoPass<br>
>>    return new BasicTTI(TM);<br>
>>  }<br>
>><br>
>> +bool BasicTTI::hasBranchDivergence() const { return false; }<br>
>><br>
>>  bool BasicTTI::isLegalAddImmediate(int64_t imm) const {<br>
>>    return getTLI()->isLegalAddImmediate(imm);<br>
>><br>
>> Modified: llvm/trunk/lib/Target/R600/AMDGPU.h<br>
>> URL:<br>
>> <a href="http://llvm.org/viewvc/llvm-project/llvm/trunk/lib/Target/R600/AMDGPU.h?rev=187278&r1=187277&r2=187278&view=diff" target="_blank">http://llvm.org/viewvc/llvm-project/llvm/trunk/lib/Target/R600/AMDGPU.h?rev=187278&r1=187277&r2=187278&view=diff</a><br>

>><br>
>> ==============================================================================<br>
>> --- llvm/trunk/lib/Target/R600/AMDGPU.h (original)<br>
>> +++ llvm/trunk/lib/Target/R600/AMDGPU.h Fri Jul 26 19:01:07 2013<br>
>> @@ -45,6 +45,10 @@ FunctionPass *createAMDGPUConvertToISAPa<br>
>>  FunctionPass *createAMDGPUIndirectAddressingPass(TargetMachine &tm);<br>
>>  FunctionPass *createAMDGPUISelDag(TargetMachine &tm);<br>
>><br>
>> +/// \brief Creates an AMDGPU-specific Target Transformation Info pass.<br>
>> +ImmutablePass *<br>
>> +createAMDGPUTargetTransformInfoPass(const AMDGPUTargetMachine *TM);<br>
>> +<br>
>>  extern Target TheAMDGPUTarget;<br>
>><br>
>>  } // End namespace llvm<br>
>><br>
>> Modified: llvm/trunk/lib/Target/R600/AMDGPUTargetMachine.cpp<br>
>> URL:<br>
>> <a href="http://llvm.org/viewvc/llvm-project/llvm/trunk/lib/Target/R600/AMDGPUTargetMachine.cpp?rev=187278&r1=187277&r2=187278&view=diff" target="_blank">http://llvm.org/viewvc/llvm-project/llvm/trunk/lib/Target/R600/AMDGPUTargetMachine.cpp?rev=187278&r1=187277&r2=187278&view=diff</a><br>

>><br>
>> ==============================================================================<br>
>> --- llvm/trunk/lib/Target/R600/AMDGPUTargetMachine.cpp (original)<br>
>> +++ llvm/trunk/lib/Target/R600/AMDGPUTargetMachine.cpp Fri Jul 26 19:01:07<br>
>> 2013<br>
>> @@ -105,6 +105,18 @@ TargetPassConfig *AMDGPUTargetMachine::c<br>
>>    return new AMDGPUPassConfig(this, PM);<br>
>>  }<br>
>><br>
>><br>
>> +//===----------------------------------------------------------------------===//<br>
>> +// AMDGPU Analysis Pass Setup<br>
>><br>
>> +//===----------------------------------------------------------------------===//<br>
>> +<br>
>> +void AMDGPUTargetMachine::addAnalysisPasses(PassManagerBase &PM) {<br>
>> +  // Add first the target-independent BasicTTI pass, then our AMDGPU<br>
>> pass. This<br>
>> +  // allows the AMDGPU pass to delegate to the target independent layer<br>
>> when<br>
>> +  // appropriate.<br>
>> +  PM.add(createBasicTargetTransformInfoPass(this));<br>
>> +  PM.add(createAMDGPUTargetTransformInfoPass(this));<br>
>> +}<br>
>> +<br>
>>  bool<br>
>>  AMDGPUPassConfig::addPreISel() {<br>
>>    const AMDGPUSubtarget &ST = TM->getSubtarget<AMDGPUSubtarget>();<br>
>><br>
>> Modified: llvm/trunk/lib/Target/R600/AMDGPUTargetMachine.h<br>
>> URL:<br>
>> <a href="http://llvm.org/viewvc/llvm-project/llvm/trunk/lib/Target/R600/AMDGPUTargetMachine.h?rev=187278&r1=187277&r2=187278&view=diff" target="_blank">http://llvm.org/viewvc/llvm-project/llvm/trunk/lib/Target/R600/AMDGPUTargetMachine.h?rev=187278&r1=187277&r2=187278&view=diff</a><br>

>><br>
>> ==============================================================================<br>
>> --- llvm/trunk/lib/Target/R600/AMDGPUTargetMachine.h (original)<br>
>> +++ llvm/trunk/lib/Target/R600/AMDGPUTargetMachine.h Fri Jul 26 19:01:07<br>
>> 2013<br>
>> @@ -61,6 +61,9 @@ public:<br>
>>    }<br>
>>    virtual const DataLayout *getDataLayout() const { return &Layout; }<br>
>>    virtual TargetPassConfig *createPassConfig(PassManagerBase &PM);<br>
>> +<br>
>> +  /// \brief Register R600 analysis passes with a pass manager.<br>
>> +  virtual void addAnalysisPasses(PassManagerBase &PM);<br>
>>  };<br>
>><br>
>>  } // End namespace llvm<br>
>><br>
>> Added: llvm/trunk/lib/Target/R600/AMDGPUTargetTransformInfo.cpp<br>
>> URL:<br>
>> <a href="http://llvm.org/viewvc/llvm-project/llvm/trunk/lib/Target/R600/AMDGPUTargetTransformInfo.cpp?rev=187278&view=auto" target="_blank">http://llvm.org/viewvc/llvm-project/llvm/trunk/lib/Target/R600/AMDGPUTargetTransformInfo.cpp?rev=187278&view=auto</a><br>

>><br>
>> ==============================================================================<br>
>> --- llvm/trunk/lib/Target/R600/AMDGPUTargetTransformInfo.cpp (added)<br>
>> +++ llvm/trunk/lib/Target/R600/AMDGPUTargetTransformInfo.cpp Fri Jul 26<br>
>> 19:01:07 2013<br>
>> @@ -0,0 +1,90 @@<br>
>> +//===-- AMDGPUTargetTransformInfo.cpp - AMDGPU specific TTI pass<br>
>> ---------===//<br>
>> +//<br>
>> +//                     The LLVM Compiler Infrastructure<br>
>> +//<br>
>> +// This file is distributed under the University of Illinois Open Source<br>
>> +// License. See LICENSE.TXT for details.<br>
>> +//<br>
>><br>
>> +//===----------------------------------------------------------------------===//<br>
>> +//<br>
>> +// \file<br>
>> +// This file implements a TargetTransformInfo analysis pass specific to<br>
>> the<br>
>> +// AMDGPU target machine. It uses the target's detailed information to<br>
>> provide<br>
>> +// more precise answers to certain TTI queries, while letting the target<br>
>> +// independent and default TTI implementations handle the rest.<br>
>> +//<br>
>><br>
>> +//===----------------------------------------------------------------------===//<br>
>> +<br>
>> +#define DEBUG_TYPE "AMDGPUtti"<br>
>> +#include "AMDGPU.h"<br>
>> +#include "AMDGPUTargetMachine.h"<br>
>> +#include "llvm/Analysis/TargetTransformInfo.h"<br>
>> +#include "llvm/Support/Debug.h"<br>
>> +#include "llvm/Target/TargetLowering.h"<br>
>> +#include "llvm/Target/CostTable.h"<br>
>> +using namespace llvm;<br>
>> +<br>
>> +// Declare the pass initialization routine locally as target-specific<br>
>> passes<br>
>> +// don't have a target-wide initialization entry point, and so we rely on<br>
>> the<br>
>> +// pass constructor initialization.<br>
>> +namespace llvm {<br>
>> +void initializeAMDGPUTTIPass(PassRegistry &);<br>
>> +}<br>
>> +<br>
>> +namespace {<br>
>> +<br>
>> +class AMDGPUTTI : public ImmutablePass, public TargetTransformInfo {<br>
>> +  const AMDGPUTargetMachine *TM;<br>
>> +  const AMDGPUSubtarget *ST;<br>
>> +  const AMDGPUTargetLowering *TLI;<br>
>> +<br>
>> +  /// Estimate the overhead of scalarizing an instruction. Insert and<br>
>> Extract<br>
>> +  /// are set if the result needs to be inserted and/or extracted from<br>
>> vectors.<br>
>> +  unsigned getScalarizationOverhead(Type *Ty, bool Insert, bool Extract)<br>
>> const;<br>
>> +<br>
>> +public:<br>
>> +  AMDGPUTTI() : ImmutablePass(ID), TM(0), ST(0), TLI(0) {<br>
>> +    llvm_unreachable("This pass cannot be directly constructed");<br>
>> +  }<br>
>> +<br>
>> +  AMDGPUTTI(const AMDGPUTargetMachine *TM)<br>
>> +      : ImmutablePass(ID), TM(TM), ST(TM->getSubtargetImpl()),<br>
>> +        TLI(TM->getTargetLowering()) {<br>
>> +    initializeAMDGPUTTIPass(*PassRegistry::getPassRegistry());<br>
>> +  }<br>
>> +<br>
>> +  virtual void initializePass() { pushTTIStack(this); }<br>
>> +<br>
>> +  virtual void finalizePass() { popTTIStack(); }<br>
>> +<br>
>> +  virtual void getAnalysisUsage(AnalysisUsage &AU) const {<br>
>> +    TargetTransformInfo::getAnalysisUsage(AU);<br>
>> +  }<br>
>> +<br>
>> +  /// Pass identification.<br>
>> +  static char ID;<br>
>> +<br>
>> +  /// Provide necessary pointer adjustments for the two base classes.<br>
>> +  virtual void *getAdjustedAnalysisPointer(const void *ID) {<br>
>> +    if (ID == &TargetTransformInfo::ID)<br>
>> +      return (TargetTransformInfo *)this;<br>
>> +    return this;<br>
>> +  }<br>
>> +<br>
>> +  virtual bool hasBranchDivergence() const;<br>
>> +<br>
>> +  /// @}<br>
>> +};<br>
>> +<br>
>> +} // end anonymous namespace<br>
>> +<br>
>> +INITIALIZE_AG_PASS(AMDGPUTTI, TargetTransformInfo, "AMDGPUtti",<br>
>> +                   "AMDGPU Target Transform Info", true, true, false)<br>
>> +char AMDGPUTTI::ID = 0;<br>
>> +<br>
>> +ImmutablePass *<br>
>> +llvm::createAMDGPUTargetTransformInfoPass(const AMDGPUTargetMachine *TM)<br>
>> {<br>
>> +  return new AMDGPUTTI(TM);<br>
>> +}<br>
>> +<br>
>> +bool AMDGPUTTI::hasBranchDivergence() const { return true; }<br>
>><br>
>> Modified: llvm/trunk/lib/Target/R600/CMakeLists.txt<br>
>> URL:<br>
>> <a href="http://llvm.org/viewvc/llvm-project/llvm/trunk/lib/Target/R600/CMakeLists.txt?rev=187278&r1=187277&r2=187278&view=diff" target="_blank">http://llvm.org/viewvc/llvm-project/llvm/trunk/lib/Target/R600/CMakeLists.txt?rev=187278&r1=187277&r2=187278&view=diff</a><br>

>><br>
>> ==============================================================================<br>
>> --- llvm/trunk/lib/Target/R600/CMakeLists.txt (original)<br>
>> +++ llvm/trunk/lib/Target/R600/CMakeLists.txt Fri Jul 26 19:01:07 2013<br>
>> @@ -23,6 +23,7 @@ add_llvm_target(R600CodeGen<br>
>>    AMDGPUMachineFunction.cpp<br>
>>    AMDGPUSubtarget.cpp<br>
>>    AMDGPUTargetMachine.cpp<br>
>> +  AMDGPUTargetTransformInfo.cpp<br>
>>    AMDGPUISelLowering.cpp<br>
>>    AMDGPUConvertToISA.cpp<br>
>>    AMDGPUInstrInfo.cpp<br>
>><br>
>> Modified: llvm/trunk/lib/Transforms/IPO/PassManagerBuilder.cpp<br>
>> URL:<br>
>> <a href="http://llvm.org/viewvc/llvm-project/llvm/trunk/lib/Transforms/IPO/PassManagerBuilder.cpp?rev=187278&r1=187277&r2=187278&view=diff" target="_blank">http://llvm.org/viewvc/llvm-project/llvm/trunk/lib/Transforms/IPO/PassManagerBuilder.cpp?rev=187278&r1=187277&r2=187278&view=diff</a><br>

>><br>
>> ==============================================================================<br>
>> --- llvm/trunk/lib/Transforms/IPO/PassManagerBuilder.cpp (original)<br>
>> +++ llvm/trunk/lib/Transforms/IPO/PassManagerBuilder.cpp Fri Jul 26<br>
>> 19:01:07 2013<br>
>> @@ -235,7 +235,7 @@ void PassManagerBuilder::populateModuleP<br>
>>    }<br>
>><br>
>>    MPM.add(createAggressiveDCEPass());         // Delete dead instructions<br>
>> -  MPM.add(createCFGSimplificationPass());     // Merge & remove BBs<br>
>> +  MPM.add(createCFGSimplificationPass(true)); // Merge & remove BBs<br>
>>    MPM.add(createInstructionCombiningPass());  // Clean up after<br>
>> everything.<br>
>><br>
>>    // As an experimental mode, run any vectorization passes in a separate<br>
>> @@ -371,7 +371,7 @@ void PassManagerBuilder::populateLTOPass<br>
>>    PM.add(createJumpThreadingPass());<br>
>><br>
>>    // Delete basic blocks, which optimization passes may have killed.<br>
>> -  PM.add(createCFGSimplificationPass());<br>
>> +  PM.add(createCFGSimplificationPass(true));<br>
>><br>
>>    // Now that we have optimized the program, discard unreachable<br>
>> functions.<br>
>>    PM.add(createGlobalDCEPass());<br>
>><br>
>> Modified: llvm/trunk/lib/Transforms/Scalar/Scalar.cpp<br>
>> URL:<br>
>> <a href="http://llvm.org/viewvc/llvm-project/llvm/trunk/lib/Transforms/Scalar/Scalar.cpp?rev=187278&r1=187277&r2=187278&view=diff" target="_blank">http://llvm.org/viewvc/llvm-project/llvm/trunk/lib/Transforms/Scalar/Scalar.cpp?rev=187278&r1=187277&r2=187278&view=diff</a><br>

>><br>
>> ==============================================================================<br>
>> --- llvm/trunk/lib/Transforms/Scalar/Scalar.cpp (original)<br>
>> +++ llvm/trunk/lib/Transforms/Scalar/Scalar.cpp Fri Jul 26 19:01:07 2013<br>
>> @@ -57,7 +57,8 @@ void llvm::initializeScalarOpts(PassRegi<br>
>>    initializeSROAPass(Registry);<br>
>>    initializeSROA_DTPass(Registry);<br>
>>    initializeSROA_SSAUpPass(Registry);<br>
>> -  initializeCFGSimplifyPassPass(Registry);<br>
>> +  initializeCFGCanonicalizePass(Registry);<br>
>> +  initializeCFGOptimizePass(Registry);<br>
>>    initializeStructurizeCFGPass(Registry);<br>
>>    initializeSinkingPass(Registry);<br>
>>    initializeTailCallElimPass(Registry);<br>
>><br>
>> Modified: llvm/trunk/lib/Transforms/Scalar/SimplifyCFGPass.cpp<br>
>> URL:<br>
>> <a href="http://llvm.org/viewvc/llvm-project/llvm/trunk/lib/Transforms/Scalar/SimplifyCFGPass.cpp?rev=187278&r1=187277&r2=187278&view=diff" target="_blank">http://llvm.org/viewvc/llvm-project/llvm/trunk/lib/Transforms/Scalar/SimplifyCFGPass.cpp?rev=187278&r1=187277&r2=187278&view=diff</a><br>

>><br>
>> ==============================================================================<br>
>> --- llvm/trunk/lib/Transforms/Scalar/SimplifyCFGPass.cpp (original)<br>
>> +++ llvm/trunk/lib/Transforms/Scalar/SimplifyCFGPass.cpp Fri Jul 26<br>
>> 19:01:07 2013<br>
>> @@ -27,6 +27,7 @@<br>
>>  #include "llvm/ADT/SmallVector.h"<br>
>>  #include "llvm/ADT/Statistic.h"<br>
>>  #include "llvm/Analysis/TargetTransformInfo.h"<br>
>> +#include "llvm/Analysis/AliasAnalysis.h"<br>
>>  #include "llvm/IR/Attributes.h"<br>
>>  #include "llvm/IR/Constants.h"<br>
>>  #include "llvm/IR/DataLayout.h"<br>
>> @@ -41,30 +42,62 @@ using namespace llvm;<br>
>>  STATISTIC(NumSimpl, "Number of blocks simplified");<br>
>><br>
>>  namespace {<br>
>> -  struct CFGSimplifyPass : public FunctionPass {<br>
>> -    static char ID; // Pass identification, replacement for typeid<br>
>> -    CFGSimplifyPass() : FunctionPass(ID) {<br>
>> -      initializeCFGSimplifyPassPass(*PassRegistry::getPassRegistry());<br>
>> -    }<br>
>> +struct CFGSimplifyPass : public FunctionPass {<br>
>> +  CFGSimplifyPass(char &ID, bool isTargetAware)<br>
>> +      : FunctionPass(ID), IsTargetAware(isTargetAware) {}<br>
>> +  virtual bool runOnFunction(Function &F);<br>
>><br>
>> -    virtual bool runOnFunction(Function &F);<br>
>> +  virtual void getAnalysisUsage(AnalysisUsage &AU) const {<br>
>> +    AU.addRequired<TargetTransformInfo>();<br>
>> +  }<br>
>> +private:<br>
>> +  AliasAnalysis *AA;<br>
>> +  bool IsTargetAware; // Should the pass be target-aware?<br>
>> +};<br>
>> +<br>
>> +// CFGSimplifyPass that does optimizations.<br>
>> +struct CFGOptimize : public CFGSimplifyPass {<br>
>> +  static char ID; // Pass identification, replacement for typeid<br>
>> +public:<br>
>> +  CFGOptimize() : CFGSimplifyPass(ID, true) {<br>
>> +    initializeCFGOptimizePass(*PassRegistry::getPassRegistry());<br>
>> +  }<br>
>> +  virtual void getAnalysisUsage(AnalysisUsage &AU) const {<br>
>> +    AU.addRequired<TargetTransformInfo>();<br>
>> +    AU.addRequired<AliasAnalysis>();<br>
>> +  }<br>
>> +};<br>
>><br>
>> -    virtual void getAnalysisUsage(AnalysisUsage &AU) const {<br>
>> -      AU.addRequired<TargetTransformInfo>();<br>
>> -    }<br>
>> -  };<br>
>> +// CFGSimplifyPass that does canonicalizations.<br>
>> +struct CFGCanonicalize : public CFGSimplifyPass {<br>
>> +  static char ID; // Pass identification, replacement for typeid<br>
>> +public:<br>
>> +  CFGCanonicalize() : CFGSimplifyPass(ID, false) {<br>
>> +    initializeCFGCanonicalizePass(*PassRegistry::getPassRegistry());<br>
>> +  }<br>
>> +};<br>
>>  }<br>
>><br>
>> -char CFGSimplifyPass::ID = 0;<br>
>> -INITIALIZE_PASS_BEGIN(CFGSimplifyPass, "simplifycfg", "Simplify the CFG",<br>
>> -                      false, false)<br>
>> +char CFGCanonicalize::ID = 0;<br>
>> +char CFGOptimize::ID = 0;<br>
>> +INITIALIZE_PASS_BEGIN(CFGCanonicalize, "simplifycfg", "Simplify the CFG",<br>
>> false,<br>
>> +                      false)<br>
>> +INITIALIZE_AG_DEPENDENCY(TargetTransformInfo)<br>
>> +INITIALIZE_PASS_END(CFGCanonicalize, "simplifycfg", "Simplify the CFG",<br>
>> false,<br>
>> +                    false)<br>
>> +INITIALIZE_PASS_BEGIN(CFGOptimize, "optimizecfg", "optimize the CFG",<br>
>> false,<br>
>> +                      false)<br>
>>  INITIALIZE_AG_DEPENDENCY(TargetTransformInfo)<br>
>> -INITIALIZE_PASS_END(CFGSimplifyPass, "simplifycfg", "Simplify the CFG",<br>
>> -                    false, false)<br>
>> +INITIALIZE_AG_DEPENDENCY(AliasAnalysis)<br>
>> +INITIALIZE_PASS_END(CFGOptimize, "optimizecfg", "Optimize the CFG",<br>
>> false,<br>
>> +                    false)<br>
>><br>
>>  // Public interface to the CFGSimplification pass<br>
>> -FunctionPass *llvm::createCFGSimplificationPass() {<br>
>> -  return new CFGSimplifyPass();<br>
>> +FunctionPass *llvm::createCFGSimplificationPass(bool IsTargetAware) {<br>
>> +  if (IsTargetAware)<br>
>> +    return new CFGOptimize();<br>
>> +  else<br>
>> +    return new CFGCanonicalize();<br>
>>  }<br>
>><br>
>>  /// changeToUnreachable - Insert an unreachable instruction before the<br>
>> specified<br>
>> @@ -301,7 +334,7 @@ static bool mergeEmptyReturnBlocks(Funct<br>
>>  /// iterativelySimplifyCFG - Call SimplifyCFG on all the blocks in the<br>
>> function,<br>
>>  /// iterating until no more changes are made.<br>
>>  static bool iterativelySimplifyCFG(Function &F, const TargetTransformInfo<br>
>> &TTI,<br>
>> -                                   const DataLayout *TD) {<br>
>> +                                   const DataLayout *TD, AliasAnalysis<br>
>> *AA) {<br>
>>    bool Changed = false;<br>
>>    bool LocalChange = true;<br>
>>    while (LocalChange) {<br>
>> @@ -310,7 +343,7 @@ static bool iterativelySimplifyCFG(Funct<br>
>>      // Loop over all of the basic blocks and remove them if they are<br>
>> unneeded...<br>
>>      //<br>
>>      for (Function::iterator BBIt = F.begin(); BBIt != F.end(); ) {<br>
>> -      if (SimplifyCFG(BBIt++, TTI, TD)) {<br>
>> +      if (SimplifyCFG(BBIt++, TTI, TD, AA)) {<br>
>>          LocalChange = true;<br>
>>          ++NumSimpl;<br>
>>        }<br>
>> @@ -324,11 +357,15 @@ static bool iterativelySimplifyCFG(Funct<br>
>>  // simplify the CFG.<br>
>>  //<br>
>>  bool CFGSimplifyPass::runOnFunction(Function &F) {<br>
>> +  if (IsTargetAware)<br>
>> +    AA = &getAnalysis<AliasAnalysis>();<br>
>> +  else<br>
>> +    AA = NULL;<br>
>>    const TargetTransformInfo &TTI = getAnalysis<TargetTransformInfo>();<br>
>>    const DataLayout *TD = getAnalysisIfAvailable<DataLayout>();<br>
>>    bool EverChanged = removeUnreachableBlocksFromFn(F);<br>
>>    EverChanged |= mergeEmptyReturnBlocks(F);<br>
>> -  EverChanged |= iterativelySimplifyCFG(F, TTI, TD);<br>
>> +  EverChanged |= iterativelySimplifyCFG(F, TTI, TD, AA);<br>
>><br>
>>    // If neither pass changed anything, we're done.<br>
>>    if (!EverChanged) return false;<br>
>> @@ -342,7 +379,7 @@ bool CFGSimplifyPass::runOnFunction(Func<br>
>>      return true;<br>
>><br>
>>    do {<br>
>> -    EverChanged = iterativelySimplifyCFG(F, TTI, TD);<br>
>> +    EverChanged = iterativelySimplifyCFG(F, TTI, TD, AA);<br>
>>      EverChanged |= removeUnreachableBlocksFromFn(F);<br>
>>    } while (EverChanged);<br>
>><br>
>><br>
>> Modified: llvm/trunk/lib/Transforms/Utils/SimplifyCFG.cpp<br>
>> URL:<br>
>> <a href="http://llvm.org/viewvc/llvm-project/llvm/trunk/lib/Transforms/Utils/SimplifyCFG.cpp?rev=187278&r1=187277&r2=187278&view=diff" target="_blank">http://llvm.org/viewvc/llvm-project/llvm/trunk/lib/Transforms/Utils/SimplifyCFG.cpp?rev=187278&r1=187277&r2=187278&view=diff</a><br>

>><br>
>> ==============================================================================<br>
>> --- llvm/trunk/lib/Transforms/Utils/SimplifyCFG.cpp (original)<br>
>> +++ llvm/trunk/lib/Transforms/Utils/SimplifyCFG.cpp Fri Jul 26 19:01:07<br>
>> 2013<br>
>> @@ -19,6 +19,7 @@<br>
>>  #include "llvm/ADT/SmallPtrSet.h"<br>
>>  #include "llvm/ADT/SmallVector.h"<br>
>>  #include "llvm/ADT/Statistic.h"<br>
>> +#include "llvm/Analysis/AliasAnalysis.h"<br>
>>  #include "llvm/Analysis/InstructionSimplify.h"<br>
>>  #include "llvm/Analysis/TargetTransformInfo.h"<br>
>>  #include "llvm/Analysis/ValueTracking.h"<br>
>> @@ -65,6 +66,10 @@ static cl::opt<bool><br>
>>  HoistCondStores("simplifycfg-hoist-cond-stores", cl::Hidden,<br>
>> cl::init(true),<br>
>>         cl::desc("Hoist conditional stores if an unconditional store<br>
>> preceeds"));<br>
>><br>
>> +static cl::opt<bool><br>
>> +ParallelAndOr("simplifycfg-parallel-and-or", cl::Hidden, cl::init(true),<br>
>> +              cl::desc("Use parallel-and-or mode for branch<br>
>> conditions"));<br>
>> +<br>
>>  STATISTIC(NumBitMaps, "Number of switch instructions turned into<br>
>> bitmaps");<br>
>>  STATISTIC(NumLookupTables, "Number of switch instructions turned into<br>
>> lookup tables");<br>
>>  STATISTIC(NumSinkCommons, "Number of common instructions sunk down to the<br>
>> end block");<br>
>> @@ -90,6 +95,7 @@ namespace {<br>
>>  class SimplifyCFGOpt {<br>
>>    const TargetTransformInfo &TTI;<br>
>>    const DataLayout *const TD;<br>
>> +  AliasAnalysis *AA;<br>
>><br>
>>    Value *isValueEqualityComparison(TerminatorInst *TI);<br>
>>    BasicBlock *GetValueEqualityComparisonCases(TerminatorInst *TI,<br>
>> @@ -107,10 +113,25 @@ class SimplifyCFGOpt {<br>
>>    bool SimplifyIndirectBr(IndirectBrInst *IBI);<br>
>>    bool SimplifyUncondBranch(BranchInst *BI, IRBuilder <> &Builder);<br>
>>    bool SimplifyCondBranch(BranchInst *BI, IRBuilder <>&Builder);<br>
>> +  /// \brief Use parallel-and or parallel-or to generate conditions for<br>
>> +  /// conditional branches.<br>
>> +  bool SimplifyParallelAndOr(BasicBlock *BB, IRBuilder<> &Builder, Pass<br>
>> *P = 0);<br>
>> +  /// \brief If \param BB is the merge block of an if-region, attempt to<br>
>> merge<br>
>> +  /// the if-region with an adjacent if-region upstream if two if-regions<br>
>> +  /// contain identical instructions.<br>
>> +  bool MergeIfRegion(BasicBlock *BB, IRBuilder<> &Builder, Pass *P = 0);<br>
>> +  /// \brief Compare a pair of blocks: \param Block1 and \param Block2,<br>
>> which<br>
>> +  /// are from two if-regions whose entry blocks are \param Head1 and<br>
>> \param<br>
>> +  /// Head2.  \returns true if \param Block1 and \param Block2 contain<br>
>> identical<br>
>> +  /// instructions, and have no memory reference alias with \param Head2.<br>
>> +  /// This is used as a legality check for merging if-regions.<br>
>> +  bool CompareIfRegionBlock(BasicBlock *Head1, BasicBlock *Head2,<br>
>> +                            BasicBlock *Block1, BasicBlock *Block2);<br>
>><br>
>>  public:<br>
>> -  SimplifyCFGOpt(const TargetTransformInfo &TTI, const DataLayout *TD)<br>
>> -      : TTI(TTI), TD(TD) {}<br>
>> +  SimplifyCFGOpt(const TargetTransformInfo &TTI, const DataLayout *TD,<br>
>> +                 AliasAnalysis *AA)<br>
>> +      : TTI(TTI), TD(TD), AA(AA) {}<br>
>>    bool run(BasicBlock *BB);<br>
>>  };<br>
>>  }<br>
>> @@ -197,8 +218,8 @@ static void AddPredecessorToBlock(BasicB<br>
>>  }<br>
>><br>
>><br>
>> -/// GetIfCondition - Given a basic block (BB) with two predecessors (and<br>
>> at<br>
>> -/// least one PHI node in it), check to see if the merge at this block is<br>
>> due<br>
>> +/// GetIfCondition - Given a basic block (BB) with two predecessors,<br>
>> +/// check to see if the merge at this block is due<br>
>>  /// to an "if condition".  If so, return the boolean condition that<br>
>> determines<br>
>>  /// which entry into BB will be taken.  Also, return by references the<br>
>> block<br>
>>  /// that will be entered from if the condition is true, and the block<br>
>> that will<br>
>> @@ -208,11 +229,26 @@ static void AddPredecessorToBlock(BasicB<br>
>>  /// instructions in them.<br>
>>  static Value *GetIfCondition(BasicBlock *BB, BasicBlock *&IfTrue,<br>
>>                               BasicBlock *&IfFalse) {<br>
>> -  PHINode *SomePHI = cast<PHINode>(BB->begin());<br>
>> -  assert(SomePHI->getNumIncomingValues() == 2 &&<br>
>> -         "Function can only handle blocks with 2 predecessors!");<br>
>> -  BasicBlock *Pred1 = SomePHI->getIncomingBlock(0);<br>
>> -  BasicBlock *Pred2 = SomePHI->getIncomingBlock(1);<br>
>> +  PHINode *SomePHI = dyn_cast<PHINode>(BB->begin());<br>
>> +  BasicBlock *Pred1 = NULL;<br>
>> +  BasicBlock *Pred2 = NULL;<br>
>> +<br>
>> +  if (SomePHI) {<br>
>> +    if (SomePHI->getNumIncomingValues() != 2)<br>
>> +      return NULL;<br>
>> +    Pred1 = SomePHI->getIncomingBlock(0);<br>
>> +    Pred2 = SomePHI->getIncomingBlock(1);<br>
>> +  } else {<br>
>> +    pred_iterator PI = pred_begin(BB), PE = pred_end(BB);<br>
>> +    if (PI == PE) // No predecessor<br>
>> +      return NULL;<br>
>> +    Pred1 = *PI++;<br>
>> +    if (PI == PE) // Only one predecessor<br>
>> +      return NULL;<br>
>> +    Pred2 = *PI++;<br>
>> +    if (PI != PE) // More than two predecessors<br>
>> +      return NULL;<br>
>> +  }<br>
>><br>
>>    // We can only handle branches.  Other control flow will be lowered to<br>
>>    // branches if possible anyway.<br>
>> @@ -4066,6 +4102,383 @@ bool SimplifyCFGOpt::SimplifyCondBranch(<br>
>>    return false;<br>
>>  }<br>
>><br>
>> +/// If \param [in] BB has more than one predecessor that is a conditional<br>
>> +/// branch, attempt to use parallel and/or for the branch condition.<br>
>> \returns<br>
>> +/// true on success.<br>
>> +///<br>
>> +/// Before:<br>
>> +///   ......<br>
>> +///   %cmp10 = fcmp une float %tmp1, %tmp2<br>
>> +///   br i1 %cmp1, label %if.then, label %lor.rhs<br>
>> +///<br>
>> +/// lor.rhs:<br>
>> +///   ......<br>
>> +///   %cmp11 = fcmp une float %tmp3, %tmp4<br>
>> +///   br i1 %cmp11, label %if.then, label %ifend<br>
>> +///<br>
>> +/// if.end:  // the merge block<br>
>> +///   ......<br>
>> +///<br>
>> +/// if.then: // has two predecessors, both of them contains conditional<br>
>> branch.<br>
>> +///   ......<br>
>> +///   br label %if.end;<br>
>> +///<br>
>> +/// After:<br>
>> +///  ......<br>
>> +///  %cmp10 = fcmp une float %tmp1, %tmp2<br>
>> +///  ......<br>
>> +///  %cmp11 = fcmp une float %tmp3, %tmp4<br>
>> +///  %cmp12 = or i1 %cmp10, %cmp11    // parallel-or mode.<br>
>> +///  br i1 %cmp12, label %if.then, label %ifend<br>
>> +///<br>
>> +///  if.end:<br>
>> +///    ......<br>
>> +///<br>
>> +///  if.then:<br>
>> +///    ......<br>
>> +///    br label %if.end;<br>
>> +///<br>
>> +///  Current implementation handles two cases.<br>
>> +///  Case 1: \param BB is on the else-path.<br>
>> +///<br>
>> +///          BB1<br>
>> +///        /     |<br>
>> +///       BB2    |<br>
>> +///      /   \   |<br>
>> +///     BB3   \  |     where, BB1, BB2 contain conditional branches.<br>
>> +///      \    |  /     BB3 contains unconditional branch.<br>
>> +///       \   | /      BB4 corresponds to \param BB which is also the<br>
>> merge.<br>
>> +///  BB => BB4<br>
>> +///<br>
>> +///<br>
>> +///  Corresponding source code:<br>
>> +///<br>
>> +///  if (a == b && c == d)<br>
>> +///    statement; // BB3<br>
>> +///<br>
>> +///  Case 2: \param BB BB is on the then-path.<br>
>> +///<br>
>> +///             BB1<br>
>> +///          /      |<br>
>> +///         |      BB2<br>
>> +///         \    /    |  where BB1, BB2 contain conditional branches.<br>
>> +///  BB =>   BB3      |  BB3 contains unconditiona branch and corresponds<br>
>> +///           \     /    to \param BB.  BB4 is the merge.<br>
>> +///             BB4<br>
>> +///<br>
>> +///  Corresponding source code:<br>
>> +///<br>
>> +///  if (a == b || c == d)<br>
>> +///    statement;  // BB3<br>
>> +///<br>
>> +///  In both cases,  \param BB is the common successor of conditional<br>
>> branches.<br>
>> +///  In Case 1, \param BB (BB4) has an unconditional branch (BB3) as<br>
>> +///  its predecessor.  In Case 2, \param BB (BB3) only has conditional<br>
>> branches<br>
>> +///  as its predecessors.<br>
>> +///<br>
>> +bool SimplifyCFGOpt::SimplifyParallelAndOr(BasicBlock *BB, IRBuilder<><br>
>> &Builder,<br>
>> +                                           Pass *P) {<br>
>> +  PHINode *PHI = dyn_cast<PHINode>(BB->begin());<br>
>> +  if (PHI)<br>
>> +    return false; // For simplicity, avoid cases containing PHI nodes.<br>
>> +<br>
>> +  BasicBlock *LastCondBlock = NULL;<br>
>> +  BasicBlock *FirstCondBlock = NULL;<br>
>> +  BasicBlock *UnCondBlock = NULL;<br>
>> +  int Idx = -1;<br>
>> +<br>
>> +  // Check predecessors of \param BB.<br>
>> +  SmallPtrSet<BasicBlock*, 16> Preds(pred_begin(BB), pred_end(BB));<br>
>> +  for (SmallPtrSetIterator<BasicBlock*> PI = Preds.begin(), PE =<br>
>> Preds.end();<br>
>> +       PI != PE; ++PI) {<br>
>> +    BasicBlock *Pred = *PI;<br>
>> +      BranchInst *PBI = dyn_cast<BranchInst>(Pred->getTerminator());<br>
>> +<br>
>> +    // All predecessors should terminate with a branch.<br>
>> +    if (!PBI)<br>
>> +      return false;<br>
>> +<br>
>> +    BasicBlock *PP = Pred->getSinglePredecessor();<br>
>> +<br>
>> +    if (PBI->isUnconditional()) {<br>
>> +      // Case 1: Pred (BB3) is an unconditional block, it should<br>
>> +      // have a single predecessor (BB2) that is also a predecessor<br>
>> +      // of \param BB (BB4) and should not have address-taken.<br>
>> +      // There should exist only one such unconditional<br>
>> +      // branch among the predecessors.<br>
>> +      if (UnCondBlock || !PP || (Preds.count(PP) == 0) ||<br>
>> +          Pred->hasAddressTaken())<br>
>> +        return false;<br>
>> +<br>
>> +      UnCondBlock = Pred;<br>
>> +      continue;<br>
>> +    }<br>
>> +<br>
>> +    // Only conditional branches are allowed beyond this point.<br>
>> +    assert(PBI->isConditional());<br>
>> +<br>
>> +    // Condition's unique use should be the branch instruction.<br>
>> +    Value *PC = PBI->getCondition();<br>
>> +    if (!PC || !PC->hasOneUse())<br>
>> +      return false;<br>
>> +<br>
>> +    if (PP && Preds.count(PP)) {<br>
>> +      // These are internal condition blocks to be merged from, e.g.,<br>
>> +      // BB2 in both cases.<br>
>> +      // Should not be address-taken.<br>
>> +      if (Pred->hasAddressTaken())<br>
>> +        return false;<br>
>> +<br>
>> +      // Instructions in the internal condition blocks should be safe<br>
>> +      // to hoist up.<br>
>> +      for (BasicBlock::iterator BI = Pred->begin(), BE = PBI; BI != BE;)<br>
>> {<br>
>> +        Instruction *CI = BI++;<br>
>> +        if (isa<PHINode>(CI) ||<br>
>> +            !isSafeToSpeculativelyExecute(CI))<br>
>> +          return false;<br>
>> +      }<br>
>> +    } else {<br>
>> +      // This is the condition block to be merged into, e.g. BB1 in<br>
>> +      // both cases.<br>
>> +      if (FirstCondBlock)<br>
>> +        return false;<br>
>> +      FirstCondBlock = Pred;<br>
>> +    }<br>
>> +<br>
>> +    // Find whether BB is uniformly on the true (or false) path<br>
>> +    // for all of its predecessors.<br>
>> +    BasicBlock *PS1 = PBI->getSuccessor(0);<br>
>> +    BasicBlock *PS2 = PBI->getSuccessor(1);<br>
>> +    BasicBlock *PS = (PS1 == BB) ? PS2 : PS1;<br>
>> +    int CIdx = (PS1 == BB) ? 0 : 1;<br>
>> +<br>
>> +    if (Idx == -1)<br>
>> +      Idx = CIdx;<br>
>> +    else if (CIdx != Idx)<br>
>> +      return false;<br>
>> +<br>
>> +    // PS is the successor which is not BB. Check successors to identify<br>
>> +    // the last conditional branch.<br>
>> +    if (Preds.count(PS) == 0) {<br>
>> +      // Case 2.<br>
>> +      // BB must have an unique successor.<br>
>> +      TerminatorInst *TBB = BB->getTerminator();<br>
>> +      if (TBB->getNumSuccessors() != 1)<br>
>> +        return false;<br>
>> +<br>
>> +      BasicBlock *SBB = TBB->getSuccessor(0);<br>
>> +      PHI = dyn_cast<PHINode>(SBB->begin());<br>
>> +      if (PHI)<br>
>> +        return false;<br>
>> +<br>
>> +      // PS (BB4) should be BB's successor.<br>
>> +      if (SBB != PS)<br>
>> +        return false;<br>
>> +      LastCondBlock = Pred;<br>
>> +    } else {<br>
>> +      BranchInst *BPS = dyn_cast<BranchInst>(PS->getTerminator());<br>
>> +      if (BPS && BPS->isUnconditional()) {<br>
>> +        // Case 1: PS(BB3) should be an unconditional branch.<br>
>> +        LastCondBlock = Pred;<br>
>> +      }<br>
>> +    }<br>
>> +  }<br>
>> +<br>
>> +  if (!FirstCondBlock || !LastCondBlock || (FirstCondBlock ==<br>
>> LastCondBlock))<br>
>> +    return false;<br>
>> +<br>
>> +  // Do the transformation.<br>
>> +  BasicBlock *CB;<br>
>> +  bool Iteration = true;<br>
>> +  BasicBlock::iterator ItOld = Builder.GetInsertPoint();<br>
>> +  BranchInst *PBI =<br>
>> dyn_cast<BranchInst>(FirstCondBlock->getTerminator());<br>
>> +  Value *PC = PBI->getCondition();<br>
>> +  do {<br>
>> +    CB = PBI->getSuccessor(1 - Idx);<br>
>> +    // Delete the conditional branch.<br>
>> +    FirstCondBlock->getInstList().pop_back();<br>
>> +    FirstCondBlock->getInstList().splice(FirstCondBlock->end(),<br>
>> CB->getInstList());<br>
>> +    PBI = cast<BranchInst>(FirstCondBlock->getTerminator());<br>
>> +    Value *CC = PBI->getCondition();<br>
>> +    // Merge conditions.<br>
>> +    Builder.SetInsertPoint(PBI);<br>
>> +    Value *NC;<br>
>> +    if (Idx == 0)<br>
>> +      // Case 2, use parallel or.<br>
>> +      NC = Builder.CreateOr(PC, CC);<br>
>> +    else<br>
>> +      // Case 1, use parallel and.<br>
>> +      NC = Builder.CreateAnd(PC, CC);<br>
>> +<br>
>> +    PBI->replaceUsesOfWith(CC, NC);<br>
>> +    PC = NC;<br>
>> +    if (CB == LastCondBlock)<br>
>> +      Iteration = false;<br>
>> +    // Remove internal conditional branches.<br>
>> +    CB->dropAllReferences();<br>
>> +    // make CB unreachable and let downstream to delete the block.<br>
>> +    new UnreachableInst(CB->getContext(), CB);<br>
>> +  } while (Iteration);<br>
>> +<br>
>> +  Builder.SetInsertPoint(ItOld);<br>
>> +  DEBUG(dbgs() << "Use parallel and/or in:\n" << *FirstCondBlock);<br>
>> +  return true;<br>
>> +}<br>
>> +<br>
>> +/// Compare blocks from two if-regions, where \param Head1 is the entry<br>
>> of the<br>
>> +/// 1st if-region. \param Head2 is the entry of the 2nd if-region. \param<br>
>> +/// Block1 is a block in the 1st if-region to compare. \param Block2 is a<br>
>> block<br>
>> +//  in the 2nd if-region to compare.  \returns true if \param Block1 and<br>
>> \param<br>
>> +/// Block2 have identical instructions and do not have memory reference<br>
>> alias<br>
>> +/// with \param Head2.<br>
>> +///<br>
>> +bool SimplifyCFGOpt::CompareIfRegionBlock(BasicBlock *Head1, BasicBlock<br>
>> *Head2,<br>
>> +                                          BasicBlock *Block1, BasicBlock<br>
>> *Block2) {<br>
>> +  TerminatorInst *PTI2 = Head2->getTerminator();<br>
>> +  Instruction *PBI2 = Head2->begin();<br>
>> +<br>
>> +  bool eq1 = (Block1 == Head1);<br>
>> +  bool eq2 = (Block2 == Head2);<br>
>> +  if (eq1 || eq2) {<br>
>> +    // An empty then-path or else-path.<br>
>> +    return (eq1 == eq2);<br>
>> +  }<br>
>> +<br>
>> +  // Check whether instructions in Block1 and Block2 are identical<br>
>> +  // and do not alias with instructions in Head2.<br>
>> +  BasicBlock::iterator iter1 = Block1->begin();<br>
>> +  BasicBlock::iterator end1 = Block1->getTerminator();<br>
>> +  BasicBlock::iterator iter2 = Block2->begin();<br>
>> +  BasicBlock::iterator end2 = Block2->getTerminator();<br>
>> +<br>
>> +  while (1) {<br>
>> +    if (iter1 == end1) {<br>
>> +      if (iter2 != end2)<br>
>> +        return false;<br>
>> +      break;<br>
>> +    }<br>
>> +<br>
>> +    if (!iter1->isIdenticalTo(iter2))<br>
>> +      return false;<br>
>> +<br>
>> +    // Illegal to remove instructions with side effects except<br>
>> +    // non-volatile stores.<br>
>> +    if (iter1->mayHaveSideEffects()) {<br>
>> +      Instruction *CurI = &*iter1;<br>
>> +      StoreInst *SI = dyn_cast<StoreInst>(CurI);<br>
>> +      if (!SI || SI->isVolatile())<br>
>> +        return false;<br>
>> +    }<br>
>> +<br>
>> +    // For simplicity and speed, data dependency check can be<br>
>> +    // avoided if read from memory doesn't exist.<br>
>> +    if (iter1->mayReadFromMemory())<br>
>> +      return false;<br>
>> +<br>
>> +    if (iter1->mayWriteToMemory()) {<br>
>> +      for (BasicBlock::iterator BI = PBI2, BE = PTI2; BI != BE; ++BI) {<br>
>> +        if (BI->mayReadFromMemory() || BI->mayWriteToMemory()) {<br>
>> +          // Check alias with Head2.<br>
>> +          if (!AA || AA->alias(iter1, BI))<br>
>> +            return false;<br>
>> +        }<br>
>> +      }<br>
>> +    }<br>
>> +    ++iter1;<br>
>> +    ++iter2;<br>
>> +  }<br>
>> +<br>
>> +  return true;<br>
>> +}<br>
>> +<br>
>> +/// Check whether \param BB is the merge block of a if-region.  If yes,<br>
>> check<br>
>> +/// whether there exists an adjacent if-region upstream, the two<br>
>> if-regions<br>
>> +/// contain identical instuctions and can be legally merged.  \returns<br>
>> true if<br>
>> +/// the two if-regions are merged.<br>
>> +///<br>
>> +/// From:<br>
>> +/// if (a)<br>
>> +///   statement;<br>
>> +/// if (b)<br>
>> +///   statement;<br>
>> +///<br>
>> +/// To:<br>
>> +/// if (a || b)<br>
>> +///   statement;<br>
>> +///<br>
>> +bool SimplifyCFGOpt::MergeIfRegion(BasicBlock *BB, IRBuilder<> &Builder,<br>
>> +                                   Pass *P) {<br>
>> +  BasicBlock *IfTrue2, *IfFalse2;<br>
>> +  Value *IfCond2 = GetIfCondition(BB, IfTrue2, IfFalse2);<br>
>> +  Instruction *CInst2 = dyn_cast_or_null<Instruction>(IfCond2);<br>
>> +  if (!CInst2)<br>
>> +    return false;<br>
>> +<br>
>> +  BasicBlock *SecondEntryBlock = CInst2->getParent();<br>
>> +  if (SecondEntryBlock->hasAddressTaken())<br>
>> +    return false;<br>
>> +<br>
>> +  BasicBlock *IfTrue1, *IfFalse1;<br>
>> +  Value *IfCond1 = GetIfCondition(SecondEntryBlock, IfTrue1, IfFalse1);<br>
>> +  Instruction *CInst1 = dyn_cast_or_null<Instruction>(IfCond1);<br>
>> +  if (!CInst1)<br>
>> +    return false;<br>
>> +<br>
>> +  BasicBlock *FirstEntryBlock = CInst1->getParent();<br>
>> +<br>
>> +  // Either then-path or else-path should be empty.<br>
>> +  if ((IfTrue1 != FirstEntryBlock) && (IfFalse1 != FirstEntryBlock))<br>
>> +    return false;<br>
>> +  if ((IfTrue2 != SecondEntryBlock) && (IfFalse2 != SecondEntryBlock))<br>
>> +    return false;<br>
>> +<br>
>> +  TerminatorInst *PTI2 = SecondEntryBlock->getTerminator();<br>
>> +  Instruction *PBI2 = SecondEntryBlock->begin();<br>
>> +<br>
>> +  if (!CompareIfRegionBlock(FirstEntryBlock, SecondEntryBlock, IfTrue1,<br>
>> IfTrue2))<br>
>> +    return false;<br>
>> +<br>
>> +  if (!CompareIfRegionBlock(FirstEntryBlock, SecondEntryBlock, IfFalse1,<br>
>> IfFalse2))<br>
>> +    return false;<br>
>> +<br>
>> +  // Check whether \param SecondEntryBlock has side-effect and is safe to<br>
>> speculate.<br>
>> +  for (BasicBlock::iterator BI = PBI2, BE = PTI2; BI != BE; ++BI) {<br>
>> +    Instruction *CI = BI;<br>
>> +    if (isa<PHINode>(CI) || CI->mayHaveSideEffects() ||<br>
>> +        !isSafeToSpeculativelyExecute(CI))<br>
>> +      return false;<br>
>> +  }<br>
>> +<br>
>> +  // Merge \param SecondEntryBlock into \param FirstEntryBlock.<br>
>> +  FirstEntryBlock->getInstList().pop_back();<br>
>> +  FirstEntryBlock->getInstList().splice(FirstEntryBlock->end(),<br>
>> SecondEntryBlock->getInstList());<br>
>> +  BranchInst *PBI =<br>
>> dyn_cast<BranchInst>(FirstEntryBlock->getTerminator());<br>
>> +  Value *CC = PBI->getCondition();<br>
>> +  BasicBlock::iterator ItOld = Builder.GetInsertPoint();<br>
>> +  Builder.SetInsertPoint(PBI);<br>
>> +  Value *NC = Builder.CreateOr(CInst1, CC);<br>
>> +  PBI->replaceUsesOfWith(CC, NC);<br>
>> +  Builder.SetInsertPoint(ItOld);<br>
>> +<br>
>> +  // Remove IfTrue1<br>
>> +  if (IfTrue1 != FirstEntryBlock) {<br>
>> +    IfTrue1->dropAllReferences();<br>
>> +    IfTrue1->eraseFromParent();<br>
>> +  }<br>
>> +<br>
>> +  // Remove IfFalse1<br>
>> +  if (IfFalse1 != FirstEntryBlock) {<br>
>> +    IfFalse1->dropAllReferences();<br>
>> +    IfFalse1->eraseFromParent();<br>
>> +  }<br>
>> +<br>
>> +  // Remove \param SecondEntryBlock<br>
>> +  SecondEntryBlock->dropAllReferences();<br>
>> +  SecondEntryBlock->eraseFromParent();<br>
>> +  DEBUG(dbgs() << "If conditions merged into:\n" << *FirstEntryBlock);<br>
>> +  return true;<br>
>> +}<br>
>> +<br>
>>  /// Check if passing a value to an instruction will cause undefined<br>
>> behavior.<br>
>>  static bool passingValueIsAlwaysUndefined(Value *V, Instruction *I) {<br>
>>    Constant *C = dyn_cast<Constant>(V);<br>
>> @@ -4168,6 +4581,11 @@ bool SimplifyCFGOpt::run(BasicBlock *BB)<br>
>>      return true;<br>
>><br>
>>    IRBuilder<> Builder(BB);<br>
>> +  // Whether to optimize conditional branches.<br>
>> +  bool OptCB = (ParallelAndOr && AA && TTI.hasBranchDivergence());<br>
>> +<br>
>> +  if (OptCB && SimplifyParallelAndOr(BB, Builder))<br>
>> +    return true;<br>
>><br>
>>    // If there is a trivial two-entry PHI node in this basic block, and we<br>
>> can<br>
>>    // eliminate it, do so now.<br>
>> @@ -4196,6 +4614,9 @@ bool SimplifyCFGOpt::run(BasicBlock *BB)<br>
>>      if (SimplifyIndirectBr(IBI)) return true;<br>
>>    }<br>
>><br>
>> +  if (OptCB && MergeIfRegion(BB, Builder))<br>
>> +    return true;<br>
>> +<br>
>>    return Changed;<br>
>>  }<br>
>><br>
>> @@ -4205,6 +4626,6 @@ bool SimplifyCFGOpt::run(BasicBlock *BB)<br>
>>  /// of the CFG.  It returns true if a modification was made.<br>
>>  ///<br>
>>  bool llvm::SimplifyCFG(BasicBlock *BB, const TargetTransformInfo &TTI,<br>
>> -                       const DataLayout *TD) {<br>
>> -  return SimplifyCFGOpt(TTI, TD).run(BB);<br>
>> +                       const DataLayout *TD, AliasAnalysis *AA) {<br>
>> +  return SimplifyCFGOpt(TTI, TD, AA).run(BB);<br>
>>  }<br>
>><br>
>> Modified: llvm/trunk/tools/lto/LTOCodeGenerator.cpp<br>
>> URL:<br>
>> <a href="http://llvm.org/viewvc/llvm-project/llvm/trunk/tools/lto/LTOCodeGenerator.cpp?rev=187278&r1=187277&r2=187278&view=diff" target="_blank">http://llvm.org/viewvc/llvm-project/llvm/trunk/tools/lto/LTOCodeGenerator.cpp?rev=187278&r1=187277&r2=187278&view=diff</a><br>

>><br>
>> ==============================================================================<br>
>> --- llvm/trunk/tools/lto/LTOCodeGenerator.cpp (original)<br>
>> +++ llvm/trunk/tools/lto/LTOCodeGenerator.cpp Fri Jul 26 19:01:07 2013<br>
>> @@ -118,7 +118,7 @@ void LTOCodeGenerator::initializeLTOPass<br>
>>    initializeGVNPass(R);<br>
>>    initializeMemCpyOptPass(R);<br>
>>    initializeDCEPass(R);<br>
>> -  initializeCFGSimplifyPassPass(R);<br>
>> +  initializeCFGCanonicalizePass(R);<br>
>>  }<br>
>><br>
>>  bool LTOCodeGenerator::addModule(LTOModule* mod, std::string& errMsg) {<br>
>><br>
>> Modified: llvm/trunk/tools/opt/opt.cpp<br>
>> URL:<br>
>> <a href="http://llvm.org/viewvc/llvm-project/llvm/trunk/tools/opt/opt.cpp?rev=187278&r1=187277&r2=187278&view=diff" target="_blank">http://llvm.org/viewvc/llvm-project/llvm/trunk/tools/opt/opt.cpp?rev=187278&r1=187277&r2=187278&view=diff</a><br>

>><br>
>> ==============================================================================<br>
>> --- llvm/trunk/tools/opt/opt.cpp (original)<br>
>> +++ llvm/trunk/tools/opt/opt.cpp Fri Jul 26 19:01:07 2013<br>
>> @@ -667,6 +667,9 @@ int main(int argc, char **argv) {<br>
>>      FPasses.reset(new FunctionPassManager(M.get()));<br>
>>      if (TD)<br>
>>        FPasses->add(new DataLayout(*TD));<br>
>> +    if (TM.get())<br>
>> +      TM->addAnalysisPasses(*FPasses);<br>
>> +<br>
>>    }<br>
>><br>
>>    if (PrintBreakpoints) {<br>
>><br>
>><br>
>> _______________________________________________<br>
>> llvm-commits mailing list<br>
>> <a href="mailto:llvm-commits@cs.uiuc.edu">llvm-commits@cs.uiuc.edu</a><br>
>> <a href="http://lists.cs.uiuc.edu/mailman/listinfo/llvm-commits" target="_blank">http://lists.cs.uiuc.edu/mailman/listinfo/llvm-commits</a><br>
><br>
><br>
><br>
><br>
> --<br>
> Alexey Samsonov, MSK<br>
<br>
</div></div></blockquote></div><br><br clear="all"><div><br></div>-- <br><div>Alexey Samsonov, MSK</div>
</div>