[polly] r268026 - [FIX] Prevent division/modulo by zero in parameters -- test case
Johannes Doerfert via llvm-commits
llvm-commits at lists.llvm.org
Fri Apr 29 03:45:39 PDT 2016
Author: jdoerfert
Date: Fri Apr 29 05:45:39 2016
New Revision: 268026
URL: http://llvm.org/viewvc/llvm-project?rev=268026&view=rev
Log:
[FIX] Prevent division/modulo by zero in parameters -- test case
This commits a test case for r268023.
Added:
polly/trunk/test/Isl/CodeGen/param_div_div_div_2.ll
Added: polly/trunk/test/Isl/CodeGen/param_div_div_div_2.ll
URL: http://llvm.org/viewvc/llvm-project/polly/trunk/test/Isl/CodeGen/param_div_div_div_2.ll?rev=268026&view=auto
==============================================================================
--- polly/trunk/test/Isl/CodeGen/param_div_div_div_2.ll (added)
+++ polly/trunk/test/Isl/CodeGen/param_div_div_div_2.ll Fri Apr 29 05:45:39 2016
@@ -0,0 +1,56 @@
+; RUN: opt %loadPolly -polly-scops -analyze < %s | FileCheck %s
+; RUN: opt %loadPolly -polly-codegen -S < %s | FileCheck %s --check-prefix=IR
+;
+; Check that we guard the divisions because we moved them and thereby increased
+; their domain.
+;
+; CHECK: Invalid Context:
+; CHECK-NEXT: [p_0] -> { : p_0 < 0 }
+; CHECK-NEXT: p0: ((%a /u %b) /u (%c /u %d))
+;
+; void f(unsigned *A, unsigned a, unsigned b, unsigned c, unsigned d) {
+; for (unsigned i; i < 100; i++)
+; A[i] += A[(a / b) / (c / d)];
+; }
+;
+; IR: %[[R0:[0-9]*]] = icmp ne i32 %d, 0
+; IR-NEXT: %[[R1:[0-9]*]] = select i1 %[[R0]], i32 %d, i32 1
+; IR-NEXT: %[[R2:[0-9]*]] = udiv i32 %c, %[[R1]]
+; IR-NEXT: %[[R3:[0-9]*]] = icmp ne i32 %2, 0
+; IR-NEXT: %[[R4:[0-9]*]] = select i1 %[[R3]], i32 %[[R2]], i32 1
+; IR-NEXT: %[[R5:[0-9]*]] = icmp ne i32 %b, 0
+; IR-NEXT: %[[R6:[0-9]*]] = select i1 %[[R5]], i32 %b, i32 1
+; IR-NEXT: %[[R7:[0-9]*]] = udiv i32 %a, %[[R6]]
+; IR-NEXT: %[[R8:[0-9]*]] = udiv i32 %[[R7]], %[[R4]]
+;
+target datalayout = "e-m:e-i64:64-f80:128-n8:16:32:64-S128"
+
+define void @f(i32* %A, i32 %a, i32 %b, i32 %c, i32 %d) {
+entry:
+ br label %for.cond
+
+for.cond: ; preds = %for.inc, %entry
+ %indvars.iv = phi i64 [ %indvars.iv.next, %for.inc ], [ 0, %entry ]
+ %cmp = icmp ult i64 %indvars.iv, 100
+ br i1 %cmp, label %for.body, label %for.end
+
+for.body: ; preds = %for.cond
+ %div = udiv i32 %a, %b
+ %div1 = udiv i32 %c, %d
+ %div2 = udiv i32 %div, %div1
+ %idxprom = zext i32 %div2 to i64
+ %arrayidx = getelementptr inbounds i32, i32* %A, i64 %idxprom
+ %tmp = load i32, i32* %arrayidx, align 4
+ %arrayidx4 = getelementptr inbounds i32, i32* %A, i64 %indvars.iv
+ %tmp1 = load i32, i32* %arrayidx4, align 4
+ %add = add i32 %tmp1, %tmp
+ store i32 %add, i32* %arrayidx4, align 4
+ br label %for.inc
+
+for.inc: ; preds = %for.body
+ %indvars.iv.next = add nuw nsw i64 %indvars.iv, 1
+ br label %for.cond
+
+for.end: ; preds = %for.cond
+ ret void
+}
More information about the llvm-commits
mailing list