[llvm-commits] [llvm] r73884 - /llvm/trunk/lib/Analysis/ScalarEvolution.cpp

Nicolas Geoffray nicolas.geoffray at lip6.fr
Mon Jun 22 14:38:17 PDT 2009


Hi Dan,

I believe this patch is responsible for the bug highlighted by the 
attached (bugpoint reduced) test-case. Older revisions compile the test 
case correclty.

FYI, here's what I get when llc'ing the file (arch=x86 OS=linux):


llc: /home/ngeoffray/project/llvm-svn/llvm/include/llvm/ADT/APInt.h:216: 
llvm::APInt::APInt(unsigned int, uint64_t, bool): Assertion `BitWidth && 
"bitwidth too small"' failed.
0   llc 0x08beb5c8
Stack dump:
0.    Program arguments: ../llvm/Release/bin/llc -march=x86 
bugpoint-reduced-simplified.bc
1.    Running pass 'Loop Pass Manager' on function 
'@JnJVM_antlr_CSharpCodeGenerator_genBitSet__Lantlr_collections_impl_BitSet_2I'
2.    Running pass 'Loop Strength Reduction' on basic block '%"GOTO or 
IF*6"'

Would you like me to open a PR?

Nicolas


Dan Gohman wrote:
> Author: djg
> Date: Mon Jun 22 10:09:28 2009
> New Revision: 73884
>
> URL: http://llvm.org/viewvc/llvm-project?rev=73884&view=rev
> Log:
> Make use of getUMinFromMismatchedTypes when computing backedge-taken
> counts for loops with multiple exits, replacing more conservative code
> which only handled constants. This is derived from a patch by
> Nick Lewycky.
>
> This also fixes llc aborts in ClamAV and others, as
> getUMinFromMismatchedTypes takes care of balancing the types before
> working with them.
>
> Modified:
>     llvm/trunk/lib/Analysis/ScalarEvolution.cpp
>
> Modified: llvm/trunk/lib/Analysis/ScalarEvolution.cpp
> URL: http://llvm.org/viewvc/llvm-project/llvm/trunk/lib/Analysis/ScalarEvolution.cpp?rev=73884&r1=73883&r2=73884&view=diff
>
> ==============================================================================
> --- llvm/trunk/lib/Analysis/ScalarEvolution.cpp (original)
> +++ llvm/trunk/lib/Analysis/ScalarEvolution.cpp Mon Jun 22 10:09:28 2009
> @@ -2958,18 +2958,18 @@
>        if (L->contains(TBB)) {
>          // Both conditions must be true for the loop to continue executing.
>          // Choose the less conservative count.
> -        // TODO: Take the minimum of the exact counts.
> -        if (BTI0.Exact == BTI1.Exact)
> +        if (BTI0.Exact == CouldNotCompute)
> +          BECount = BTI1.Exact;
> +        else if (BTI1.Exact == CouldNotCompute)
>            BECount = BTI0.Exact;
> -        // TODO: Take the minimum of the maximum counts.
> +        else
> +          BECount = getUMinFromMismatchedTypes(BTI0.Exact, BTI1.Exact);
>          if (BTI0.Max == CouldNotCompute)
>            MaxBECount = BTI1.Max;
>          else if (BTI1.Max == CouldNotCompute)
>            MaxBECount = BTI0.Max;
> -        else if (const SCEVConstant *C0 = dyn_cast<SCEVConstant>(BTI0.Max))
> -          if (const SCEVConstant *C1 = dyn_cast<SCEVConstant>(BTI1.Max))
> -              MaxBECount = getConstant(APIntOps::umin(C0->getValue()->getValue(),
> -                                                      C1->getValue()->getValue()));
> +        else
> +          MaxBECount = getUMinFromMismatchedTypes(BTI0.Max, BTI1.Max);
>        } else {
>          // Both conditions must be true for the loop to exit.
>          assert(L->contains(FBB) && "Loop block has no successor in loop!");
> @@ -2992,18 +2992,18 @@
>        if (L->contains(FBB)) {
>          // Both conditions must be false for the loop to continue executing.
>          // Choose the less conservative count.
> -        // TODO: Take the minimum of the exact counts.
> -        if (BTI0.Exact == BTI1.Exact)
> +        if (BTI0.Exact == CouldNotCompute)
> +          BECount = BTI1.Exact;
> +        else if (BTI1.Exact == CouldNotCompute)
>            BECount = BTI0.Exact;
> -        // TODO: Take the minimum of the maximum counts.
> +        else
> +          BECount = getUMinFromMismatchedTypes(BTI0.Exact, BTI1.Exact);
>          if (BTI0.Max == CouldNotCompute)
>            MaxBECount = BTI1.Max;
>          else if (BTI1.Max == CouldNotCompute)
>            MaxBECount = BTI0.Max;
> -        else if (const SCEVConstant *C0 = dyn_cast<SCEVConstant>(BTI0.Max))
> -          if (const SCEVConstant *C1 = dyn_cast<SCEVConstant>(BTI1.Max))
> -              MaxBECount = getConstant(APIntOps::umin(C0->getValue()->getValue(),
> -                                                      C1->getValue()->getValue()));
> +        else
> +          MaxBECount = getUMinFromMismatchedTypes(BTI0.Max, BTI1.Max);
>        } else {
>          // Both conditions must be false for the loop to exit.
>          assert(L->contains(TBB) && "Loop block has no successor in loop!");
>
>
> _______________________________________________
> llvm-commits mailing list
> llvm-commits at cs.uiuc.edu
> http://lists.cs.uiuc.edu/mailman/listinfo/llvm-commits
>   

-------------- next part --------------
An embedded and charset-unspecified text was scrubbed...
Name: bugpoint-reduced-simplified.ll
URL: <http://lists.llvm.org/pipermail/llvm-commits/attachments/20090622/46b16999/attachment.ksh>


More information about the llvm-commits mailing list