[polly] r268855 - Codegen: Enable the detection of min/max expressions
Tobias Grosser via llvm-commits
llvm-commits at lists.llvm.org
Sat May 7 01:03:44 PDT 2016
Author: grosser
Date: Sat May 7 03:03:44 2016
New Revision: 268855
URL: http://llvm.org/viewvc/llvm-project?rev=268855&view=rev
Log:
Codegen: Enable the detection of min/max expressions
Min/max expressions are easier to read and can in some cases also result in
more concise IR that is generated as the min/max --- when lowered to a
cmp+select pattern -- commonly has a simpler condition then the ternary
condition isl would normally generate.
Modified:
polly/trunk/lib/CodeGen/IslAst.cpp
polly/trunk/test/Isl/Ast/aliasing_parametric_simple_2.ll
polly/trunk/test/Isl/Ast/dependence_distance_parametric.ll
polly/trunk/test/Isl/Ast/dependence_distance_parametric_expr.ll
polly/trunk/test/Isl/CodeGen/aliasing_parametric_simple_2.ll
Modified: polly/trunk/lib/CodeGen/IslAst.cpp
URL: http://llvm.org/viewvc/llvm-project/polly/trunk/lib/CodeGen/IslAst.cpp?rev=268855&r1=268854&r2=268855&view=diff
==============================================================================
--- polly/trunk/lib/CodeGen/IslAst.cpp (original)
+++ polly/trunk/lib/CodeGen/IslAst.cpp Sat May 7 03:03:44 2016
@@ -406,6 +406,7 @@ void IslAst::init(const Dependences &D)
isl_ctx *Ctx = S->getIslCtx();
isl_options_set_ast_build_atomic_upper_bound(Ctx, true);
+ isl_options_set_ast_build_detect_min_max(Ctx, true);
isl_ast_build *Build;
AstBuildUserInfo BuildInfo;
Modified: polly/trunk/test/Isl/Ast/aliasing_parametric_simple_2.ll
URL: http://llvm.org/viewvc/llvm-project/polly/trunk/test/Isl/Ast/aliasing_parametric_simple_2.ll?rev=268855&r1=268854&r2=268855&view=diff
==============================================================================
--- polly/trunk/test/Isl/Ast/aliasing_parametric_simple_2.ll (original)
+++ polly/trunk/test/Isl/Ast/aliasing_parametric_simple_2.ll Sat May 7 03:03:44 2016
@@ -5,7 +5,7 @@
; A[i] = B[c - 10] + B[5];
; }
;
-; CHECK: if (1 && 0 == c <= -{{[0-9]*}} && (&MemRef_B[c <= 15 ? 6 : c - 9] <= &MemRef_A[0] || &MemRef_A[1024] <= &MemRef_B[c >= 15 ? 5 : c - 10]))
+; CHECK: if (1 && 0 == c <= -{{[0-9]*}} && (&MemRef_B[max(6, c - 9)] <= &MemRef_A[0] || &MemRef_A[1024] <= &MemRef_B[min(5, c - 10)]))
; CHECK: for (int c0 = 0; c0 <= 1023; c0 += 1)
; CHECK: Stmt_for_body(c0);
; CHECK: else
Modified: polly/trunk/test/Isl/Ast/dependence_distance_parametric.ll
URL: http://llvm.org/viewvc/llvm-project/polly/trunk/test/Isl/Ast/dependence_distance_parametric.ll?rev=268855&r1=268854&r2=268855&view=diff
==============================================================================
--- polly/trunk/test/Isl/Ast/dependence_distance_parametric.ll (original)
+++ polly/trunk/test/Isl/Ast/dependence_distance_parametric.ll Sat May 7 03:03:44 2016
@@ -3,7 +3,7 @@
; void f(int *A, int N, int c) {
; CHECK: #pragma minimal dependence distance: 1
; for (int j = 0; j < N; j++)
-; CHECK: #pragma minimal dependence distance: c <= -1 ? -c : c
+; CHECK: #pragma minimal dependence distance: max(-c, c)
; for (int i = 0; i < N; i++)
; A[i + c] = A[i] + 1;
; }
Modified: polly/trunk/test/Isl/Ast/dependence_distance_parametric_expr.ll
URL: http://llvm.org/viewvc/llvm-project/polly/trunk/test/Isl/Ast/dependence_distance_parametric_expr.ll?rev=268855&r1=268854&r2=268855&view=diff
==============================================================================
--- polly/trunk/test/Isl/Ast/dependence_distance_parametric_expr.ll (original)
+++ polly/trunk/test/Isl/Ast/dependence_distance_parametric_expr.ll Sat May 7 03:03:44 2016
@@ -3,7 +3,7 @@
; void f(int *A, int N, int c, int v) {
; CHECK: #pragma minimal dependence distance: 1
; for (int j = 0; j < N; j++)
-; CHECK: #pragma minimal dependence distance: c + v <= -1 ? -c - v : c + v
+; CHECK: #pragma minimal dependence distance: max(-c - v, c + v)
; for (int i = 0; i < N; i++)
; A[i + c + v] = A[i] + 1;
; }
Modified: polly/trunk/test/Isl/CodeGen/aliasing_parametric_simple_2.ll
URL: http://llvm.org/viewvc/llvm-project/polly/trunk/test/Isl/CodeGen/aliasing_parametric_simple_2.ll?rev=268855&r1=268854&r2=268855&view=diff
==============================================================================
--- polly/trunk/test/Isl/CodeGen/aliasing_parametric_simple_2.ll (original)
+++ polly/trunk/test/Isl/CodeGen/aliasing_parametric_simple_2.ll Sat May 7 03:03:44 2016
@@ -7,9 +7,8 @@
;
; CHECK: %[[Ctx:[._a-zA-Z0-9]*]] = and i1 true
; CHECK-NEXT: %[[M0:[._a-zA-Z0-9]*]] = sext i32 %c to i64
-; CHECK-NEXT: %[[M1:[._a-zA-Z0-9]*]] = icmp sle i64 %[[M0]], 15
-; CHECK-NEXT: %[[M2:[._a-zA-Z0-9]*]] = sext i32 %c to i64
-; CHECK-NEXT: %[[M3:[._a-zA-Z0-9]*]] = sub nsw i64 %[[M2]], 9
+; CHECK-NEXT: %[[M3:[._a-zA-Z0-9]*]] = sub nsw i64 %[[M0]], 9
+; CHECK-NEXT: %[[M1:[._a-zA-Z0-9]*]] = icmp sgt i64 6, %[[M3]]
; CHECK-NEXT: %[[M4:[._a-zA-Z0-9]*]] = select i1 %[[M1]], i64 6, i64 %[[M3]]
; CHECK-NEXT: %[[BMax:[._a-zA-Z0-9]*]] = getelementptr i32, i32* %B, i64 %[[M4]]
; CHECK-NEXT: %[[AMin:[._a-zA-Z0-9]*]] = getelementptr i32, i32* %A, i64 0
@@ -18,9 +17,8 @@
; CHECK-NEXT: %[[BltA:[._a-zA-Z0-9]*]] = icmp ule i64 %[[BMaxI]], %[[AMinI]]
; CHECK-NEXT: %[[AMax:[._a-zA-Z0-9]*]] = getelementptr i32, i32* %A, i64 1024
; CHECK-NEXT: %[[m0:[._a-zA-Z0-9]*]] = sext i32 %c to i64
-; CHECK-NEXT: %[[m1:[._a-zA-Z0-9]*]] = icmp sge i64 %[[m0]], 15
-; CHECK-NEXT: %[[m2:[._a-zA-Z0-9]*]] = sext i32 %c to i64
-; CHECK-NEXT: %[[m3:[._a-zA-Z0-9]*]] = sub nsw i64 %[[m2]], 10
+; CHECK-NEXT: %[[m3:[._a-zA-Z0-9]*]] = sub nsw i64 %[[m0]], 10
+; CHECK-NEXT: %[[m1:[._a-zA-Z0-9]*]] = icmp slt i64 5, %[[m3]]
; CHECK-NEXT: %[[m4:[._a-zA-Z0-9]*]] = select i1 %[[m1]], i64 5, i64 %[[m3]]
; CHECK-NEXT: %[[BMin:[._a-zA-Z0-9]*]] = getelementptr i32, i32* %B, i64 %[[m4]]
; CHECK-NEXT: %[[AMaxI:[._a-zA-Z0-9]*]] = ptrtoint i32* %[[AMax]] to i64
More information about the llvm-commits
mailing list