[polly] r275174 - [SCEVAffinator] Fix assertion checking for constant divisor.

Michael Kruse via llvm-commits llvm-commits at lists.llvm.org
Tue Jul 12 08:08:47 PDT 2016


Author: meinersbur
Date: Tue Jul 12 10:08:47 2016
New Revision: 275174

URL: http://llvm.org/viewvc/llvm-project?rev=275174&view=rev
Log:
[SCEVAffinator] Fix assertion checking for constant divisor.

An assertion in visitSDivInstruction() checked whether the divisor is constant
by checking whether the argument is a ConstantInt. However, SCEVValidator allows
the divisor to be simplified to a constant by ScalarEvolution.

We synchronize the implementation of SCEVValidator and SCEVAffinator to both
accept simplified SCEV expressions.

Added:
    polly/trunk/test/ScopInfo/scev-div-with-evaluatable-divisor.ll
Modified:
    polly/trunk/lib/Support/SCEVAffinator.cpp

Modified: polly/trunk/lib/Support/SCEVAffinator.cpp
URL: http://llvm.org/viewvc/llvm-project/polly/trunk/lib/Support/SCEVAffinator.cpp?rev=275174&r1=275173&r2=275174&view=diff
==============================================================================
--- polly/trunk/lib/Support/SCEVAffinator.cpp (original)
+++ polly/trunk/lib/Support/SCEVAffinator.cpp Tue Jul 12 10:08:47 2016
@@ -535,7 +535,7 @@ __isl_give PWACtx SCEVAffinator::visitSD
   auto *Divisor = SDiv->getOperand(1);
   auto *DivisorSCEV = SE.getSCEVAtScope(Divisor, Scope);
   auto DivisorPWAC = visit(DivisorSCEV);
-  assert(isa<ConstantInt>(Divisor) &&
+  assert(isa<SCEVConstant>(DivisorSCEV) &&
          "SDiv is no parameter but has a non-constant RHS.");
 
   auto *Dividend = SDiv->getOperand(0);

Added: polly/trunk/test/ScopInfo/scev-div-with-evaluatable-divisor.ll
URL: http://llvm.org/viewvc/llvm-project/polly/trunk/test/ScopInfo/scev-div-with-evaluatable-divisor.ll?rev=275174&view=auto
==============================================================================
--- polly/trunk/test/ScopInfo/scev-div-with-evaluatable-divisor.ll (added)
+++ polly/trunk/test/ScopInfo/scev-div-with-evaluatable-divisor.ll Tue Jul 12 10:08:47 2016
@@ -0,0 +1,55 @@
+; RUN: opt %loadPolly -polly-scops -analyze < %s
+
+; Derived from test-suite/SingleSource/UnitTests/Vector/SSE/sse.stepfft.c
+
+; The values %mul.i44 is simplified to constant 4 by ScalarEvolution, but 
+; SCEVAffinator used to check whether the sdiv's argument was constant.
+
+target datalayout = "e-m:e-i64:64-f80:128-n8:16:32:64-S128"
+target triple = "x86_64-unknown-linux-gnu"
+
+; Function Attrs: nounwind uwtable
+define void @cfft2(i32 %n) local_unnamed_addr #0 {
+entry:
+  br i1 undef, label %for.body.lr.ph, label %for.end
+
+for.body.lr.ph:                                   ; preds = %entry
+  br label %for.body
+
+for.body:                                         ; preds = %for.inc, %for.body.lr.ph
+  %mj.017 = phi i32 [ 1, %for.body.lr.ph ], [ undef, %for.inc ]
+  br i1 undef, label %if.else, label %if.then
+
+if.then:                                          ; preds = %for.body
+  br label %for.inc
+
+if.else:                                          ; preds = %for.body
+  %mul.i44 = shl i32 %mj.017, 2
+  %div.i45 = sdiv i32 %n, %mul.i44
+  br i1 undef, label %for.body.i58.lr.ph, label %for.inc
+
+for.body.i58.lr.ph:                               ; preds = %if.else
+  br i1 undef, label %for.body.i58.us, label %for.body.i58.preheader
+
+for.body.i58.preheader:                           ; preds = %for.body.i58.lr.ph
+  br label %for.body.i58
+
+for.body.i58.us:                                  ; preds = %for.body.i58.us, %for.body.i58.lr.ph
+  br i1 undef, label %for.inc, label %for.body.i58.us
+
+for.body.i58:                                     ; preds = %for.body.i58, %for.body.i58.preheader
+  %exitcond42 = icmp eq i32 0, %div.i45
+  br i1 %exitcond42, label %for.inc, label %for.body.i58
+
+for.inc:                                          ; preds = %for.body.i58, %for.body.i58.us, %if.else, %if.then
+  br i1 undef, label %for.end, label %for.body
+
+for.end:                                          ; preds = %for.inc, %entry
+  ret void
+}
+
+attributes #0 = { nounwind uwtable "disable-tail-calls"="false" "less-precise-fpmad"="false" "no-frame-pointer-elim"="false" "no-infs-fp-math"="false" "no-jump-tables"="false" "no-nans-fp-math"="false" "stack-protector-buffer-size"="8" "target-cpu"="x86-64" "target-features"="+fxsr,+mmx,+sse,+sse2,+x87" "unsafe-fp-math"="false" "use-soft-float"="false" }
+
+!llvm.ident = !{!0}
+
+!0 = !{!"clang version 3.9.0 (trunk 273249) (llvm/trunk 273255)"}




More information about the llvm-commits mailing list