[PATCH] D38529: [IRCE] Temporarily disable unsigned latch conditions by default
Max Kazantsev via Phabricator via llvm-commits
llvm-commits at lists.llvm.org
Tue Oct 3 22:09:55 PDT 2017
mkazantsev created this revision.
We have found some corner cases connected to range intersection where IRCE makes
a bad thing when the latch condition is unsigned. The fix for that will go as a follow up.
This patch temporarily disables IRCE for unsigned latch conditions until the issue is fixed.
https://reviews.llvm.org/D38529
Files:
lib/Transforms/Scalar/InductiveRangeCheckElimination.cpp
test/Transforms/IRCE/clamp.ll
test/Transforms/IRCE/eq_ne.ll
test/Transforms/IRCE/stride_more_than_1.ll
test/Transforms/IRCE/unsigned_comparisons_ugt.ll
test/Transforms/IRCE/unsigned_comparisons_ult.ll
Index: test/Transforms/IRCE/unsigned_comparisons_ult.ll
===================================================================
--- test/Transforms/IRCE/unsigned_comparisons_ult.ll
+++ test/Transforms/IRCE/unsigned_comparisons_ult.ll
@@ -1,4 +1,4 @@
-; RUN: opt -verify-loop-info -irce-print-changed-loops -irce -S < %s 2>&1 | FileCheck %s
+; RUN: opt -verify-loop-info -irce-print-changed-loops -irce -irce-allow-unsigned-latch=true -S < %s 2>&1 | FileCheck %s
; CHECK: irce: in function test_01: constrained Loop at depth 1 containing: %loop<header><exiting>,%in.bounds<latch><exiting>
; CHECK: irce: in function test_02: constrained Loop at depth 1 containing: %loop<header><exiting>,%in.bounds<latch><exiting>
Index: test/Transforms/IRCE/unsigned_comparisons_ugt.ll
===================================================================
--- test/Transforms/IRCE/unsigned_comparisons_ugt.ll
+++ test/Transforms/IRCE/unsigned_comparisons_ugt.ll
@@ -1,4 +1,4 @@
-; RUN: opt -verify-loop-info -irce-print-changed-loops -irce -S < %s 2>&1 | FileCheck %s
+; RUN: opt -verify-loop-info -irce-print-changed-loops -irce -irce-allow-unsigned-latch=true -S < %s 2>&1 | FileCheck %s
; CHECK: irce: in function test_01: constrained Loop at depth 1 containing: %loop<header><exiting>,%in.bounds<latch><exiting>
; CHECK: irce: in function test_02: constrained Loop at depth 1 containing: %loop<header><exiting>,%in.bounds<latch><exiting>
Index: test/Transforms/IRCE/stride_more_than_1.ll
===================================================================
--- test/Transforms/IRCE/stride_more_than_1.ll
+++ test/Transforms/IRCE/stride_more_than_1.ll
@@ -1,4 +1,4 @@
-; RUN: opt -verify-loop-info -irce-print-changed-loops -irce -S < %s 2>&1 | FileCheck %s
+; RUN: opt -verify-loop-info -irce-print-changed-loops -irce -irce-allow-unsigned-latch=true -S < %s 2>&1 | FileCheck %s
; CHECK: irce: in function test_01: constrained Loop at depth 1 containing: %loop<header><exiting>,%in.bounds<latch><exiting>
; CHECK: irce: in function test_02: constrained Loop at depth 1 containing: %loop<header><exiting>,%in.bounds<latch><exiting>
Index: test/Transforms/IRCE/eq_ne.ll
===================================================================
--- test/Transforms/IRCE/eq_ne.ll
+++ test/Transforms/IRCE/eq_ne.ll
@@ -1,4 +1,4 @@
-; RUN: opt -verify-loop-info -irce-print-changed-loops -irce -S < %s 2>&1 | FileCheck %s
+; RUN: opt -verify-loop-info -irce-print-changed-loops -irce -irce-allow-unsigned-latch=true -S < %s 2>&1 | FileCheck %s
; CHECK: irce: in function test_01: constrained Loop at depth 1 containing: %loop<header><exiting>,%in.bounds<latch><exiting>
; CHECK: irce: in function test_01u: constrained Loop at depth 1 containing: %loop<header><exiting>,%in.bounds<latch><exiting>
Index: test/Transforms/IRCE/clamp.ll
===================================================================
--- test/Transforms/IRCE/clamp.ll
+++ test/Transforms/IRCE/clamp.ll
@@ -1,4 +1,4 @@
-; RUN: opt -verify-loop-info -irce-print-changed-loops -irce -S < %s 2>&1 | FileCheck %s
+; RUN: opt -verify-loop-info -irce-print-changed-loops -irce -irce-allow-unsigned-latch=true -S < %s 2>&1 | FileCheck %s
; The test demonstrates that incorrect behavior of Clamp may lead to incorrect
; calculation of post-loop exit condition.
Index: lib/Transforms/Scalar/InductiveRangeCheckElimination.cpp
===================================================================
--- lib/Transforms/Scalar/InductiveRangeCheckElimination.cpp
+++ lib/Transforms/Scalar/InductiveRangeCheckElimination.cpp
@@ -79,6 +79,9 @@
static cl::opt<bool> SkipProfitabilityChecks("irce-skip-profitability-checks",
cl::Hidden, cl::init(false));
+static cl::opt<bool> AllowUnsignedLatchCondition("irce-allow-unsigned-latch",
+ cl::Hidden, cl::init(false));
+
static const char *ClonedLoopTag = "irce.loop.clone";
#define DEBUG_TYPE "irce"
@@ -889,6 +892,15 @@
IsSignedPredicate =
Pred == ICmpInst::ICMP_SLT || Pred == ICmpInst::ICMP_SGT;
+
+ // FIXME: We temporarily disable unsigned latch conditions by default
+ // because of found problems with intersecting signed and unsigned ranges.
+ // We are going to turn it on once the problems are fixed.
+ if (!IsSignedPredicate && !AllowUnsignedLatchCondition) {
+ FailureReason = "unsigned latch conditions are explicitly prohibited";
+ return None;
+ }
+
// The predicate that we need to check that the induction variable lies
// within bounds.
ICmpInst::Predicate BoundPred =
@@ -964,6 +976,15 @@
IsSignedPredicate =
Pred == ICmpInst::ICMP_SLT || Pred == ICmpInst::ICMP_SGT;
+
+ // FIXME: We temporarily disable unsigned latch conditions by default
+ // because of found problems with intersecting signed and unsigned ranges.
+ // We are going to turn it on once the problems are fixed.
+ if (!IsSignedPredicate && !AllowUnsignedLatchCondition) {
+ FailureReason = "unsigned latch conditions are explicitly prohibited";
+ return None;
+ }
+
// The predicate that we need to check that the induction variable lies
// within bounds.
ICmpInst::Predicate BoundPred =
-------------- next part --------------
A non-text attachment was scrubbed...
Name: D38529.117623.patch
Type: text/x-patch
Size: 5270 bytes
Desc: not available
URL: <http://lists.llvm.org/pipermail/llvm-commits/attachments/20171004/42075dc3/attachment.bin>
More information about the llvm-commits
mailing list