[llvm-commits] [llvm] r167110 - in /llvm/trunk: lib/Analysis/DependenceAnalysis.cpp test/Transforms/LoopIdiom/crash.ll

Preston Briggs preston.briggs at gmail.com
Wed Oct 31 10:20:02 PDT 2012


Looks good to me.

Thanks,
Preston

From: Benjamin Kramer <benny.kra at googlemail.com>
> To: llvm-commits at cs.uiuc.edu
> Subject: [llvm-commits] [llvm] r167110 - in /llvm/trunk:
>         lib/Analysis/DependenceAnalysis.cpp
> test/Transforms/LoopIdiom/crash.ll
> Message-ID: <20121031092038.AFE792A6C065 at llvm.org>
> Content-Type: text/plain; charset="utf-8"
>
> Author: d0k
> Date: Wed Oct 31 04:20:38 2012
> New Revision: 167110
>
> URL: http://llvm.org/viewvc/llvm-project?rev=167110&view=rev
> Log:
> DependenceAnalysis: Don't crash if there is no constant operand.
>
> This makes the code match the comments. Resolves a crash in loop idiom
> (PR14219).
>
> Added:
>     llvm/trunk/test/Transforms/LoopIdiom/crash.ll
> Modified:
>     llvm/trunk/lib/Analysis/DependenceAnalysis.cpp
>
> Modified: llvm/trunk/lib/Analysis/DependenceAnalysis.cpp
> URL:
> http://llvm.org/viewvc/llvm-project/llvm/trunk/lib/Analysis/DependenceAnalysis.cpp?rev=167110&r1=167109&r2=167110&view=diff
>
> ==============================================================================
> --- llvm/trunk/lib/Analysis/DependenceAnalysis.cpp (original)
> +++ llvm/trunk/lib/Analysis/DependenceAnalysis.cpp Wed Oct 31 04:20:38 2012
> @@ -2278,11 +2278,12 @@
>          assert(!Constant && "Surprised to find multiple constants");
>          Constant = cast<SCEVConstant>(Operand);
>        }
> -      else if (isa<SCEVMulExpr>(Operand)) {
> +      else if (const SCEVMulExpr *Product =
> dyn_cast<SCEVMulExpr>(Operand)) {
>          // Search for constant operand to participate in GCD;
>          // If none found; return false.
> -        const SCEVConstant *ConstOp =
> -          getConstantPart(cast<SCEVMulExpr>(Operand));
> +        const SCEVConstant *ConstOp = getConstantPart(Product);
> +        if (!ConstOp)
> +          return false;
>          APInt ConstOpValue = ConstOp->getValue()->getValue();
>          ExtraGCD = APIntOps::GreatestCommonDivisor(ExtraGCD,
>                                                     ConstOpValue.abs());
>
> Added: llvm/trunk/test/Transforms/LoopIdiom/crash.ll
> URL:
> http://llvm.org/viewvc/llvm-project/llvm/trunk/test/Transforms/LoopIdiom/crash.ll?rev=167110&view=auto
>
> ==============================================================================
> --- llvm/trunk/test/Transforms/LoopIdiom/crash.ll (added)
> +++ llvm/trunk/test/Transforms/LoopIdiom/crash.ll Wed Oct 31 04:20:38 2012
> @@ -0,0 +1,25 @@
> +; RUN: opt -basicaa -loop-idiom -S < %s
> +target datalayout =
> "e-p:64:64:64-i1:8:8-i8:8:8-i16:16:16-i32:32:32-i64:64:64-f32:32:32-f64:64:64-v64:64:64-v128:128:128-a0:0:64-s0:64:64-f80:128:128-n8:16:32:64-S128"
> +target triple = "x86_64-apple-macosx10.8.0"
> +
> +; Don't crash inside DependenceAnalysis
> +; PR14219
> +define void @test1(i64* %iwork, i64 %x)  {
> +bb0:
> +  %mul116 = mul nsw i64 %x, %x
> +  %incdec.ptr6.sum175 = add i64 42, %x
> +  %arrayidx135 = getelementptr inbounds i64* %iwork, i64
> %incdec.ptr6.sum175
> +  br label %bb1
> +bb1:
> +  %storemerge4226 = phi i64 [ 0, %bb0 ], [ %inc139, %bb1 ]
> +  store i64 1, i64* %arrayidx135, align 8
> +  %incdec.ptr6.sum176 = add i64 %mul116, %storemerge4226
> +  %arrayidx137 = getelementptr inbounds i64* %iwork, i64
> %incdec.ptr6.sum176
> +  store i64 1, i64* %arrayidx137, align 8
> +  %inc139 = add nsw i64 %storemerge4226, 1
> +  %cmp131 = icmp sgt i64 %storemerge4226, 42
> +  br i1 %cmp131, label %bb2, label %bb1
> +bb2:
> +  ret void
> +}
>
>
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://lists.llvm.org/pipermail/llvm-commits/attachments/20121031/e4cfe896/attachment.html>


More information about the llvm-commits mailing list