6
6
//
7
7
// ===----------------------------------------------------------------------===//
8
8
9
+ #include < utility>
10
+
9
11
#include " mlir/Dialect/Arith/Transforms/Passes.h"
10
12
11
13
#include " mlir/Analysis/DataFlow/DeadCodeAnalysis.h"
@@ -23,20 +25,21 @@ using namespace mlir::arith;
23
25
using namespace mlir ::dataflow;
24
26
25
27
// / Returns true if 2 integer ranges have intersection.
26
- static bool intersects (ConstantIntRanges lhs, ConstantIntRanges rhs) {
28
+ static bool intersects (const ConstantIntRanges &lhs,
29
+ const ConstantIntRanges &rhs) {
27
30
return !((lhs.smax ().slt (rhs.smin ()) || lhs.smin ().sgt (rhs.smax ())) &&
28
31
(lhs.umax ().ult (rhs.umin ()) || lhs.umin ().ugt (rhs.umax ())));
29
32
}
30
33
31
34
static FailureOr<bool > handleEq (ConstantIntRanges lhs, ConstantIntRanges rhs) {
32
- if (!intersects (lhs, rhs))
35
+ if (!intersects (std::move ( lhs), std::move ( rhs) ))
33
36
return false ;
34
37
35
38
return failure ();
36
39
}
37
40
38
41
static FailureOr<bool > handleNe (ConstantIntRanges lhs, ConstantIntRanges rhs) {
39
- if (!intersects (lhs, rhs))
42
+ if (!intersects (std::move ( lhs), std::move ( rhs) ))
40
43
return true ;
41
44
42
45
return failure ();
@@ -63,11 +66,11 @@ static FailureOr<bool> handleSle(ConstantIntRanges lhs, ConstantIntRanges rhs) {
63
66
}
64
67
65
68
static FailureOr<bool > handleSgt (ConstantIntRanges lhs, ConstantIntRanges rhs) {
66
- return handleSlt (rhs, lhs);
69
+ return handleSlt (std::move ( rhs), std::move ( lhs) );
67
70
}
68
71
69
72
static FailureOr<bool > handleSge (ConstantIntRanges lhs, ConstantIntRanges rhs) {
70
- return handleSle (rhs, lhs);
73
+ return handleSle (std::move ( rhs), std::move ( lhs) );
71
74
}
72
75
73
76
static FailureOr<bool > handleUlt (ConstantIntRanges lhs, ConstantIntRanges rhs) {
@@ -91,11 +94,11 @@ static FailureOr<bool> handleUle(ConstantIntRanges lhs, ConstantIntRanges rhs) {
91
94
}
92
95
93
96
static FailureOr<bool > handleUgt (ConstantIntRanges lhs, ConstantIntRanges rhs) {
94
- return handleUlt (rhs, lhs);
97
+ return handleUlt (std::move ( rhs), std::move ( lhs) );
95
98
}
96
99
97
100
static FailureOr<bool > handleUge (ConstantIntRanges lhs, ConstantIntRanges rhs) {
98
- return handleUle (rhs, lhs);
101
+ return handleUle (std::move ( rhs), std::move ( lhs) );
99
102
}
100
103
101
104
namespace {
0 commit comments