[llvm-commits] [llvm] r40889 - /llvm/trunk/test/Analysis/ScalarEvolution/2007-08-06-Unsigned.ll
Author: nicholas Date: Tue Aug 7 07:27:03 2007 New Revision: 40889 URL: http://llvm.org/viewvc/llvm-project?rev=40889&view=rev Log: Add reference to problem report. Modified: llvm/trunk/test/Analysis/ScalarEvolution/2007-08-06-Unsigned.ll Modified: llvm/trunk/test/Analysis/ScalarEvolution/2007-08-06-Unsigned.ll URL: http://llvm.org/viewvc/llvm-project/llvm/trunk/test/Analysis/ScalarEvolution/2007-08-06-Unsigned.ll?rev=40889&r1=40888&r2=40889&view=diff == --- llvm/trunk/test/Analysis/ScalarEvolution/2007-08-06-Unsigned.ll (original) +++ llvm/trunk/test/Analysis/ScalarEvolution/2007-08-06-Unsigned.ll Tue Aug 7 07:27:03 2007 @@ -1,4 +1,5 @@ ; RUN: llvm-as < %s | opt -scalar-evolution -analyze |& grep "Loop bb: ( -1 + ( -1 * %x) + %y) iterations!" +; PR1597 define i32 @f(i32 %x, i32 %y) { entry: ___ llvm-commits mailing list llvm-commits@cs.uiuc.edu http://lists.cs.uiuc.edu/mailman/listinfo/llvm-commits
[llvm-commits] [llvm] r40890 - /llvm/trunk/docs/LangRef.html
Author: reid Date: Tue Aug 7 09:34:28 2007 New Revision: 40890 URL: http://llvm.org/viewvc/llvm-project?rev=40890&view=rev Log: Describe the global/local naming convention. Modified: llvm/trunk/docs/LangRef.html Modified: llvm/trunk/docs/LangRef.html URL: http://llvm.org/viewvc/llvm-project/llvm/trunk/docs/LangRef.html?rev=40890&r1=40889&r2=40890&view=diff == --- llvm/trunk/docs/LangRef.html (original) +++ llvm/trunk/docs/LangRef.html Tue Aug 7 09:34:28 2007 @@ -296,25 +296,27 @@ -LLVM uses three different forms of identifiers, for different -purposes: + LLVM identifiers come in two basic types: global and local. Global + identifiers (functions, global variables) begin with the @ character. Local + identifiers (register names, types) begin with the % character. Additionally, + there are three different formats for identifiers, for different purposes: - Named values are represented as a string of characters with a '%' prefix. - For example, %foo, %DivisionByZero, %a.really.long.identifier. The actual - regular expression used is '%[a-zA-Z$._][a-zA-Z$._0-9]*'. + Named values are represented as a string of characters with their prefix. + For example, %foo, @DivisionByZero, %a.really.long.identifier. The actual + regular expression used is '[EMAIL PROTECTED]'. Identifiers which require other characters in their names can be surrounded - with quotes. In this way, anything except a " character can be used - in a name. + with quotes. In this way, anything except a " character can + be used in a named value. - Unnamed values are represented as an unsigned numeric value with a '%' - prefix. For example, %12, %2, %44. + Unnamed values are represented as an unsigned numeric value with their + prefix. For example, %12, @2, %44. Constants, which are described in a section about constants, below. -LLVM requires that values start with a '%' sign for two reasons: Compilers +LLVM requires that values start with a prefix for two reasons: Compilers don't need to worry about name clashes with reserved words, and the set of reserved words may be expanded in the future without penalty. Additionally, unnamed identifiers allow a compiler to quickly come up with a temporary @@ -327,7 +329,7 @@ 'ret', etc...), for primitive type names ('void', 'i32', etc...), and others. These reserved words cannot conflict with variable names, because -none of them start with a '%' character. +none of them start with a prefix character ('%' or '@'). Here is an example of LLVM code to multiply the integer variable '%X' by 8: ___ llvm-commits mailing list llvm-commits@cs.uiuc.edu http://lists.cs.uiuc.edu/mailman/listinfo/llvm-commits
[llvm-commits] [llvm] r40891 - /llvm/trunk/docs/CommandGuide/lli.pod
Author: reid Date: Tue Aug 7 10:48:16 2007 New Revision: 40891 URL: http://llvm.org/viewvc/llvm-project?rev=40891&view=rev Log: Remove the -f option which is no longer supported, but add the -fake-argv0 option which is similar. Modified: llvm/trunk/docs/CommandGuide/lli.pod Modified: llvm/trunk/docs/CommandGuide/lli.pod URL: http://llvm.org/viewvc/llvm-project/llvm/trunk/docs/CommandGuide/lli.pod?rev=40891&r1=40890&r2=40891&view=diff == --- llvm/trunk/docs/CommandGuide/lli.pod (original) +++ llvm/trunk/docs/CommandGuide/lli.pod Tue Aug 7 10:48:16 2007 @@ -72,12 +72,9 @@ If set to true, use the interpreter even if a just-in-time compiler is available for this architecture. Defaults to false. -=item B<-f>=I +=item B<-fake-argv0>=I -Call the function named I to start the program. Note: The -function is assumed to have the C signature C I C<(int, -char **, char **)>. If you try to use this option to call a function of -incompatible type, undefined behavior may result. Defaults to C. +Override the C value passed into the executing program. =back ___ llvm-commits mailing list llvm-commits@cs.uiuc.edu http://lists.cs.uiuc.edu/mailman/listinfo/llvm-commits
[llvm-commits] [llvm] r40892 - /llvm/trunk/docs/CommandGuide/lli.pod
Author: reid Date: Tue Aug 7 11:11:57 2007 New Revision: 40892 URL: http://llvm.org/viewvc/llvm-project?rev=40892&view=rev Log: Add some more missing options. Modified: llvm/trunk/docs/CommandGuide/lli.pod Modified: llvm/trunk/docs/CommandGuide/lli.pod URL: http://llvm.org/viewvc/llvm-project/llvm/trunk/docs/CommandGuide/lli.pod?rev=40892&r1=40891&r2=40892&view=diff == --- llvm/trunk/docs/CommandGuide/lli.pod (original) +++ llvm/trunk/docs/CommandGuide/lli.pod Tue Aug 7 11:11:57 2007 @@ -67,14 +67,24 @@ current CPU. For a list of available attributes, use: B /dev/null | llc -march=xyz -mattr=help> +=item B<-fake-argv0>=I + +Override the C value passed into the executing program. + =item B<-force-interpreter>=I<{false,true}> If set to true, use the interpreter even if a just-in-time compiler is available for this architecture. Defaults to false. -=item B<-fake-argv0>=I +=item B<-load>=I -Override the C value passed into the executing program. +Causes B to load the plugin (shared object) named I and use +it for optimization. + +=item B<-soft-float> + +Causes B to generate software floating point library calls instead of +equivalent hardware instructions. =back ___ llvm-commits mailing list llvm-commits@cs.uiuc.edu http://lists.cs.uiuc.edu/mailman/listinfo/llvm-commits
[llvm-commits] [llvm] r40893 - /llvm/trunk/docs/CommandGuide/lli.pod
Author: reid Date: Tue Aug 7 11:21:52 2007 New Revision: 40893 URL: http://llvm.org/viewvc/llvm-project?rev=40893&view=rev Log: Add another missing option. Modified: llvm/trunk/docs/CommandGuide/lli.pod Modified: llvm/trunk/docs/CommandGuide/lli.pod URL: http://llvm.org/viewvc/llvm-project/llvm/trunk/docs/CommandGuide/lli.pod?rev=40893&r1=40892&r2=40893&view=diff == --- llvm/trunk/docs/CommandGuide/lli.pod (original) +++ llvm/trunk/docs/CommandGuide/lli.pod Tue Aug 7 11:21:52 2007 @@ -86,6 +86,11 @@ Causes B to generate software floating point library calls instead of equivalent hardware instructions. +=item B<-enable-unsafe-fp-math> + +Causes B to enable optimizations that may decrease floating point +precision. + =back =head1 EXIT STATUS ___ llvm-commits mailing list llvm-commits@cs.uiuc.edu http://lists.cs.uiuc.edu/mailman/listinfo/llvm-commits
[llvm-commits] [llvm] r40894 - /llvm/trunk/docs/CommandGuide/lli.pod
Author: reid Date: Tue Aug 7 11:23:42 2007 New Revision: 40894 URL: http://llvm.org/viewvc/llvm-project?rev=40894&view=rev Log: Add the -disable-excess-fp-precision option. Modified: llvm/trunk/docs/CommandGuide/lli.pod Modified: llvm/trunk/docs/CommandGuide/lli.pod URL: http://llvm.org/viewvc/llvm-project/llvm/trunk/docs/CommandGuide/lli.pod?rev=40894&r1=40893&r2=40894&view=diff == --- llvm/trunk/docs/CommandGuide/lli.pod (original) +++ llvm/trunk/docs/CommandGuide/lli.pod Tue Aug 7 11:23:42 2007 @@ -91,6 +91,10 @@ Causes B to enable optimizations that may decrease floating point precision. +=item B<-disable-excess-fp-precision> + +Disable optimizations that may increase floating point precision. + =back =head1 EXIT STATUS ___ llvm-commits mailing list llvm-commits@cs.uiuc.edu http://lists.cs.uiuc.edu/mailman/listinfo/llvm-commits
[llvm-commits] [llvm] r40895 - /llvm/trunk/docs/CommandGuide/lli.pod
Author: reid Date: Tue Aug 7 11:29:57 2007 New Revision: 40895 URL: http://llvm.org/viewvc/llvm-project?rev=40895&view=rev Log: Rearrange options into sections and add the last floating point related option. Modified: llvm/trunk/docs/CommandGuide/lli.pod Modified: llvm/trunk/docs/CommandGuide/lli.pod URL: http://llvm.org/viewvc/llvm-project/llvm/trunk/docs/CommandGuide/lli.pod?rev=40895&r1=40894&r2=40895&view=diff == --- llvm/trunk/docs/CommandGuide/lli.pod (original) +++ llvm/trunk/docs/CommandGuide/lli.pod Tue Aug 7 11:29:57 2007 @@ -22,14 +22,28 @@ The optional I specified on the command line are passed to the program as arguments. -=head1 OPTIONS +=head1 GENERAL OPTIONS =over +=item B<-fake-argv0>=I + +Override the C value passed into the executing program. + +=item B<-force-interpreter>=I<{false,true}> + +If set to true, use the interpreter even if a just-in-time compiler is available +for this architecture. Defaults to false. + =item B<-help> Print a summary of command line options. +=item B<-load>=I + +Causes B to load the plugin (shared object) named I and use +it for optimization. + =item B<-stats> Print statistics from the code-generation passes. This is only meaningful for @@ -40,6 +54,12 @@ Record the amount of time needed for each code-generation pass and print it to standard error. +=back + +=head1 TARGET OPTIONS + +=over + =item B<-mtriple>=I Override the target triple specified in the input bitcode file with the @@ -67,33 +87,31 @@ current CPU. For a list of available attributes, use: B /dev/null | llc -march=xyz -mattr=help> -=item B<-fake-argv0>=I +=back -Override the C value passed into the executing program. -=item B<-force-interpreter>=I<{false,true}> +=head1 FLOATING POINT OPTIONS -If set to true, use the interpreter even if a just-in-time compiler is available -for this architecture. Defaults to false. +=over -=item B<-load>=I +=item B<-disable-excess-fp-precision> -Causes B to load the plugin (shared object) named I and use -it for optimization. +Disable optimizations that may increase floating point precision. -=item B<-soft-float> +=item B<-enable-finite-only-fp-math> -Causes B to generate software floating point library calls instead of -equivalent hardware instructions. +Enable optimizations that assumes only finite floating point math. That is, +there is no NAN or Inf values. =item B<-enable-unsafe-fp-math> Causes B to enable optimizations that may decrease floating point precision. -=item B<-disable-excess-fp-precision> +=item B<-soft-float> -Disable optimizations that may increase floating point precision. +Causes B to generate software floating point library calls instead of +equivalent hardware instructions. =back ___ llvm-commits mailing list llvm-commits@cs.uiuc.edu http://lists.cs.uiuc.edu/mailman/listinfo/llvm-commits
[llvm-commits] [llvm] r40896 - /llvm/trunk/lib/CodeGen/VirtRegMap.h
Author: greened Date: Tue Aug 7 11:34:05 2007 New Revision: 40896 URL: http://llvm.org/viewvc/llvm-project?rev=40896&view=rev Log: Add a missing forward declaration. Modified: llvm/trunk/lib/CodeGen/VirtRegMap.h Modified: llvm/trunk/lib/CodeGen/VirtRegMap.h URL: http://llvm.org/viewvc/llvm-project/llvm/trunk/lib/CodeGen/VirtRegMap.h?rev=40896&r1=40895&r2=40896&view=diff == --- llvm/trunk/lib/CodeGen/VirtRegMap.h (original) +++ llvm/trunk/lib/CodeGen/VirtRegMap.h Tue Aug 7 11:34:05 2007 @@ -25,6 +25,7 @@ namespace llvm { class MachineInstr; + class MachineFunction; class TargetInstrInfo; class VirtRegMap { ___ llvm-commits mailing list llvm-commits@cs.uiuc.edu http://lists.cs.uiuc.edu/mailman/listinfo/llvm-commits
[llvm-commits] [llvm] r40897 - /llvm/trunk/lib/Transforms/Scalar/LoopUnswitch.cpp
Author: greened Date: Tue Aug 7 11:44:38 2007 New Revision: 40897 URL: http://llvm.org/viewvc/llvm-project?rev=40897&view=rev Log: Fix GLIBCXX_DEBUG error triggered by incrementing erased iterator. Modified: llvm/trunk/lib/Transforms/Scalar/LoopUnswitch.cpp Modified: llvm/trunk/lib/Transforms/Scalar/LoopUnswitch.cpp URL: http://llvm.org/viewvc/llvm-project/llvm/trunk/lib/Transforms/Scalar/LoopUnswitch.cpp?rev=40897&r1=40896&r2=40897&view=diff == --- llvm/trunk/lib/Transforms/Scalar/LoopUnswitch.cpp (original) +++ llvm/trunk/lib/Transforms/Scalar/LoopUnswitch.cpp Tue Aug 7 11:44:38 2007 @@ -777,8 +777,8 @@ if (LBBI != DF->end()) { DominanceFrontier::DomSetType &LBSet = LBBI->second; for (DominanceFrontier::DomSetType::iterator LI = LBSet.begin(), - LE = LBSet.end(); LI != LE; ++LI) { - BasicBlock *B = *LI; + LE = LBSet.end(); LI != LE; /* NULL */) { + BasicBlock *B = *LI++; if (OutSiders.count(B)) DF->removeFromFrontier(LBBI, B); } @@ -789,8 +789,8 @@ if (NBBI != DF->end()) { DominanceFrontier::DomSetType NBSet = NBBI->second; for (DominanceFrontier::DomSetType::iterator NI = NBSet.begin(), - NE = NBSet.end(); NI != NE; ++NI) { - BasicBlock *B = *NI; + NE = NBSet.end(); NI != NE; /* NULL */) { + BasicBlock *B = *NI++; if (OutSiders.count(B)) DF->removeFromFrontier(NBBI, B); } ___ llvm-commits mailing list llvm-commits@cs.uiuc.edu http://lists.cs.uiuc.edu/mailman/listinfo/llvm-commits
[llvm-commits] [llvm] r40898 - /llvm/trunk/lib/Transforms/Scalar/LowerGC.cpp
Author: greened Date: Tue Aug 7 11:52:03 2007 New Revision: 40898 URL: http://llvm.org/viewvc/llvm-project?rev=40898&view=rev Log: Fix comment typo Modified: llvm/trunk/lib/Transforms/Scalar/LowerGC.cpp Modified: llvm/trunk/lib/Transforms/Scalar/LowerGC.cpp URL: http://llvm.org/viewvc/llvm-project/llvm/trunk/lib/Transforms/Scalar/LowerGC.cpp?rev=40898&r1=40897&r2=40898&view=diff == --- llvm/trunk/lib/Transforms/Scalar/LowerGC.cpp (original) +++ llvm/trunk/lib/Transforms/Scalar/LowerGC.cpp Tue Aug 7 11:52:03 2007 @@ -201,7 +201,7 @@ // It sure would be nice to pass op_begin()+1, // op_begin()+2 but it runs into trouble with -// CallInst::init's &*ierator, which requires a +// CallInst::init's &*iterator, which requires a // conversion from Use* to Value*. The conversion // from Use to Value * is not useful because the // memory for Value * won't be contiguous. ___ llvm-commits mailing list llvm-commits@cs.uiuc.edu http://lists.cs.uiuc.edu/mailman/listinfo/llvm-commits
[llvm-commits] [llvm] r40899 - /llvm/trunk/tools/llvm-upgrade/UpgradeParser.y
Author: greened Date: Tue Aug 7 11:57:55 2007 New Revision: 40899 URL: http://llvm.org/viewvc/llvm-project?rev=40899&view=rev Log: Make this code more efficient Modified: llvm/trunk/tools/llvm-upgrade/UpgradeParser.y Modified: llvm/trunk/tools/llvm-upgrade/UpgradeParser.y URL: http://llvm.org/viewvc/llvm-project/llvm/trunk/tools/llvm-upgrade/UpgradeParser.y?rev=40899&r1=40898&r2=40899&view=diff == --- llvm/trunk/tools/llvm-upgrade/UpgradeParser.y (original) +++ llvm/trunk/tools/llvm-upgrade/UpgradeParser.y Tue Aug 7 11:57:55 2007 @@ -1723,11 +1723,12 @@ while (!F->use_empty()) { CallInst* CI = cast(F->use_back()); -SmallVector Args; -Args.push_back(new AllocaInst(ArgTy, 0, "vacopy.fix.1", CI)); -Args.push_back(new AllocaInst(ArgTy, 0, "vacopy.fix.2", CI)); +Value *Args[2] = { + new AllocaInst(ArgTy, 0, "vacopy.fix.1", CI), + new AllocaInst(ArgTy, 0, "vacopy.fix.2", CI) +}; new StoreInst(CI->getOperand(1), Args[1], CI); -new CallInst(NF, Args.begin(), Args.end(), "", CI); +new CallInst(NF, Args, Args + 2, "", CI); Value* foo = new LoadInst(Args[0], "vacopy.fix.3", CI); CI->replaceAllUsesWith(foo); CI->getParent()->getInstList().erase(CI); ___ llvm-commits mailing list llvm-commits@cs.uiuc.edu http://lists.cs.uiuc.edu/mailman/listinfo/llvm-commits
Re: [llvm-commits] [llvm] r40883 - in /llvm/trunk: include/llvm/LinkAllPasses.h include/llvm/Transforms/Scalar.h lib/Transforms/Scalar/LoopIndexSplit.cpp
> URL: http://llvm.org/viewvc/llvm-project?rev=40883&view=rev > Log: > Begin loop index split pass. Nice! > > +// > ===--- > ---===// > +// > +// LoopIndexSplit - This pass splits loop Please finish your sentence :) > +// > +LoopPass *createLoopIndexSplitPass(); > + > > == > > --- llvm/trunk/lib/Transforms/Scalar/LoopIndexSplit.cpp (added) > +++ llvm/trunk/lib/Transforms/Scalar/LoopIndexSplit.cpp Mon Aug 6 > 19:25:56 2007 > @@ -0,0 +1,384 @@ .. > + > +#define DEBUG_TYPE "loop-index-split" > + > +#include "llvm/Function.h" > +#include "llvm/Transforms/Scalar.h" This should include Transforms/Scalar first, because it is the "interface" to the .cpp file. > +/// Find condition inside a loop that is suitable candidate for > index split. > +void LoopIndexSplit::findSplitCondition() { > + > + BasicBlock *Header = L->getHeader(); > + > + for (BasicBlock::iterator I = Header->begin(); isa(I); + > +I) { > +PHINode *PN = cast(I); > + > +if (!PN->getType()->isInteger()) > + continue; > + > +SCEVHandle SCEV = SE->getSCEV(PN); > +if (!isa(SCEV)) > + continue; > + > +// If this phi node is used in a compare instruction then it is a > +// split condition candidate. > +for (Value::use_iterator UI = PN->use_begin(), E = PN->use_end(); > + UI != E; ++UI) { > + if (ICmpInst *CI = dyn_cast(*UI)) { > +SplitCondition = CI; > +break; > + } > +} One problem with this is that it won't find conditions that are derived expressions of the induction variable. Consider "if (iv+1 == 17)". Because the use of the IV is actually the add, this won't pick it up. I'd suggest scanning the terminators in the loop body, looking for comparisons where one side is a loop invariant, and one side is an addrecexpr corresponding to this loop. Another thing to consider: in the "non-one-iteration loop" case, you can actually have multiple indexes to split. The ultimate implementation will probably want to collect all of them for a loop and use a cost model to determine which is the cheapest to split (based on how much code would have to be duplicated). > + // Replace split condition in header. > + // Transform > + // SplitCondition : icmp eq i32 IndVar, SplitValue > + // into > + // c1 = icmp uge i32 SplitValue, StartValue > + // c2 = icmp ult i32 vSplitValue, ExitValue > + // and i32 c1, c2 > + bool SignedPredicate = SplitCondition->isSignedPredicate(); I don't think this is right. Doesn't the signedness of the compare depend on the loop exit condition, not the split condition? while (i < n) if (i == 17) You want the signedness of the i < n comparison. Similarly, somewhere in the safety checks, you should verify that the exit condition really is an integer compare. > + Instruction *C1 = new ICmpInst(SignedPredicate ? > + ICmpInst::ICMP_SGE : > ICmpInst::ICMP_UGE, > + SplitValue, StartValue, > "lisplit", Terminator); > + Instruction *C2 = new ICmpInst(SignedPredicate ? > + ICmpInst::ICMP_SLT : > ICmpInst::ICMP_ULT, > + SplitValue, ExitValue, "lisplit", > Terminator); > + Instruction *NSplitCond = BinaryOperator::create(Instruction::And, > + C1, C2, > "lisplit", Terminator); Plz use BinaryOperator::createAnd(C1, C2, "lisplit", Terminator); > + SplitCondition->replaceAllUsesWith(NSplitCond); > + SplitCondition->removeFromParent(); > + delete SplitCondition; Instead of removeFromParent + delete, just use eraseFromParent(). > + BranchInst *BR = dyn_cast(Latch->getTerminator()); > + BR->setUnconditionalDest(LatchSucc); If you know the terminator is a branch, use cast, otherwise you need to check to see if BR is null. > + // Now, clear latch block. Remove instructions that are responsible > + // to increment induction variable. > + Instruction *LTerminator = Latch->getTerminator(); > + for (BasicBlock::iterator LB = Latch->begin(), LE = Latch->end(); > + LB != LE; ) { > +Instruction *I = LB; > +++LB; > +if (isa(I) || I == LTerminator) > + continue; > + > +I->replaceAllUsesWith(UndefValue::get(I->getType())); This won't work if I has void type. I don't know if that is possible though, do to your safety predicate. > +I->removeFromParent(); > +delete I; These two lines can be I->eraseFromParent(); > +// If loop header includes loop variant instruction operands then > +// this loop can not be eliminated. This is used by > processOneIterationLoop(). > +bool LoopIndexSplit::safeHeader(BasicBlock *Header) { > + > + Instruction *Terminator = Header->getTerminator(); > + for(BasicBlock::iterator BI = Header->begin(), BE = Hea
[llvm-commits] [llvm] r40900 - /llvm/trunk/docs/CommandGuide/lli.pod
Author: reid Date: Tue Aug 7 12:12:43 2007 New Revision: 40900 URL: http://llvm.org/viewvc/llvm-project?rev=40900&view=rev Log: Add the code generation options. Modified: llvm/trunk/docs/CommandGuide/lli.pod Modified: llvm/trunk/docs/CommandGuide/lli.pod URL: http://llvm.org/viewvc/llvm-project/llvm/trunk/docs/CommandGuide/lli.pod?rev=40900&r1=40899&r2=40900&view=diff == --- llvm/trunk/docs/CommandGuide/lli.pod (original) +++ llvm/trunk/docs/CommandGuide/lli.pod Tue Aug 7 12:12:43 2007 @@ -115,6 +115,125 @@ =back +=head1 CODE GENERATION OPTIONS + +=over + +=item B<-code-model>=I + +Choose the code model from: + +=over + +=item I: Target default code model + +=item I: Small code model + +=item I: Kernel code model +=item I: Medium code model +=item I: Large code model + +=back + +=item B<-disable-post-RA-scheduler> + +Disable scheduling after register allocation. + +=item B<-disable-spill-fusing> + +Disable fusing of spill code into instructions. + +=item B<-enable-correct-eh-support> + +Make the -lowerinvoke pass insert expensive, but correct, EH code. + +=item B<-enable-eh> + +Exception handling should be emitted. + +=item B<-join-liveintervals> + +Coalesce copies (default=true). + +=item B<-nozero-initialized-in-bss> +Don't place zero-initialized symbols into the BSS section. + +=item B<-pre-RA-sched>=I + +Instruction schedulers available (before register allocation): + +=over + +=item I<=default>: Best scheduler for the target + +=item I<=none>: No scheduling: breadth first sequencing + +=item I<=simple>: Simple two pass scheduling: minimize critical path and maximize processor utilization + +=item I<=simple-noitin>: Simple two pass scheduling: Same as simple except using generic latency + +=item I<=list-burr>: Bottom-up register reduction list scheduling + +=item I<=list-tdrr>: Top-down register reduction list scheduling + +=item I<=list-td>: Top-down list scheduler -print-machineinstrs - Print generated machine code + +=back + +=item B<-regalloc>=I + +Register allocator to use: (default = linearscan) + +=over + +=item I<=bigblock>: Big-block register allocator + +=item I<=linearscan>: linear scan register allocator =local - local register allocator + +=item I<=simple>: simple register allocator + +=back + +=item B<-relocation-model>=I + +Choose relocation model from: + +=over + +=item I<=default>: Target default relocation model + +=item I<=static>: Non-relocatable code =pic - Fully relocatable, position independent code + +=item I<=dynamic-no-pic>: Relocatable external references, non-relocatable code + +=back + +=item B<-spiller> + +Spiller to use: (default: local) + +=over + +=item I<=simple>: simple spiller + +=item I<=local>: local spiller + +=back + +=item B<-x86-asm-syntax>=I + +Choose style of code to emit from X86 backend: + +=over + +=item I<=att>: Emit AT&T-style assembly + +=item I<=intel>: Emit Intel-style assembly + +=back + +=back + =head1 EXIT STATUS If B fails to load the program, it will exit with an exit code of 1. ___ llvm-commits mailing list llvm-commits@cs.uiuc.edu http://lists.cs.uiuc.edu/mailman/listinfo/llvm-commits
Re: [llvm-commits] [llvm] r40883 - in /llvm/trunk: include/llvm/LinkAllPasses.h include/llvm/Transforms/Scalar.h lib/Transforms/Scalar/LoopIndexSplit.cpp
On Aug 7, 2007, at 9:59 AM, Chris Lattner wrote: >> URL: http://llvm.org/viewvc/llvm-project?rev=40883&view=rev >> Log: >> Begin loop index split pass. > > Nice! > >> >> +// >> ===-- >> - >> ---===// >> +// >> +// LoopIndexSplit - This pass splits loop > > Please finish your sentence :) ok > >> +// >> +LoopPass *createLoopIndexSplitPass(); >> + >> >> = >> = >> >> --- llvm/trunk/lib/Transforms/Scalar/LoopIndexSplit.cpp (added) >> +++ llvm/trunk/lib/Transforms/Scalar/LoopIndexSplit.cpp Mon Aug 6 >> 19:25:56 2007 >> @@ -0,0 +1,384 @@ > .. >> + >> +#define DEBUG_TYPE "loop-index-split" >> + >> +#include "llvm/Function.h" >> +#include "llvm/Transforms/Scalar.h" > > This should include Transforms/Scalar first, because it is the > "interface" to the .cpp file. ok > >> +/// Find condition inside a loop that is suitable candidate for >> index split. >> +void LoopIndexSplit::findSplitCondition() { >> + >> + BasicBlock *Header = L->getHeader(); >> + >> + for (BasicBlock::iterator I = Header->begin(); isa(I); + >> +I) { >> +PHINode *PN = cast(I); >> + >> +if (!PN->getType()->isInteger()) >> + continue; >> + >> +SCEVHandle SCEV = SE->getSCEV(PN); >> +if (!isa(SCEV)) >> + continue; >> + >> +// If this phi node is used in a compare instruction then it >> is a >> +// split condition candidate. >> +for (Value::use_iterator UI = PN->use_begin(), E = PN->use_end >> (); >> + UI != E; ++UI) { >> + if (ICmpInst *CI = dyn_cast(*UI)) { >> +SplitCondition = CI; >> +break; >> + } >> +} > > One problem with this is that it won't find conditions that are > derived expressions of the induction variable. Consider "if (iv+1 == > 17)". Because the use of the IV is actually the add, this won't pick > it up. > > I'd suggest scanning the terminators in the loop body, looking for > comparisons where one side is a loop invariant, and one side is an > addrecexpr corresponding to this loop. ok. Only need to check header terminator here. > Another thing to consider: in the "non-one-iteration loop" case, you > can actually have multiple indexes to split. The ultimate > implementation will probably want to collect all of them for a loop > and use a cost model to determine which is the cheapest to split > (based on how much code would have to be duplicated). hmm... okay >> + // Replace split condition in header. >> + // Transform >> + // SplitCondition : icmp eq i32 IndVar, SplitValue >> + // into >> + // c1 = icmp uge i32 SplitValue, StartValue >> + // c2 = icmp ult i32 vSplitValue, ExitValue >> + // and i32 c1, c2 >> + bool SignedPredicate = SplitCondition->isSignedPredicate(); > > I don't think this is right. Doesn't the signedness of the compare > depend on the loop exit condition, not the split condition? > > while (i < n) >if (i == 17) > > You want the signedness of the i < n comparison. I was thinking both comparisons will have same sign but now I see. OK. > > Similarly, somewhere in the safety checks, you should verify that the > exit condition really is an integer compare. It does. > >> + Instruction *C1 = new ICmpInst(SignedPredicate ? >> + ICmpInst::ICMP_SGE : >> ICmpInst::ICMP_UGE, >> + SplitValue, StartValue, >> "lisplit", Terminator); >> + Instruction *C2 = new ICmpInst(SignedPredicate ? >> + ICmpInst::ICMP_SLT : >> ICmpInst::ICMP_ULT, >> + SplitValue, ExitValue, "lisplit", >> Terminator); >> + Instruction *NSplitCond = BinaryOperator::create(Instruction::And, >> + C1, C2, >> "lisplit", Terminator); > > Plz use BinaryOperator::createAnd(C1, C2, "lisplit", Terminator); OK > >> + SplitCondition->replaceAllUsesWith(NSplitCond); >> + SplitCondition->removeFromParent(); >> + delete SplitCondition; > > Instead of removeFromParent + delete, just use eraseFromParent(). good idea :) > >> + BranchInst *BR = dyn_cast(Latch->getTerminator()); >> + BR->setUnconditionalDest(LatchSucc); > > If you know the terminator is a branch, use cast, > otherwise you need to check to see if BR is null. OK, I'll add null check. > >> + // Now, clear latch block. Remove instructions that are >> responsible >> + // to increment induction variable. >> + Instruction *LTerminator = Latch->getTerminator(); >> + for (BasicBlock::iterator LB = Latch->begin(), LE = Latch->end(); >> + LB != LE; ) { >> +Instruction *I = LB; >> +++LB; >> +if (isa(I) || I == LTerminator) >> + continue; >> + >> +I->replaceAllUsesWith(UndefValue::get(I->getType())); > > This won't work if I has void type. I don't know if that is possible > though, do to your safety predicate. It won't have void type.. I
[llvm-commits] [llvm] r40902 - /llvm/trunk/docs/CommandGuide/lli.pod
Author: reid Date: Tue Aug 7 12:43:48 2007 New Revision: 40902 URL: http://llvm.org/viewvc/llvm-project?rev=40902&view=rev Log: Try an indent level for better formatting. Add the -version option. Modified: llvm/trunk/docs/CommandGuide/lli.pod Modified: llvm/trunk/docs/CommandGuide/lli.pod URL: http://llvm.org/viewvc/llvm-project/llvm/trunk/docs/CommandGuide/lli.pod?rev=40902&r1=40901&r2=40902&view=diff == --- llvm/trunk/docs/CommandGuide/lli.pod (original) +++ llvm/trunk/docs/CommandGuide/lli.pod Tue Aug 7 12:43:48 2007 @@ -54,6 +54,10 @@ Record the amount of time needed for each code-generation pass and print it to standard error. +=item B<-version> + +Print out the version of B and exit without doing anything else. + =back =head1 TARGET OPTIONS @@ -123,14 +127,16 @@ Choose the code model from: -=over +=over 2 =item I: Target default code model =item I: Small code model =item I: Kernel code model + =item I: Medium code model + =item I: Large code model =back @@ -162,7 +168,7 @@ Instruction schedulers available (before register allocation): -=over +=over 2 =item I<=default>: Best scheduler for the target @@ -184,7 +190,7 @@ Register allocator to use: (default = linearscan) -=over +=over 2 =item I<=bigblock>: Big-block register allocator @@ -198,7 +204,7 @@ Choose relocation model from: -=over +=over 2 =item I<=default>: Target default relocation model @@ -212,7 +218,7 @@ Spiller to use: (default: local) -=over +=over 2 =item I<=simple>: simple spiller @@ -224,7 +230,7 @@ Choose style of code to emit from X86 backend: -=over +=over 2 =item I<=att>: Emit AT&T-style assembly ___ llvm-commits mailing list llvm-commits@cs.uiuc.edu http://lists.cs.uiuc.edu/mailman/listinfo/llvm-commits
[llvm-commits] [llvm] r40903 - /llvm/trunk/lib/Transforms/Scalar/LoopIndexSplit.cpp
Author: dpatel Date: Tue Aug 7 12:45:35 2007 New Revision: 40903 URL: http://llvm.org/viewvc/llvm-project?rev=40903&view=rev Log: Use eraseFromParent(). Modified: llvm/trunk/lib/Transforms/Scalar/LoopIndexSplit.cpp Modified: llvm/trunk/lib/Transforms/Scalar/LoopIndexSplit.cpp URL: http://llvm.org/viewvc/llvm-project/llvm/trunk/lib/Transforms/Scalar/LoopIndexSplit.cpp?rev=40903&r1=40902&r2=40903&view=diff == --- llvm/trunk/lib/Transforms/Scalar/LoopIndexSplit.cpp (original) +++ llvm/trunk/lib/Transforms/Scalar/LoopIndexSplit.cpp Tue Aug 7 12:45:35 2007 @@ -238,8 +238,7 @@ Instruction *NSplitCond = BinaryOperator::create(Instruction::And, C1, C2, "lisplit", Terminator); SplitCondition->replaceAllUsesWith(NSplitCond); - SplitCondition->removeFromParent(); - delete SplitCondition; + SplitCondition->eraseFromParent(); // As a first step to break this loop, remove Latch to Header edge. BasicBlock *LatchSucc = NULL; @@ -263,8 +262,7 @@ continue; I->replaceAllUsesWith(UndefValue::get(I->getType())); -I->removeFromParent(); -delete I; +I->eraseFromParent(); } LPM.deleteLoopFromQueue(L); ___ llvm-commits mailing list llvm-commits@cs.uiuc.edu http://lists.cs.uiuc.edu/mailman/listinfo/llvm-commits
[llvm-commits] [llvm] r40904 - /llvm/trunk/docs/CommandGuide/lli.pod
Author: reid Date: Tue Aug 7 12:48:56 2007 New Revision: 40904 URL: http://llvm.org/viewvc/llvm-project?rev=40904&view=rev Log: Okay, over/back tags don't next. Modified: llvm/trunk/docs/CommandGuide/lli.pod Modified: llvm/trunk/docs/CommandGuide/lli.pod URL: http://llvm.org/viewvc/llvm-project/llvm/trunk/docs/CommandGuide/lli.pod?rev=40904&r1=40903&r2=40904&view=diff == --- llvm/trunk/docs/CommandGuide/lli.pod (original) +++ llvm/trunk/docs/CommandGuide/lli.pod Tue Aug 7 12:48:56 2007 @@ -121,13 +121,15 @@ =head1 CODE GENERATION OPTIONS -=over +=over 4 =item B<-code-model>=I Choose the code model from: -=over 2 +=back + +=over 8 =item I: Target default code model @@ -141,6 +143,8 @@ =back +=over 4 + =item B<-disable-post-RA-scheduler> Disable scheduling after register allocation. @@ -168,7 +172,9 @@ Instruction schedulers available (before register allocation): -=over 2 +=back + +=over 8 =item I<=default>: Best scheduler for the target @@ -186,11 +192,15 @@ =back +=over 4 + =item B<-regalloc>=I Register allocator to use: (default = linearscan) -=over 2 +=back + +=over 8 =item I<=bigblock>: Big-block register allocator @@ -200,11 +210,15 @@ =back +=over 4 + =item B<-relocation-model>=I Choose relocation model from: -=over 2 +=back + +=over 8 =item I<=default>: Target default relocation model @@ -214,11 +228,15 @@ =back +=over 4 + =item B<-spiller> Spiller to use: (default: local) -=over 2 +=back + +=over 8 =item I<=simple>: simple spiller @@ -226,11 +244,15 @@ =back +=over 4 + =item B<-x86-asm-syntax>=I Choose style of code to emit from X86 backend: -=over 2 +=back + +=over 8 =item I<=att>: Emit AT&T-style assembly @@ -238,8 +260,6 @@ =back -=back - =head1 EXIT STATUS If B fails to load the program, it will exit with an exit code of 1. ___ llvm-commits mailing list llvm-commits@cs.uiuc.edu http://lists.cs.uiuc.edu/mailman/listinfo/llvm-commits
[llvm-commits] [llvm] r40905 - /llvm/trunk/docs/CommandGuide/lli.pod
Author: reid Date: Tue Aug 7 12:57:36 2007 New Revision: 40905 URL: http://llvm.org/viewvc/llvm-project?rev=40905&view=rev Log: Who thought up this crazy formatting scheme? Modified: llvm/trunk/docs/CommandGuide/lli.pod Modified: llvm/trunk/docs/CommandGuide/lli.pod URL: http://llvm.org/viewvc/llvm-project/llvm/trunk/docs/CommandGuide/lli.pod?rev=40905&r1=40904&r2=40905&view=diff == --- llvm/trunk/docs/CommandGuide/lli.pod (original) +++ llvm/trunk/docs/CommandGuide/lli.pod Tue Aug 7 12:57:36 2007 @@ -121,29 +121,17 @@ =head1 CODE GENERATION OPTIONS -=over 4 +=over =item B<-code-model>=I Choose the code model from: -=back - -=over 8 - -=item I: Target default code model - -=item I: Small code model - -=item I: Kernel code model - -=item I: Medium code model - -=item I: Large code model - -=back - -=over 4 +default: Target default code model +small: Small code model +kernel: Kernel code model +medium: Medium code model +large: Large code model =item B<-disable-post-RA-scheduler> @@ -172,91 +160,43 @@ Instruction schedulers available (before register allocation): -=back - -=over 8 - -=item I<=default>: Best scheduler for the target - -=item I<=none>: No scheduling: breadth first sequencing - -=item I<=simple>: Simple two pass scheduling: minimize critical path and maximize processor utilization - -=item I<=simple-noitin>: Simple two pass scheduling: Same as simple except using generic latency - -=item I<=list-burr>: Bottom-up register reduction list scheduling - -=item I<=list-tdrr>: Top-down register reduction list scheduling - -=item I<=list-td>: Top-down list scheduler -print-machineinstrs - Print generated machine code - -=back - -=over 4 +=default: Best scheduler for the target +=none: No scheduling: breadth first sequencing +=simple: Simple two pass scheduling: minimize critical path and maximize processor utilization +=simple-noitin: Simple two pass scheduling: Same as simple except using generic latency +=list-burr: Bottom-up register reduction list scheduling +=list-tdrr: Top-down register reduction list scheduling +=list-td: Top-down list scheduler -print-machineinstrs - Print generated machine code =item B<-regalloc>=I Register allocator to use: (default = linearscan) -=back - -=over 8 - -=item I<=bigblock>: Big-block register allocator - -=item I<=linearscan>: linear scan register allocator =local - local register allocator - -=item I<=simple>: simple register allocator - -=back - -=over 4 +=bigblock: Big-block register allocator +=linearscan: linear scan register allocator =local - local register allocator +=simple: simple register allocator =item B<-relocation-model>=I Choose relocation model from: -=back - -=over 8 - -=item I<=default>: Target default relocation model - -=item I<=static>: Non-relocatable code =pic - Fully relocatable, position independent code - -=item I<=dynamic-no-pic>: Relocatable external references, non-relocatable code - -=back - -=over 4 +=default: Target default relocation model +=static: Non-relocatable code =pic - Fully relocatable, position independent code +=dynamic-no-pic: Relocatable external references, non-relocatable code =item B<-spiller> Spiller to use: (default: local) -=back - -=over 8 - -=item I<=simple>: simple spiller - -=item I<=local>: local spiller - -=back - -=over 4 +=simple: simple spiller +=local: local spiller =item B<-x86-asm-syntax>=I Choose style of code to emit from X86 backend: -=back - -=over 8 - -=item I<=att>: Emit AT&T-style assembly - -=item I<=intel>: Emit Intel-style assembly +=att: Emit AT&T-style assembly +=intel: Emit Intel-style assembly =back ___ llvm-commits mailing list llvm-commits@cs.uiuc.edu http://lists.cs.uiuc.edu/mailman/listinfo/llvm-commits
[llvm-commits] [llvm] r40906 - in /llvm/trunk/lib/Target/X86: X86FloatingPoint.cpp X86ISelDAGToDAG.cpp X86InstrFPStack.td
Author: johannes Date: Tue Aug 7 15:29:26 2007 New Revision: 40906 URL: http://llvm.org/viewvc/llvm-project?rev=40906&view=rev Log: Long double patch 8 of N: make it partially work in SSE mode (all but conversions <-> other FP types, I think): >>Do not mark all-80-bit operations as "Requires[FPStack]" (which really means "not SSE"). >>Refactor load-and-extend to facilitate this. >>Update comments. >>Handle long double in SSE when computing FP_REG_KILL. Modified: llvm/trunk/lib/Target/X86/X86FloatingPoint.cpp llvm/trunk/lib/Target/X86/X86ISelDAGToDAG.cpp llvm/trunk/lib/Target/X86/X86InstrFPStack.td Modified: llvm/trunk/lib/Target/X86/X86FloatingPoint.cpp URL: http://llvm.org/viewvc/llvm-project/llvm/trunk/lib/Target/X86/X86FloatingPoint.cpp?rev=40906&r1=40905&r2=40906&view=diff == --- llvm/trunk/lib/Target/X86/X86FloatingPoint.cpp (original) +++ llvm/trunk/lib/Target/X86/X86FloatingPoint.cpp Tue Aug 7 15:29:26 2007 @@ -424,7 +424,10 @@ { X86::LD_Fp164 , X86::LD_F1 }, { X86::LD_Fp180 , X86::LD_F1 }, { X86::LD_Fp32m , X86::LD_F32m }, + { X86::LD_Fp32m64 , X86::LD_F32m }, + { X86::LD_Fp32m80 , X86::LD_F32m }, { X86::LD_Fp64m , X86::LD_F64m }, + { X86::LD_Fp64m80 , X86::LD_F64m }, { X86::LD_Fp80m , X86::LD_F80m }, { X86::MUL_Fp32m, X86::MUL_F32m }, { X86::MUL_Fp64m, X86::MUL_F64m }, Modified: llvm/trunk/lib/Target/X86/X86ISelDAGToDAG.cpp URL: http://llvm.org/viewvc/llvm-project/llvm/trunk/lib/Target/X86/X86ISelDAGToDAG.cpp?rev=40906&r1=40905&r2=40906&view=diff == --- llvm/trunk/lib/Target/X86/X86ISelDAGToDAG.cpp (original) +++ llvm/trunk/lib/Target/X86/X86ISelDAGToDAG.cpp Tue Aug 7 15:29:26 2007 @@ -479,61 +479,61 @@ // If we are emitting FP stack code, scan the basic block to determine if this // block defines any FP values. If so, put an FP_REG_KILL instruction before // the terminator of the block. - if (!Subtarget->hasSSE2()) { -// Note that FP stack instructions *are* used in SSE code when returning -// values, but these are not live out of the basic block, so we don't need -// an FP_REG_KILL in this case either. -bool ContainsFPCode = false; - -// Scan all of the machine instructions in these MBBs, checking for FP -// stores. -MachineFunction::iterator MBBI = FirstMBB; -do { - for (MachineBasicBlock::iterator I = MBBI->begin(), E = MBBI->end(); - !ContainsFPCode && I != E; ++I) { -if (I->getNumOperands() != 0 && I->getOperand(0).isRegister()) { - const TargetRegisterClass *clas; - for (unsigned op = 0, e = I->getNumOperands(); op != e; ++op) { -if (I->getOperand(op).isRegister() && I->getOperand(op).isDef() && -MRegisterInfo::isVirtualRegister(I->getOperand(op).getReg()) && -((clas = RegMap->getRegClass(I->getOperand(0).getReg())) == - X86::RFP32RegisterClass || - clas == X86::RFP64RegisterClass || - clas == X86::RFP80RegisterClass)) { - ContainsFPCode = true; - break; -} - } -} - } -} while (!ContainsFPCode && &*(MBBI++) != BB); - -// Check PHI nodes in successor blocks. These PHI's will be lowered to have -// a copy of the input value in this block. -if (!ContainsFPCode) { - // Final check, check LLVM BB's that are successors to the LLVM BB - // corresponding to BB for FP PHI nodes. - const BasicBlock *LLVMBB = BB->getBasicBlock(); - const PHINode *PN; - for (succ_const_iterator SI = succ_begin(LLVMBB), E = succ_end(LLVMBB); - !ContainsFPCode && SI != E; ++SI) { -for (BasicBlock::const_iterator II = SI->begin(); - (PN = dyn_cast(II)); ++II) { - if (PN->getType()->isFloatingPoint()) { + + // Note that FP stack instructions *are* used in SSE code for long double, + // so we do need this check. + bool ContainsFPCode = false; + + // Scan all of the machine instructions in these MBBs, checking for FP + // stores. (RFP32 and RFP64 will not exist in SSE mode, but RFP80 might.) + MachineFunction::iterator MBBI = FirstMBB; + do { +for (MachineBasicBlock::iterator I = MBBI->begin(), E = MBBI->end(); + !ContainsFPCode && I != E; ++I) { + if (I->getNumOperands() != 0 && I->getOperand(0).isRegister()) { +const TargetRegisterClass *clas; +for (unsigned op = 0, e = I->getNumOperands(); op != e; ++op) { + if (I->getOperand(op).isRegister() && I->getOperand(op).isDef() && + MRegisterInfo::isVirtualRegister(I->getOperand(op).getReg()) && + ((clas = RegMap->getRegClass(I->getOperand(0).getReg())) == + X86::RFP32RegisterClass || + clas == X86:
[llvm-commits] [llvm] r40908 - /llvm/trunk/lib/Target/PowerPC/PPCInstrAltivec.td
Author: johannes Date: Tue Aug 7 18:08:00 2007 New Revision: 40908 URL: http://llvm.org/viewvc/llvm-project?rev=40908&view=rev Log: Fix spelling of mtvscr and mfvscr. Modified: llvm/trunk/lib/Target/PowerPC/PPCInstrAltivec.td Modified: llvm/trunk/lib/Target/PowerPC/PPCInstrAltivec.td URL: http://llvm.org/viewvc/llvm-project/llvm/trunk/lib/Target/PowerPC/PPCInstrAltivec.td?rev=40908&r1=40907&r2=40908&view=diff == --- llvm/trunk/lib/Target/PowerPC/PPCInstrAltivec.td (original) +++ llvm/trunk/lib/Target/PowerPC/PPCInstrAltivec.td Tue Aug 7 18:08:00 2007 @@ -171,10 +171,10 @@ "dstst $rA, $rB, $STRM, $T", LdStGeneral /*FIXME*/, []>; def MFVSCR : VXForm_4<1540, (outs VRRC:$vD), (ins), - "mfvcr $vD", LdStGeneral, + "mfvscr $vD", LdStGeneral, [(set VRRC:$vD, (int_ppc_altivec_mfvscr))]>; def MTVSCR : VXForm_5<1604, (outs), (ins VRRC:$vB), - "mtvcr $vB", LdStGeneral, + "mtvscr $vB", LdStGeneral, [(int_ppc_altivec_mtvscr VRRC:$vB)]>; let isLoad = 1, PPC970_Unit = 2 in { // Loads. ___ llvm-commits mailing list llvm-commits@cs.uiuc.edu http://lists.cs.uiuc.edu/mailman/listinfo/llvm-commits
[llvm-commits] [llvm] r40909 - /llvm/trunk/lib/Transforms/Scalar/GVN.cpp
Author: resistor Date: Tue Aug 7 18:12:31 2007 New Revision: 40909 URL: http://llvm.org/viewvc/llvm-project?rev=40909&view=rev Log: Don't insert nearly as many redundant phi nodes. Modified: llvm/trunk/lib/Transforms/Scalar/GVN.cpp Modified: llvm/trunk/lib/Transforms/Scalar/GVN.cpp URL: http://llvm.org/viewvc/llvm-project/llvm/trunk/lib/Transforms/Scalar/GVN.cpp?rev=40909&r1=40908&r2=40909&view=diff == --- llvm/trunk/lib/Transforms/Scalar/GVN.cpp (original) +++ llvm/trunk/lib/Transforms/Scalar/GVN.cpp Tue Aug 7 18:12:31 2007 @@ -642,6 +642,10 @@ DenseMap availableOut; +typedef DenseMap > PhiMapType; +PhiMapType phiMap; + + // This transformation requires dominator postdominator info virtual void getAnalysisUsage(AnalysisUsage &AU) const { AU.setPreservesCFG(); @@ -780,6 +784,7 @@ return first; } + phiMap[orig->getPointerOperand()].insert(PN); return PN; } @@ -791,6 +796,7 @@ MD.getNonLocalDependency(L, deps); DenseMap repl; + for (DenseMap::iterator I = deps.begin(), E = deps.end(); I != E; ++I) if (I->second == MemoryDependenceAnalysis::None) { @@ -799,24 +805,40 @@ continue; }else if (StoreInst* S = dyn_cast(I->second)) { if (S->getPointerOperand() == L->getPointerOperand()) -repl.insert(std::make_pair(I->first, S->getOperand(0))); +repl[I->first] = S->getOperand(0); else return false; } else if (LoadInst* LD = dyn_cast(I->second)) { if (LD->getPointerOperand() == L->getPointerOperand()) -repl.insert(std::make_pair(I->first, LD)); +repl[I->first] = LD; else return false; } else { return false; } + SmallPtrSet& p = phiMap[L->getPointerOperand()]; + for (SmallPtrSet::iterator I = p.begin(), E = p.end(); + I != E; ++I) { +if ((*I)->getParent() == L->getParent()) { + MD.removeInstruction(L); + L->replaceAllUsesWith(*I); + toErase.push_back(L); + NumGVNLoad++; + + return true; +} else { + repl.insert(std::make_pair((*I)->getParent(), *I)); +} + } + SmallPtrSet visited; Value* v = GetValueForBlock(L->getParent(), L, repl, true); MD.removeInstruction(L); L->replaceAllUsesWith(v); toErase.push_back(L); + NumGVNLoad++; return true; } @@ -917,6 +939,7 @@ // Clean out global sets from any previous functions VN.clear(); availableOut.clear(); + phiMap.clear(); bool changed_function = false; ___ llvm-commits mailing list llvm-commits@cs.uiuc.edu http://lists.cs.uiuc.edu/mailman/listinfo/llvm-commits
[llvm-commits] [test-suite] r40910 - /test-suite/trunk/MultiSource/Applications/spiff/spiff.c
Author: laurov Date: Tue Aug 7 18:13:12 2007 New Revision: 40910 URL: http://llvm.org/viewvc/llvm-project?rev=40910&view=rev Log: Fix a memory leak. Modified: test-suite/trunk/MultiSource/Applications/spiff/spiff.c Modified: test-suite/trunk/MultiSource/Applications/spiff/spiff.c URL: http://llvm.org/viewvc/llvm-project/test-suite/trunk/MultiSource/Applications/spiff/spiff.c?rev=40910&r1=40909&r2=40910&view=diff == --- test-suite/trunk/MultiSource/Applications/spiff/spiff.c (original) +++ test-suite/trunk/MultiSource/Applications/spiff/spiff.c Tue Aug 7 18:13:12 2007 @@ -49,7 +49,7 @@ int argc; char *argv[]; { - E_edit edit_end; + E_edit edit_end = E_NULL; char *filename[2]; int max_d; /* max number of differences allowed */ @@ -115,6 +115,9 @@ for(i=0;i<=SPIFF_ITER;i++) { + if (edit_end != E_NULL) +free(edit_end); + if (_Y_eflag) { edit_end = Q_do_exact(K_gettmax(0),K_gettmax(1), ___ llvm-commits mailing list llvm-commits@cs.uiuc.edu http://lists.cs.uiuc.edu/mailman/listinfo/llvm-commits
[llvm-commits] [llvm] r40911 - /llvm/trunk/include/llvm/Transforms/Scalar.h
Author: dpatel Date: Tue Aug 7 18:16:03 2007 New Revision: 40911 URL: http://llvm.org/viewvc/llvm-project?rev=40911&view=rev Log: Fix comment. Modified: llvm/trunk/include/llvm/Transforms/Scalar.h Modified: llvm/trunk/include/llvm/Transforms/Scalar.h URL: http://llvm.org/viewvc/llvm-project/llvm/trunk/include/llvm/Transforms/Scalar.h?rev=40911&r1=40910&r2=40911&view=diff == --- llvm/trunk/include/llvm/Transforms/Scalar.h (original) +++ llvm/trunk/include/llvm/Transforms/Scalar.h Tue Aug 7 18:16:03 2007 @@ -143,7 +143,8 @@ //===--===// // -// LoopIndexSplit - This pass splits loop +// LoopIndexSplit - This pass divides loop's iteration range by spliting loop +// such that each individual loop is executed efficiently. // LoopPass *createLoopIndexSplitPass(); ___ llvm-commits mailing list llvm-commits@cs.uiuc.edu http://lists.cs.uiuc.edu/mailman/listinfo/llvm-commits
[llvm-commits] [llvm] r40912 - /llvm/trunk/lib/Transforms/Scalar/LoopIndexSplit.cpp
Author: dpatel Date: Tue Aug 7 18:17:52 2007 New Revision: 40912 URL: http://llvm.org/viewvc/llvm-project?rev=40912&view=rev Log: Fix new compare instruction's signness. Caught by Chris during review. Modified: llvm/trunk/lib/Transforms/Scalar/LoopIndexSplit.cpp Modified: llvm/trunk/lib/Transforms/Scalar/LoopIndexSplit.cpp URL: http://llvm.org/viewvc/llvm-project/llvm/trunk/lib/Transforms/Scalar/LoopIndexSplit.cpp?rev=40912&r1=40911&r2=40912&view=diff == --- llvm/trunk/lib/Transforms/Scalar/LoopIndexSplit.cpp (original) +++ llvm/trunk/lib/Transforms/Scalar/LoopIndexSplit.cpp Tue Aug 7 18:17:52 2007 @@ -13,8 +13,8 @@ #define DEBUG_TYPE "loop-index-split" -#include "llvm/Function.h" #include "llvm/Transforms/Scalar.h" +#include "llvm/Function.h" #include "llvm/Analysis/LoopPass.h" #include "llvm/Analysis/ScalarEvolutionExpander.h" #include "llvm/Support/Compiler.h" @@ -83,6 +83,9 @@ // This compare instruction compares IndVar against SplitValue. ICmpInst *SplitCondition; + +// Loop exit condition. +ICmpInst *ExitCondition; }; char LoopIndexSplit::ID = 0; @@ -228,7 +231,7 @@ // c1 = icmp uge i32 SplitValue, StartValue // c2 = icmp ult i32 vSplitValue, ExitValue // and i32 c1, c2 - bool SignedPredicate = SplitCondition->isSignedPredicate(); + bool SignedPredicate = ExitCondition->isSignedPredicate(); Instruction *C1 = new ICmpInst(SignedPredicate ? ICmpInst::ICMP_SGE : ICmpInst::ICMP_UGE, SplitValue, StartValue, "lisplit", Terminator); @@ -303,7 +306,6 @@ // loop may not be eliminated. This is used by processOneIterationLoop(). bool LoopIndexSplit::safeExitBlock(BasicBlock *ExitBlock) { - Instruction *ExitCondition = NULL; Instruction *IndVarIncrement = NULL; for (BasicBlock::iterator BI = ExitBlock->begin(), BE = ExitBlock->end(); @@ -339,11 +341,11 @@ // I is an Exit condition if next instruction is block terminator. // Exit condition is OK if it compares loop invariant exit value, // which is checked below. -else if (isa(I)) { +else if (ICmpInst *EC = dyn_cast(I)) { ++BI; Instruction *N = BI; if (N == ExitBlock->getTerminator()) { -ExitCondition = I; +ExitCondition = EC; break; } } ___ llvm-commits mailing list llvm-commits@cs.uiuc.edu http://lists.cs.uiuc.edu/mailman/listinfo/llvm-commits
[llvm-commits] [llvm] r40913 - in /llvm/trunk: include/llvm/CodeGen/LiveInterval.h lib/CodeGen/LiveInterval.cpp lib/CodeGen/LiveIntervalAnalysis.cpp lib/CodeGen/SimpleRegisterCoalescing.cpp
Author: evancheng Date: Tue Aug 7 18:49:57 2007 New Revision: 40913 URL: http://llvm.org/viewvc/llvm-project?rev=40913&view=rev Log: - LiveInterval value#'s now have 3 components: def instruction #, kill instruction #, and source register number (iff the value# is defined by a copy). - Now def instruction # is set for every value#, not just for copy defined ones. - Update some outdated code related inactive live ranges. - Kill info not yet set. That's next patch. Modified: llvm/trunk/include/llvm/CodeGen/LiveInterval.h llvm/trunk/lib/CodeGen/LiveInterval.cpp llvm/trunk/lib/CodeGen/LiveIntervalAnalysis.cpp llvm/trunk/lib/CodeGen/SimpleRegisterCoalescing.cpp Modified: llvm/trunk/include/llvm/CodeGen/LiveInterval.h URL: http://llvm.org/viewvc/llvm-project/llvm/trunk/include/llvm/CodeGen/LiveInterval.h?rev=40913&r1=40912&r2=40913&view=diff == --- llvm/trunk/include/llvm/CodeGen/LiveInterval.h (original) +++ llvm/trunk/include/llvm/CodeGen/LiveInterval.h Tue Aug 7 18:49:57 2007 @@ -85,13 +85,22 @@ float weight;// weight of this interval MachineInstr* remat; // definition if the definition rematerializable Ranges ranges; // the ranges in which this register is live + +/// ValueNumberInfo - If the value number definition is undefined (e.g. phi +/// merge point), it contains ~0,x,x. If the value number is not in use, it +/// contains ~1,x,x to indicate that the value # is not used. The first +/// entry is the instruction # of the definition, the second is the kill #. +/// If the third value is non-zero, then the val# is defined by a copy and +/// it represents the register number it is copied from. +struct VNInfo { + unsigned def; + unsigned kill; + unsigned reg; + VNInfo() : def(~1U), kill(~0U), reg(0) {}; + VNInfo(unsigned d, unsigned k, unsigned r) : def(d), kill(k), reg(r) {}; +}; private: -/// ValueNumberInfo - If this value number is not defined by a copy, this -/// holds ~0,x. If the value number is not in use, it contains ~1,x to -/// indicate that the value # is not used. If the val# is defined by a -/// copy, the first entry is the instruction # of the copy, and the second -/// is the register number copied from. -SmallVector, 4> ValueNumberInfo; +SmallVector ValueNumberInfo; public: LiveInterval(unsigned Reg, float Weight) @@ -134,7 +143,7 @@ /// getNextValue - Create a new value number and return it. MIIdx specifies /// the instruction that defines the value number. unsigned getNextValue(unsigned MIIdx, unsigned SrcReg) { - ValueNumberInfo.push_back(std::make_pair(MIIdx, SrcReg)); + ValueNumberInfo.push_back(VNInfo(MIIdx, ~0U, SrcReg)); return ValueNumberInfo.size()-1; } @@ -142,25 +151,29 @@ /// specified value number. unsigned getInstForValNum(unsigned ValNo) const { //assert(ValNo < ValueNumberInfo.size()); - return ValueNumberInfo[ValNo].first; + return ValueNumberInfo[ValNo].def; +} + +/// getKillForValNum - Return the machine instruction index that kills the +/// specified value number. +unsigned getKillForValNum(unsigned ValNo) const { + //assert(ValNo < ValueNumberInfo.size()); + return ValueNumberInfo[ValNo].kill; } unsigned getSrcRegForValNum(unsigned ValNo) const { //assert(ValNo < ValueNumberInfo.size()); - if (ValueNumberInfo[ValNo].first < ~2U) -return ValueNumberInfo[ValNo].second; - return 0; + return ValueNumberInfo[ValNo].reg; } -std::pair getValNumInfo(unsigned ValNo) const { +VNInfo getValNumInfo(unsigned ValNo) const { //assert(ValNo < ValueNumberInfo.size()); return ValueNumberInfo[ValNo]; } /// setValueNumberInfo - Change the value number info for the specified /// value number. -void setValueNumberInfo(unsigned ValNo, -const std::pair &I){ +void setValueNumberInfo(unsigned ValNo, const VNInfo &I) { ValueNumberInfo[ValNo] = I; } @@ -247,7 +260,7 @@ /// the intervals are not joinable, this aborts. void join(LiveInterval &Other, int *ValNoAssignments, int *RHSValNoAssignments, - SmallVector,16> &NewValueNumberInfo); + SmallVector &NewValueNumberInfo); /// removeRange - Remove the specified range from this interval. Note that /// the range must already be in this interval in its entirety. Modified: llvm/trunk/lib/CodeGen/LiveInterval.cpp URL: http://llvm.org/viewvc/llvm-project/llvm/trunk/lib/CodeGen/LiveInterval.cpp?rev=40913&r1=40912&r2=40913&view=diff == --- llvm/trunk/lib/CodeGen/LiveInterval.cpp (original) +++ llvm/trunk/lib/CodeGen/LiveInterval.cpp Tue Aug 7 1
[llvm-commits] [llvm] r40914 - /llvm/trunk/lib/CodeGen/LiveInterval.cpp
Author: evancheng Date: Tue Aug 7 20:00:21 2007 New Revision: 40914 URL: http://llvm.org/viewvc/llvm-project?rev=40914&view=rev Log: Remove a dead assertion. Modified: llvm/trunk/lib/CodeGen/LiveInterval.cpp Modified: llvm/trunk/lib/CodeGen/LiveInterval.cpp URL: http://llvm.org/viewvc/llvm-project/llvm/trunk/lib/CodeGen/LiveInterval.cpp?rev=40914&r1=40913&r2=40914&view=diff == --- llvm/trunk/lib/CodeGen/LiveInterval.cpp (original) +++ llvm/trunk/lib/CodeGen/LiveInterval.cpp Tue Aug 7 20:00:21 2007 @@ -300,7 +300,6 @@ // we want to avoid the interval scan if not. bool MustMapCurValNos = false; for (unsigned i = 0, e = getNumValNums(); i != e; ++i) { -assert(ValueNumberInfo[i].def != ~2U); if (ValueNumberInfo[i].def == ~1U) continue; // tombstone value # if (i != (unsigned)LHSValNoAssignments[i]) { MustMapCurValNos = true; ___ llvm-commits mailing list llvm-commits@cs.uiuc.edu http://lists.cs.uiuc.edu/mailman/listinfo/llvm-commits
Re: [llvm-commits] [llvm] r40913 - in /llvm/trunk: include/llvm/CodeGen/LiveInterval.h lib/CodeGen/LiveInterval.cpp lib/CodeGen/LiveIntervalAnalysis.cpp lib/CodeGen/SimpleRegisterCoalescing.cpp
On Aug 7, 2007, at 4:49 PM, Evan Cheng wrote: > Author: evancheng > Date: Tue Aug 7 18:49:57 2007 > New Revision: 40913 > > URL: http://llvm.org/viewvc/llvm-project?rev=40913&view=rev > Log: > - LiveInterval value#'s now have 3 components: def instruction #, > kill instruction #, and source register number (iff the value# is > defined by a > copy). > - Now def instruction # is set for every value#, not just for copy > defined ones. > - Update some outdated code related inactive live ranges. > - Kill info not yet set. That's next patch. Nice > +/// ValueNumberInfo - If the value number definition is > undefined (e.g. phi > +/// merge point), it contains ~0,x,x. If the value number is > not in use, it > +/// contains ~1,x,x to indicate that the value # is not used. > The first > +/// entry is the instruction # of the definition, the second > is the kill #. > +/// If the third value is non-zero, then the val# is defined > by a copy and > +/// it represents the register number it is copied from. > +struct VNInfo { > + unsigned def; > + unsigned kill; > + unsigned reg; Yay for structs with actual names on the members :). With this you can now move the "The first entry is the instruction #" comments down to the members in the struct. -Chris ___ llvm-commits mailing list llvm-commits@cs.uiuc.edu http://lists.cs.uiuc.edu/mailman/listinfo/llvm-commits
[llvm-commits] [llvm] r40915 - /llvm/trunk/lib/Transforms/Scalar/LoopIndexSplit.cpp
Author: dpatel Date: Tue Aug 7 20:51:27 2007 New Revision: 40915 URL: http://llvm.org/viewvc/llvm-project?rev=40915&view=rev Log: Embrace patch review feedback. Modified: llvm/trunk/lib/Transforms/Scalar/LoopIndexSplit.cpp Modified: llvm/trunk/lib/Transforms/Scalar/LoopIndexSplit.cpp URL: http://llvm.org/viewvc/llvm-project/llvm/trunk/lib/Transforms/Scalar/LoopIndexSplit.cpp?rev=40915&r1=40914&r2=40915&view=diff == --- llvm/trunk/lib/Transforms/Scalar/LoopIndexSplit.cpp (original) +++ llvm/trunk/lib/Transforms/Scalar/LoopIndexSplit.cpp Tue Aug 7 20:51:27 2007 @@ -217,13 +217,26 @@ if (!safeExitBlock(ExitBlock)) return false; + // Update CFG. + + // As a first step to break this loop, remove Latch to Header edge. BasicBlock *Latch = L->getLoopLatch(); + BasicBlock *LatchSucc = NULL; + BranchInst *BR = dyn_cast(Latch->getTerminator()); + if (!BR) +return false; + Header->removePredecessor(Latch); + for (succ_iterator SI = succ_begin(Latch), E = succ_end(Latch); + SI != E; ++SI) { +if (Header != *SI) + LatchSucc = *SI; + } + BR->setUnconditionalDest(LatchSucc); + BasicBlock *Preheader = L->getLoopPreheader(); Instruction *Terminator = Header->getTerminator(); Value *StartValue = IndVar->getIncomingValueForBlock(Preheader); - // Update CFG. - // Replace split condition in header. // Transform // SplitCondition : icmp eq i32 IndVar, SplitValue @@ -238,22 +251,10 @@ Instruction *C2 = new ICmpInst(SignedPredicate ? ICmpInst::ICMP_SLT : ICmpInst::ICMP_ULT, SplitValue, ExitValue, "lisplit", Terminator); - Instruction *NSplitCond = BinaryOperator::create(Instruction::And, - C1, C2, "lisplit", Terminator); + Instruction *NSplitCond = BinaryOperator::createAnd(C1, C2, "lisplit", Terminator); SplitCondition->replaceAllUsesWith(NSplitCond); SplitCondition->eraseFromParent(); - // As a first step to break this loop, remove Latch to Header edge. - BasicBlock *LatchSucc = NULL; - Header->removePredecessor(Latch); - for (succ_iterator SI = succ_begin(Latch), E = succ_end(Latch); - SI != E; ++SI) { -if (Header != *SI) - LatchSucc = *SI; - } - BranchInst *BR = dyn_cast(Latch->getTerminator()); - BR->setUnconditionalDest(LatchSucc); - // Now, clear latch block. Remove instructions that are responsible // to increment induction variable. Instruction *LTerminator = Latch->getTerminator(); @@ -281,15 +282,13 @@ BI != BE; ++BI) { Instruction *I = BI; -// PHI Nodes are OK. +// PHI Nodes are OK. FIXME : Handle last value assignments. if (isa(I)) continue; // SplitCondition itself is OK. -if (ICmpInst *CI = dyn_cast(I)) { - if (CI == SplitCondition) -continue; -} +if (I == SplitCondition) + continue; // Terminator is also harmless. if (I == Terminator) @@ -307,12 +306,12 @@ bool LoopIndexSplit::safeExitBlock(BasicBlock *ExitBlock) { Instruction *IndVarIncrement = NULL; - + for (BasicBlock::iterator BI = ExitBlock->begin(), BE = ExitBlock->end(); BI != BE; ++BI) { Instruction *I = BI; -// PHI Nodes are OK. +// PHI Nodes are OK. FIXME : Handle last value assignments. if (isa(I)) continue; @@ -338,6 +337,7 @@ if (IndVarIncrement && PN == IndVar && CI->isOne()) continue; } + // I is an Exit condition if next instruction is block terminator. // Exit condition is OK if it compares loop invariant exit value, // which is checked below. @@ -346,7 +346,7 @@ Instruction *N = BI; if (N == ExitBlock->getTerminator()) { ExitCondition = EC; -break; +continue; } } ___ llvm-commits mailing list llvm-commits@cs.uiuc.edu http://lists.cs.uiuc.edu/mailman/listinfo/llvm-commits
[llvm-commits] [llvm] r40916 - in /llvm/trunk: include/llvm/CodeGen/LiveInterval.h lib/CodeGen/LiveInterval.cpp lib/CodeGen/LiveIntervalAnalysis.cpp lib/CodeGen/SimpleRegisterCoalescing.cpp
Author: evancheng Date: Tue Aug 7 22:00:28 2007 New Revision: 40916 URL: http://llvm.org/viewvc/llvm-project?rev=40916&view=rev Log: - Each val# can have multiple kills. - Fix some minor bugs related to special markers on val# def. ~0U means undefined, ~1U means dead val#. Modified: llvm/trunk/include/llvm/CodeGen/LiveInterval.h llvm/trunk/lib/CodeGen/LiveInterval.cpp llvm/trunk/lib/CodeGen/LiveIntervalAnalysis.cpp llvm/trunk/lib/CodeGen/SimpleRegisterCoalescing.cpp Modified: llvm/trunk/include/llvm/CodeGen/LiveInterval.h URL: http://llvm.org/viewvc/llvm-project/llvm/trunk/include/llvm/CodeGen/LiveInterval.h?rev=40916&r1=40915&r2=40916&view=diff == --- llvm/trunk/include/llvm/CodeGen/LiveInterval.h (original) +++ llvm/trunk/include/llvm/CodeGen/LiveInterval.h Tue Aug 7 22:00:28 2007 @@ -87,17 +87,14 @@ Ranges ranges; // the ranges in which this register is live /// ValueNumberInfo - If the value number definition is undefined (e.g. phi -/// merge point), it contains ~0,x,x. If the value number is not in use, it -/// contains ~1,x,x to indicate that the value # is not used. The first -/// entry is the instruction # of the definition, the second is the kill #. -/// If the third value is non-zero, then the val# is defined by a copy and -/// it represents the register number it is copied from. +/// merge point), it contains ~0u,x. If the value number is not in use, it +/// contains ~1u,x to indicate that the value # is not used. struct VNInfo { - unsigned def; - unsigned kill; - unsigned reg; - VNInfo() : def(~1U), kill(~0U), reg(0) {}; - VNInfo(unsigned d, unsigned k, unsigned r) : def(d), kill(k), reg(r) {}; + unsigned def; // instruction # of the definition + unsigned reg; // src reg: non-zero iff val# is defined by a copy + SmallVector kills; // instruction #s of the kills + VNInfo() : def(~1U), reg(0) {}; + VNInfo(unsigned d, unsigned r) : def(d), reg(r) {}; }; private: SmallVector ValueNumberInfo; @@ -143,7 +140,7 @@ /// getNextValue - Create a new value number and return it. MIIdx specifies /// the instruction that defines the value number. unsigned getNextValue(unsigned MIIdx, unsigned SrcReg) { - ValueNumberInfo.push_back(VNInfo(MIIdx, ~0U, SrcReg)); + ValueNumberInfo.push_back(VNInfo(MIIdx, SrcReg)); return ValueNumberInfo.size()-1; } @@ -154,16 +151,22 @@ return ValueNumberInfo[ValNo].def; } -/// getKillForValNum - Return the machine instruction index that kills the -/// specified value number. -unsigned getKillForValNum(unsigned ValNo) const { +unsigned getSrcRegForValNum(unsigned ValNo) const { //assert(ValNo < ValueNumberInfo.size()); - return ValueNumberInfo[ValNo].kill; + return ValueNumberInfo[ValNo].reg; } -unsigned getSrcRegForValNum(unsigned ValNo) const { +/// getKillsForValNum - Return the kill instruction indexes of the specified +/// value number. +SmallVector getKillsForValNum(unsigned ValNo) const { //assert(ValNo < ValueNumberInfo.size()); - return ValueNumberInfo[ValNo].reg; + return ValueNumberInfo[ValNo].kills; +} + +/// addKillForValNum - Add a kill instruction index to the specified value +/// number. +void addKillForValNum(unsigned ValNo, unsigned KillIdx) { + ValueNumberInfo[ValNo].kills.push_back(KillIdx); } VNInfo getValNumInfo(unsigned ValNo) const { @@ -176,7 +179,7 @@ void setValueNumberInfo(unsigned ValNo, const VNInfo &I) { ValueNumberInfo[ValNo] = I; } - + /// MergeValueNumberInto - This method is called when two value nubmers /// are found to be equivalent. This eliminates V1, replacing all /// LiveRanges with the V1 value number with the V2 value number. This can Modified: llvm/trunk/lib/CodeGen/LiveInterval.cpp URL: http://llvm.org/viewvc/llvm-project/llvm/trunk/lib/CodeGen/LiveInterval.cpp?rev=40916&r1=40915&r2=40916&view=diff == --- llvm/trunk/lib/CodeGen/LiveInterval.cpp (original) +++ llvm/trunk/lib/CodeGen/LiveInterval.cpp Tue Aug 7 22:00:28 2007 @@ -300,7 +300,7 @@ // we want to avoid the interval scan if not. bool MustMapCurValNos = false; for (unsigned i = 0, e = getNumValNums(); i != e; ++i) { -if (ValueNumberInfo[i].def == ~1U) continue; // tombstone value # +//if (ValueNumberInfo[i].def == ~1U) continue; // tombstone value # if (i != (unsigned)LHSValNoAssignments[i]) { MustMapCurValNos = true; break; @@ -508,14 +508,11 @@ OS << i << "@"; if (ValueNumberInfo[i].def == ~0U) { OS << "?"; + } else if (ValueNumberInfo[i].def == ~1U) { +OS << "x"; } else { OS << V
[llvm-commits] [llvm-gcc-4.0] r40917 - /llvm-gcc-4.0/tags/llvm-gcc-1200-06/
Author: void Date: Tue Aug 7 22:11:42 2007 New Revision: 40917 URL: http://llvm.org/viewvc/llvm-project?rev=40917&view=rev Log: Creating llvm-gcc-1200-06 branch Added: llvm-gcc-4.0/tags/llvm-gcc-1200-06/ - copied from r40916, llvm-gcc-4.0/trunk/ ___ llvm-commits mailing list llvm-commits@cs.uiuc.edu http://lists.cs.uiuc.edu/mailman/listinfo/llvm-commits
[llvm-commits] [llvm] r40918 - /llvm/tags/Apple/llvm-1200-06/
Author: void Date: Tue Aug 7 22:11:50 2007 New Revision: 40918 URL: http://llvm.org/viewvc/llvm-project?rev=40918&view=rev Log: Creating llvm-1200-06 branch Added: llvm/tags/Apple/llvm-1200-06/ - copied from r40917, llvm/trunk/ ___ llvm-commits mailing list llvm-commits@cs.uiuc.edu http://lists.cs.uiuc.edu/mailman/listinfo/llvm-commits
Re: [llvm-commits] [llvm] r40916 - in /llvm/trunk: include/llvm/CodeGen/LiveInterval.h lib/CodeGen/LiveInterval.cpp lib/CodeGen/LiveIntervalAnalysis.cpp lib/CodeGen/SimpleRegisterCoalescing.cpp
Evan, On Wed, 2007-08-08 at 03:00 +, Evan Cheng wrote: > Author: evancheng > Date: Tue Aug 7 22:00:28 2007 > New Revision: 40916 > > URL: http://llvm.org/viewvc/llvm-project?rev=40916&view=rev > Log: > - Each val# can have multiple kills. > - Fix some minor bugs related to special markers on val# def. ~0U means > undefined, ~1U means dead val#. > > Modified: > llvm/trunk/include/llvm/CodeGen/LiveInterval.h > llvm/trunk/lib/CodeGen/LiveInterval.cpp > llvm/trunk/lib/CodeGen/LiveIntervalAnalysis.cpp > llvm/trunk/lib/CodeGen/SimpleRegisterCoalescing.cpp > > Modified: llvm/trunk/include/llvm/CodeGen/LiveInterval.h > URL: > http://llvm.org/viewvc/llvm-project/llvm/trunk/include/llvm/CodeGen/LiveInterval.h?rev=40916&r1=40915&r2=40916&view=diff > > == > --- llvm/trunk/include/llvm/CodeGen/LiveInterval.h (original) > +++ llvm/trunk/include/llvm/CodeGen/LiveInterval.h Tue Aug 7 22:00:28 2007 > @@ -87,17 +87,14 @@ > Ranges ranges; // the ranges in which this register is live > > /// ValueNumberInfo - If the value number definition is undefined (e.g. > phi > -/// merge point), it contains ~0,x,x. If the value number is not in use, > it > -/// contains ~1,x,x to indicate that the value # is not used. The first > -/// entry is the instruction # of the definition, the second is the kill > #. > -/// If the third value is non-zero, then the val# is defined by a copy > and > -/// it represents the register number it is copied from. > +/// merge point), it contains ~0u,x. If the value number is not in use, > it > +/// contains ~1u,x to indicate that the value # is not used. > struct VNInfo { > - unsigned def; > - unsigned kill; > - unsigned reg; > - VNInfo() : def(~1U), kill(~0U), reg(0) {}; > - VNInfo(unsigned d, unsigned k, unsigned r) : def(d), kill(k), reg(r) > {}; > + unsigned def; // instruction # of the definition > + unsigned reg; // src reg: non-zero iff val# is defined by a copy > + SmallVector kills; // instruction #s of the kills Why loose the doxygen on these? The /// lines you removed were previously included in the doxygen documentation, now they won't be. Please use ///< to indicate a doxygen comment that applies to the preceding field. You can do this for function parameters too. Thanks, Reid. > + VNInfo() : def(~1U), reg(0) {}; > + VNInfo(unsigned d, unsigned r) : def(d), reg(r) {}; > }; >private: > SmallVector ValueNumberInfo; > @@ -143,7 +140,7 @@ > /// getNextValue - Create a new value number and return it. MIIdx > specifies > /// the instruction that defines the value number. > unsigned getNextValue(unsigned MIIdx, unsigned SrcReg) { > - ValueNumberInfo.push_back(VNInfo(MIIdx, ~0U, SrcReg)); > + ValueNumberInfo.push_back(VNInfo(MIIdx, SrcReg)); >return ValueNumberInfo.size()-1; > } > > @@ -154,16 +151,22 @@ >return ValueNumberInfo[ValNo].def; > } > > -/// getKillForValNum - Return the machine instruction index that kills > the > -/// specified value number. > -unsigned getKillForValNum(unsigned ValNo) const { > +unsigned getSrcRegForValNum(unsigned ValNo) const { >//assert(ValNo < ValueNumberInfo.size()); > - return ValueNumberInfo[ValNo].kill; > + return ValueNumberInfo[ValNo].reg; > } > > -unsigned getSrcRegForValNum(unsigned ValNo) const { > +/// getKillsForValNum - Return the kill instruction indexes of the > specified > +/// value number. > +SmallVector getKillsForValNum(unsigned ValNo) const { >//assert(ValNo < ValueNumberInfo.size()); > - return ValueNumberInfo[ValNo].reg; > + return ValueNumberInfo[ValNo].kills; > +} > + > +/// addKillForValNum - Add a kill instruction index to the specified > value > +/// number. > +void addKillForValNum(unsigned ValNo, unsigned KillIdx) { > + ValueNumberInfo[ValNo].kills.push_back(KillIdx); > } > > VNInfo getValNumInfo(unsigned ValNo) const { > @@ -176,7 +179,7 @@ > void setValueNumberInfo(unsigned ValNo, const VNInfo &I) { >ValueNumberInfo[ValNo] = I; > } > - > + > /// MergeValueNumberInto - This method is called when two value nubmers > /// are found to be equivalent. This eliminates V1, replacing all > /// LiveRanges with the V1 value number with the V2 value number. This > can > > Modified: llvm/trunk/lib/CodeGen/LiveInterval.cpp > URL: > http://llvm.org/viewvc/llvm-project/llvm/trunk/lib/CodeGen/LiveInterval.cpp?rev=40916&r1=40915&r2=40916&view=diff > > == > --- llvm/trunk/lib/CodeGen/LiveInterval.cpp (original) > +++ llvm/trunk/lib/CodeGen/LiveInterval.cpp Tue Aug 7 22:00:28 2007 > @@ -300,7 +300,7 @@ >// we want to a
[llvm-commits] [llvm] r40919 - /llvm/trunk/lib/Transforms/Scalar/DeadStoreElimination.cpp
Author: resistor Date: Tue Aug 7 23:52:29 2007 New Revision: 40919 URL: http://llvm.org/viewvc/llvm-project?rev=40919&view=rev Log: First round of cleanups from Chris' feedback. Modified: llvm/trunk/lib/Transforms/Scalar/DeadStoreElimination.cpp Modified: llvm/trunk/lib/Transforms/Scalar/DeadStoreElimination.cpp URL: http://llvm.org/viewvc/llvm-project/llvm/trunk/lib/Transforms/Scalar/DeadStoreElimination.cpp?rev=40919&r1=40918&r2=40919&view=diff == --- llvm/trunk/lib/Transforms/Scalar/DeadStoreElimination.cpp (original) +++ llvm/trunk/lib/Transforms/Scalar/DeadStoreElimination.cpp Tue Aug 7 23:52:29 2007 @@ -57,16 +57,23 @@ SetVector& possiblyDead); void DeleteDeadInstructionChains(Instruction *I, SetVector &DeadInsts); + +// Find the base pointer that a pointer came from +// Because this is used to find pointers that originate +// from allocas, it is safe to ignore GEP indices, since +// either the store will be in the alloca, and thus dead, +// or beyond the end of the alloca, and thus undefined. void TranslatePointerBitCasts(Value*& v) { assert(isa(v->getType()) && "Translating a non-pointer type?"); - - // See through pointer-to-pointer bitcasts - while (isa(v) || isa(v)) + while (true) { if (BitCastInst* C = dyn_cast(v)) v = C->getOperand(0); else if (GetElementPtrInst* G = dyn_cast(v)) v = G->getOperand(0); +else + break; + } } // getAnalysisUsage - We require post dominance frontiers (aka Control @@ -100,62 +107,62 @@ for (BasicBlock::iterator BBI = BB.begin(), BBE = BB.end(); BBI != BBE; ++BBI) { // If we find a store or a free... -if (isa(BBI) || isa(BBI)) { - Value* pointer = 0; - if (StoreInst* S = dyn_cast(BBI)) -pointer = S->getPointerOperand(); - else if (FreeInst* F = dyn_cast(BBI)) -pointer = F->getPointerOperand(); +if (!isa(BBI) && !isa(BBI)) + continue; - assert(pointer && "Not a free or a store?"); +Value* pointer = 0; +if (StoreInst* S = dyn_cast(BBI)) + pointer = S->getPointerOperand(); +else if (FreeInst* F = dyn_cast(BBI)) + pointer = F->getPointerOperand(); - StoreInst*& last = lastStore[pointer]; - bool deletedStore = false; +assert(pointer && "Not a free or a store?"); - // ... to a pointer that has been stored to before... - if (last) { +StoreInst*& last = lastStore[pointer]; +bool deletedStore = false; + +// ... to a pointer that has been stored to before... +if (last) { + Instruction* dep = MD.getDependency(BBI); -Instruction* dep = MD.getDependency(BBI); + // ... and no other memory dependencies are between them + while (dep != MemoryDependenceAnalysis::None && + dep != MemoryDependenceAnalysis::NonLocal && + isa(dep)) { +if (dep != last) { + dep = MD.getDependency(BBI, dep); + continue; +} -// ... and no other memory dependencies are between them -while (dep != MemoryDependenceAnalysis::None && - dep != MemoryDependenceAnalysis::NonLocal && - isa(dep)) { - if (dep == last) { - -// Remove it! -MD.removeInstruction(last); +// Remove it! +MD.removeInstruction(last); -// DCE instructions only used to calculate that store -if (Instruction* D = dyn_cast(last->getOperand(0))) - possiblyDead.insert(D); -if (Instruction* D = dyn_cast(last->getOperand(1))) - possiblyDead.insert(D); +// DCE instructions only used to calculate that store +if (Instruction* D = dyn_cast(last->getOperand(0))) + possiblyDead.insert(D); +if (Instruction* D = dyn_cast(last->getOperand(1))) + possiblyDead.insert(D); -last->eraseFromParent(); -NumFastStores++; -deletedStore = true; -MadeChange = true; - -break; - } else { -dep = MD.getDependency(BBI, dep); - } -} +last->eraseFromParent(); +NumFastStores++; +deletedStore = true; +MadeChange = true; + +break; } - - // Handle frees whose dependencies are non-trivial - if (FreeInst* F = dyn_cast(BBI)) -if (!deletedStore) - MadeChange |= handleFreeWithNonTrivialDependency(F, - MD.getDependency(F), - possiblyDead); - - // Update our most-recent-store map
Re: [llvm-commits] [llvm] r40919 - /llvm/trunk/lib/Transforms/Scalar/DeadStoreElimination.cpp
> URL: http://llvm.org/viewvc/llvm-project?rev=40919&view=rev > Log: > First round of cleanups from Chris' feedback. Cool. in addition to saying why you did it, plz say "what" you did for the svn log. :) > + > +// Find the base pointer that a pointer came from > +// Because this is used to find pointers that originate > +// from allocas, it is safe to ignore GEP indices, since > +// either the store will be in the alloca, and thus dead, > +// or beyond the end of the alloca, and thus undefined. Please use /// comments so they are included in doxygen. > +Value* pointer = 0; > +if (StoreInst* S = dyn_cast(BBI)) > + pointer = S->getPointerOperand(); > +else if (FreeInst* F = dyn_cast(BBI)) > + pointer = F->getPointerOperand(); > > +assert(pointer && "Not a free or a store?"); I'd suggest just writing this as: > +if (StoreInst* S = dyn_cast(BBI)) > + pointer = S->getPointerOperand(); > +else > + pointer = cast(BBI)->getPointerOperand(); which makes it obvious that the assert is unneeded. Thanks! -Chris ___ llvm-commits mailing list llvm-commits@cs.uiuc.edu http://lists.cs.uiuc.edu/mailman/listinfo/llvm-commits
Re: [llvm-commits] [llvm] r40916 - in /llvm/trunk: include/llvm/CodeGen/LiveInterval.h lib/CodeGen/LiveInterval.cpp lib/CodeGen/LiveIntervalAnalysis.cpp lib/CodeGen/SimpleRegisterCoalescing.cpp
> - Each val# can have multiple kills. > - Fix some minor bugs related to special markers on val# def. ~0U > means > undefined, ~1U means dead val#. > + unsigned def; // instruction # of the definition > + unsigned reg; // src reg: non-zero iff val# is defined by a > copy > + SmallVector kills; // instruction #s of the kills Thanks! > +/// getKillsForValNum - Return the kill instruction indexes of > the specified > +/// value number. > +SmallVector getKillsForValNum(unsigned ValNo) > const { This should return the vector by const reference, instead of by copy. >//assert(ValNo < ValueNumberInfo.size()); Why not leave the assert in? :) > @@ -300,7 +300,7 @@ >// we want to avoid the interval scan if not. >bool MustMapCurValNos = false; >for (unsigned i = 0, e = getNumValNums(); i != e; ++i) { > -if (ValueNumberInfo[i].def == ~1U) continue; // tombstone > value # > +//if (ValueNumberInfo[i].def == ~1U) continue; // tombstone > value # Will it stay or will it go? :) -Chris ___ llvm-commits mailing list llvm-commits@cs.uiuc.edu http://lists.cs.uiuc.edu/mailman/listinfo/llvm-commits
[llvm-commits] [llvm] r40920 - in /llvm/trunk: include/llvm/Analysis/Dominators.h lib/Analysis/PostDominators.cpp lib/VMCore/Dominators.cpp
Author: lattner Date: Wed Aug 8 00:51:24 2007 New Revision: 40920 URL: http://llvm.org/viewvc/llvm-project?rev=40920&view=rev Log: reimplement dfs number computation to be significantly faster. This speeds up natural loop canonicalization (which does many cfg xforms) by 4.3x, for example. This also fixes a bug in postdom dfnumber computation. Modified: llvm/trunk/include/llvm/Analysis/Dominators.h llvm/trunk/lib/Analysis/PostDominators.cpp llvm/trunk/lib/VMCore/Dominators.cpp Modified: llvm/trunk/include/llvm/Analysis/Dominators.h URL: http://llvm.org/viewvc/llvm-project/llvm/trunk/include/llvm/Analysis/Dominators.h?rev=40920&r1=40919&r2=40920&view=diff == --- llvm/trunk/include/llvm/Analysis/Dominators.h (original) +++ llvm/trunk/include/llvm/Analysis/Dominators.h Wed Aug 8 00:51:24 2007 @@ -97,17 +97,12 @@ return this->DFSNumIn >= other->DFSNumIn && this->DFSNumOut <= other->DFSNumOut; } - - /// assignDFSNumber - Assign In and Out numbers while walking dominator tree - /// in dfs order. - void assignDFSNumber(int num); }; //===--===// /// DominatorTree - Calculate the immediate dominator tree for a function. /// class DominatorTreeBase : public DominatorBase { - protected: void reset(); typedef DenseMap DomTreeNodeMapType; @@ -135,9 +130,7 @@ // Info - Collection of information used during the computation of idoms. DenseMap Info; - void updateDFSNumbers(); - - public: +public: DominatorTreeBase(intptr_t ID, bool isPostDom) : DominatorBase(ID, isPostDom), DFSInfoValid(false), SlowQueries(0) {} ~DominatorTreeBase() { reset(); } @@ -275,6 +268,11 @@ if (OS) print(*OS, M); } virtual void dump(); + +protected: + /// updateDFSNumbers - Assign In and Out numbers to the nodes while walking + /// dominator tree in dfs order. + void updateDFSNumbers(); }; //===- Modified: llvm/trunk/lib/Analysis/PostDominators.cpp URL: http://llvm.org/viewvc/llvm-project/llvm/trunk/lib/Analysis/PostDominators.cpp?rev=40920&r1=40919&r2=40920&view=diff == --- llvm/trunk/lib/Analysis/PostDominators.cpp (original) +++ llvm/trunk/lib/Analysis/PostDominators.cpp Wed Aug 8 00:51:24 2007 @@ -193,15 +193,9 @@ Info.clear(); std::vector().swap(Vertex); - int dfsnum = 0; - // Iterate over all nodes in depth first order... - for (unsigned i = 0, e = Roots.size(); i != e; ++i) -for (idf_iterator I = idf_begin(Roots[i]), - E = idf_end(Roots[i]); I != E; ++I) { - if (!getNodeForBlock(*I)->getIDom()) -getNodeForBlock(*I)->assignDFSNumber(dfsnum); -} - DFSInfoValid = true; + // Start out with the DFS numbers being invalid. Let them be computed if + // demanded. + DFSInfoValid = false; } Modified: llvm/trunk/lib/VMCore/Dominators.cpp URL: http://llvm.org/viewvc/llvm-project/llvm/trunk/lib/VMCore/Dominators.cpp?rev=40920&r1=40919&r2=40920&view=diff == --- llvm/trunk/lib/VMCore/Dominators.cpp (original) +++ llvm/trunk/lib/VMCore/Dominators.cpp Wed Aug 8 00:51:24 2007 @@ -20,6 +20,7 @@ #include "llvm/ADT/DepthFirstIterator.h" #include "llvm/ADT/SetOperations.h" #include "llvm/ADT/SmallPtrSet.h" +#include "llvm/ADT/SmallVector.h" #include "llvm/Instructions.h" #include "llvm/Support/Streams.h" #include @@ -383,15 +384,39 @@ } void DominatorTreeBase::updateDFSNumbers() { - int dfsnum = 0; - // Iterate over all nodes in depth first order. - for (unsigned i = 0, e = Roots.size(); i != e; ++i) -for (df_iterator I = df_begin(Roots[i]), - E = df_end(Roots[i]); I != E; ++I) { - if (DomTreeNode *BBNode = getNode(*I)) { -if (!BBNode->getIDom()) - BBNode->assignDFSNumber(dfsnum); + unsigned DFSNum = 0; + + SmallVector WorkStack; + SmallPtrSet Visited; + + for (unsigned i = 0, e = Roots.size(); i != e; ++i) { +DomTreeNode *ThisRoot = getNode(Roots[i]); +WorkStack.push_back(ThisRoot); +Visited.insert(ThisRoot); +ThisRoot->DFSNumIn = DFSNum++; + +while (!WorkStack.empty()) { + DomTreeNode *Node = WorkStack.back(); + + bool MustVisitAChild = false; + for (DomTreeNode::iterator DI = Node->begin(), E = Node->end(); + DI != E; ++DI) { +DomTreeNode *Child = *DI; +if (!Visited.insert(Child)) + continue; + +MustVisitAChild = true; +Child->DFSNumIn = DFSNum++; +WorkStack.push_back(Child); +break; } + + if (!MustVisitAChild) { +// If we reach here means all children are visited +Node->DFSNumOut = DFSNum++; +WorkStack.pop_back(); + } +} } SlowQueries = 0; DFSInfoVali
[llvm-commits] [llvm] r40921 - in /llvm/trunk: include/llvm/CodeGen/LiveInterval.h lib/CodeGen/LiveInterval.cpp
Author: evancheng Date: Wed Aug 8 00:56:18 2007 New Revision: 40921 URL: http://llvm.org/viewvc/llvm-project?rev=40921&view=rev Log: Clean up and bug fix. Modified: llvm/trunk/include/llvm/CodeGen/LiveInterval.h llvm/trunk/lib/CodeGen/LiveInterval.cpp Modified: llvm/trunk/include/llvm/CodeGen/LiveInterval.h URL: http://llvm.org/viewvc/llvm-project/llvm/trunk/include/llvm/CodeGen/LiveInterval.h?rev=40921&r1=40920&r2=40921&view=diff == --- llvm/trunk/include/llvm/CodeGen/LiveInterval.h (original) +++ llvm/trunk/include/llvm/CodeGen/LiveInterval.h Wed Aug 8 00:56:18 2007 @@ -147,19 +147,19 @@ /// getInstForValNum - Return the machine instruction index that defines the /// specified value number. unsigned getInstForValNum(unsigned ValNo) const { - //assert(ValNo < ValueNumberInfo.size()); + assert(ValNo < ValueNumberInfo.size()); return ValueNumberInfo[ValNo].def; } unsigned getSrcRegForValNum(unsigned ValNo) const { - //assert(ValNo < ValueNumberInfo.size()); + assert(ValNo < ValueNumberInfo.size()); return ValueNumberInfo[ValNo].reg; } /// getKillsForValNum - Return the kill instruction indexes of the specified /// value number. -SmallVector getKillsForValNum(unsigned ValNo) const { - //assert(ValNo < ValueNumberInfo.size()); +const SmallVector &getKillsForValNum(unsigned ValNo) const { + assert(ValNo < ValueNumberInfo.size()); return ValueNumberInfo[ValNo].kills; } @@ -170,7 +170,7 @@ } VNInfo getValNumInfo(unsigned ValNo) const { - //assert(ValNo < ValueNumberInfo.size()); + assert(ValNo < ValueNumberInfo.size()); return ValueNumberInfo[ValNo]; } Modified: llvm/trunk/lib/CodeGen/LiveInterval.cpp URL: http://llvm.org/viewvc/llvm-project/llvm/trunk/lib/CodeGen/LiveInterval.cpp?rev=40921&r1=40920&r2=40921&view=diff == --- llvm/trunk/lib/CodeGen/LiveInterval.cpp (original) +++ llvm/trunk/lib/CodeGen/LiveInterval.cpp Wed Aug 8 00:56:18 2007 @@ -300,7 +300,7 @@ // we want to avoid the interval scan if not. bool MustMapCurValNos = false; for (unsigned i = 0, e = getNumValNums(); i != e; ++i) { -//if (ValueNumberInfo[i].def == ~1U) continue; // tombstone value # +if (ValueNumberInfo[i].def == ~1U) continue; // tombstone value # if (i != (unsigned)LHSValNoAssignments[i]) { MustMapCurValNos = true; break; ___ llvm-commits mailing list llvm-commits@cs.uiuc.edu http://lists.cs.uiuc.edu/mailman/listinfo/llvm-commits
[llvm-commits] [llvm] r40922 - /llvm/trunk/lib/Transforms/Scalar/DeadStoreElimination.cpp
Author: resistor Date: Wed Aug 8 01:06:02 2007 New Revision: 40922 URL: http://llvm.org/viewvc/llvm-project?rev=40922&view=rev Log: A few more small cleanups. Modified: llvm/trunk/lib/Transforms/Scalar/DeadStoreElimination.cpp Modified: llvm/trunk/lib/Transforms/Scalar/DeadStoreElimination.cpp URL: http://llvm.org/viewvc/llvm-project/llvm/trunk/lib/Transforms/Scalar/DeadStoreElimination.cpp?rev=40922&r1=40921&r2=40922&view=diff == --- llvm/trunk/lib/Transforms/Scalar/DeadStoreElimination.cpp (original) +++ llvm/trunk/lib/Transforms/Scalar/DeadStoreElimination.cpp Wed Aug 8 01:06:02 2007 @@ -58,11 +58,11 @@ void DeleteDeadInstructionChains(Instruction *I, SetVector &DeadInsts); -// Find the base pointer that a pointer came from -// Because this is used to find pointers that originate -// from allocas, it is safe to ignore GEP indices, since -// either the store will be in the alloca, and thus dead, -// or beyond the end of the alloca, and thus undefined. +/// Find the base pointer that a pointer came from +/// Because this is used to find pointers that originate +/// from allocas, it is safe to ignore GEP indices, since +/// either the store will be in the alloca, and thus dead, +/// or beyond the end of the alloca, and thus undefined. void TranslatePointerBitCasts(Value*& v) { assert(isa(v->getType()) && "Translating a non-pointer type?"); @@ -113,10 +113,8 @@ Value* pointer = 0; if (StoreInst* S = dyn_cast(BBI)) pointer = S->getPointerOperand(); -else if (FreeInst* F = dyn_cast(BBI)) - pointer = F->getPointerOperand(); - -assert(pointer && "Not a free or a store?"); +else + pointer = cast(BBI)->getPointerOperand(); StoreInst*& last = lastStore[pointer]; bool deletedStore = false; ___ llvm-commits mailing list llvm-commits@cs.uiuc.edu http://lists.cs.uiuc.edu/mailman/listinfo/llvm-commits
[llvm-commits] [llvm] r40923 - /llvm/trunk/lib/VMCore/Dominators.cpp
Author: lattner Date: Wed Aug 8 01:24:20 2007 New Revision: 40923 URL: http://llvm.org/viewvc/llvm-project?rev=40923&view=rev Log: Speed up updateDFSNumbers with two observations: 1. domtree is a tree, not a graph. There is no need to avoid revisiting nodes with a set. 2. the worklist can contain the child iterator pointers so we don't get N^2 rescanning of children. This speeds up updateDFSNumbers significantly, making it basically free. On the testcase in PR1432, this speeds up loopsimplify by another 3x, dropping it from the 12th most expensive pass to the to the 30th. :) It used to be #1. Modified: llvm/trunk/lib/VMCore/Dominators.cpp Modified: llvm/trunk/lib/VMCore/Dominators.cpp URL: http://llvm.org/viewvc/llvm-project/llvm/trunk/lib/VMCore/Dominators.cpp?rev=40923&r1=40922&r2=40923&view=diff == --- llvm/trunk/lib/VMCore/Dominators.cpp (original) +++ llvm/trunk/lib/VMCore/Dominators.cpp Wed Aug 8 01:24:20 2007 @@ -386,38 +386,33 @@ void DominatorTreeBase::updateDFSNumbers() { unsigned DFSNum = 0; - SmallVector WorkStack; - SmallPtrSet Visited; - + SmallVector, 32> WorkStack; + for (unsigned i = 0, e = Roots.size(); i != e; ++i) { DomTreeNode *ThisRoot = getNode(Roots[i]); -WorkStack.push_back(ThisRoot); -Visited.insert(ThisRoot); +WorkStack.push_back(std::make_pair(ThisRoot, ThisRoot->begin())); ThisRoot->DFSNumIn = DFSNum++; while (!WorkStack.empty()) { - DomTreeNode *Node = WorkStack.back(); - - bool MustVisitAChild = false; - for (DomTreeNode::iterator DI = Node->begin(), E = Node->end(); - DI != E; ++DI) { -DomTreeNode *Child = *DI; -if (!Visited.insert(Child)) - continue; - -MustVisitAChild = true; -Child->DFSNumIn = DFSNum++; -WorkStack.push_back(Child); -break; - } - - if (!MustVisitAChild) { -// If we reach here means all children are visited + DomTreeNode *Node = WorkStack.back().first; + DomTreeNode::iterator ChildIt = WorkStack.back().second; + + // If we visited all of the children of this node, "recurse" back up the + // stack setting the DFOutNum. + if (ChildIt == Node->end()) { Node->DFSNumOut = DFSNum++; WorkStack.pop_back(); + } else { +// Otherwise, recursively visit this child. +DomTreeNode *Child = *ChildIt; +++WorkStack.back().second; + +WorkStack.push_back(std::make_pair(Child, Child->begin())); +Child->DFSNumIn = DFSNum++; } } } + SlowQueries = 0; DFSInfoValid = true; } ___ llvm-commits mailing list llvm-commits@cs.uiuc.edu http://lists.cs.uiuc.edu/mailman/listinfo/llvm-commits
[llvm-commits] [llvm] r40924 - /llvm/trunk/lib/Analysis/ConstantFolding.cpp
Author: lattner Date: Wed Aug 8 01:55:43 2007 New Revision: 40924 URL: http://llvm.org/viewvc/llvm-project?rev=40924&view=rev Log: significantly speed up constant folding of calls (and thus all clients that use ConstantFoldInstruction on calls) by avoiding Value::getName(). getName() constructs and returns an std::string, which does heap allocation stuff. This slightly speeds up instcombine. Modified: llvm/trunk/lib/Analysis/ConstantFolding.cpp Modified: llvm/trunk/lib/Analysis/ConstantFolding.cpp URL: http://llvm.org/viewvc/llvm-project/llvm/trunk/lib/Analysis/ConstantFolding.cpp?rev=40924&r1=40923&r2=40924&view=diff == --- llvm/trunk/lib/Analysis/ConstantFolding.cpp (original) +++ llvm/trunk/lib/Analysis/ConstantFolding.cpp Wed Aug 8 01:55:43 2007 @@ -19,6 +19,7 @@ #include "llvm/Instructions.h" #include "llvm/Intrinsics.h" #include "llvm/ADT/SmallVector.h" +#include "llvm/ADT/StringMap.h" #include "llvm/Target/TargetData.h" #include "llvm/Support/GetElementPtrTypeIterator.h" #include "llvm/Support/MathExtras.h" @@ -312,8 +313,6 @@ /// the specified function. bool llvm::canConstantFoldCallTo(Function *F) { - const std::string &Name = F->getName(); - switch (F->getIntrinsicID()) { case Intrinsic::sqrt_f32: case Intrinsic::sqrt_f64: @@ -327,29 +326,65 @@ default: break; } - switch (Name[0]) - { -case 'a': - return Name == "acos" || Name == "asin" || Name == "atan" || - Name == "atan2"; -case 'c': - return Name == "ceil" || Name == "cos" || Name == "cosf" || - Name == "cosh"; -case 'e': - return Name == "exp"; -case 'f': - return Name == "fabs" || Name == "fmod" || Name == "floor"; -case 'l': - return Name == "log" || Name == "log10"; -case 'p': - return Name == "pow"; -case 's': - return Name == "sin" || Name == "sinh" || - Name == "sqrt" || Name == "sqrtf"; -case 't': - return Name == "tan" || Name == "tanh"; -default: - return false; + const ValueName *NameVal = F->getValueName(); + const char *Str = NameVal->getKeyData(); + unsigned Len = NameVal->getKeyLength(); + if (Len == 0) return false; + + // In these cases, the check of the length is required. We don't want to + // return true for a name like "cos\0blah" which strcmp would return equal to + // "cos", but has length 8. + switch (Str[0]) { + default: return false; + case 'a': +if (Len == 4) + return !strcmp(Str, "acos") || !strcmp(Str, "asin") || + !strcmp(Str, "atan"); +else if (Len == 5) + return !strcmp(Str, "atan2"); +return false; + case 'c': +if (Len == 3) + return !strcmp(Str, "cos"); +else if (Len == 4) + return !strcmp(Str, "ceil") || !strcmp(Str, "cosf") || + !strcmp(Str, "cosh"); +return false; + case 'e': +if (Len == 3) + return !strcmp(Str, "exp"); +return false; + case 'f': +if (Len == 4) + return !strcmp(Str, "fabs") || !strcmp(Str, "fmod"); +else if (Len == 5) + return !strcmp(Str, "floor"); +return false; +break; + case 'l': +if (Len == 3 && !strcmp(Str, "log")) + return true; +if (Len == 5 && !strcmp(Str, "log10")) + return true; +return false; + case 'p': +if (Len == 3 && !strcmp(Str, "pow")) + return true; +return false; + case 's': +if (Len == 3) + return !strcmp(Str, "sin"); +if (Len == 4) + return !strcmp(Str, "sinh") || !strcmp(Str, "sqrt"); +if (Len == 5) + return !strcmp(Str, "sqrtf"); +return false; + case 't': +if (Len == 3 && !strcmp(Str, "tan")) + return true; +else if (Len == 4 && !strcmp(Str, "tanh")) + return true; +return false; } } @@ -378,81 +413,83 @@ /// with the specified arguments, returning null if unsuccessful. Constant * llvm::ConstantFoldCall(Function *F, Constant** Operands, unsigned NumOperands) { - const std::string &Name = F->getName(); + const ValueName *NameVal = F->getValueName(); + const char *Str = NameVal->getKeyData(); + unsigned Len = NameVal->getKeyLength(); + const Type *Ty = F->getReturnType(); - if (NumOperands == 1) { if (ConstantFP *Op = dyn_cast(Operands[0])) { double V = Op->getValue(); - switch (Name[0]) - { -case 'a': - if (Name == "acos") -return ConstantFoldFP(acos, V, Ty); - else if (Name == "asin") -return ConstantFoldFP(asin, V, Ty); - else if (Name == "atan") -return ConstantFoldFP(atan, V, Ty); - break; -case 'c': - if (Name == "ceil") -return ConstantFoldFP(ceil, V, Ty); - else if (Name == "cos") -return ConstantFoldFP(cos, V, Ty); - else if (Name == "cosh") -return ConstantFoldFP(cosh, V, Ty); - break; -case 'e': -