Skip to content
Projects
Groups
Snippets
Help
This project
Loading...
Sign in / Register
Toggle navigation
T
tic
Overview
Overview
Details
Activity
Cycle Analytics
Repository
Repository
Files
Commits
Branches
Tags
Contributors
Graph
Compare
Charts
Issues
0
Issues
0
List
Board
Labels
Milestones
Merge Requests
0
Merge Requests
0
CI / CD
CI / CD
Pipelines
Jobs
Schedules
Charts
Wiki
Wiki
Snippets
Snippets
Members
Members
Collapse sidebar
Close sidebar
Activity
Graph
Charts
Create a new issue
Jobs
Commits
Issue Boards
Open sidebar
wenyuanbo
tic
Commits
7ec58675
Commit
7ec58675
authored
Sep 24, 2017
by
Tianqi Chen
Committed by
GitHub
Sep 24, 2017
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
[ARITH] More robust int set checking (#487)
parent
1b2e5ced
Hide whitespace changes
Inline
Side-by-side
Showing
1 changed file
with
6 additions
and
15 deletions
+6
-15
src/arithmetic/int_set.cc
+6
-15
No files found.
src/arithmetic/int_set.cc
View file @
7ec58675
...
@@ -132,27 +132,18 @@ IntSet IntSet::interval(Expr min, Expr max) {
...
@@ -132,27 +132,18 @@ IntSet IntSet::interval(Expr min, Expr max) {
return
IntervalSet
::
make
(
min
,
max
);
return
IntervalSet
::
make
(
min
,
max
);
}
}
inline
bool
prove_equal
(
Expr
lhs
,
Expr
rhs
)
{
return
is_zero
(
ir
::
Simplify
(
lhs
-
rhs
));
}
// Check if a is created from b.
// Check if a is created from b.
bool
IntSet
::
match_range
(
const
Range
&
b
)
const
{
bool
IntSet
::
match_range
(
const
Range
&
b
)
const
{
const
IntSet
&
a
=
*
this
;
const
IntSet
&
a
=
*
this
;
const
IntervalSet
*
a_int
=
a
.
as
<
IntervalSet
>
();
const
IntervalSet
*
a_int
=
a
.
as
<
IntervalSet
>
();
if
(
!
a_int
)
return
false
;
if
(
!
a_int
)
return
false
;
const
Interval
&
i
=
a_int
->
i
;
const
Interval
&
i
=
a_int
->
i
;
if
(
!
i
.
min
.
same_as
(
b
))
return
false
;
return
prove_equal
(
i
.
min
,
b
->
min
)
&&
if
(
is_one
(
b
->
extent
))
return
i
.
is_single_point
();
prove_equal
(
i
.
max
,
ComputeExpr
<
Sub
>
(
ComputeExpr
<
Add
>
(
b
->
extent
,
b
->
min
),
1
));
if
(
is_positive_const
(
b
->
extent
)
&&
is_const
(
b
->
min
))
{
// deep equality
return
Equal
(
ComputeExpr
<
Sub
>
(
ComputeExpr
<
Add
>
(
b
->
extent
,
b
->
min
),
1
),
a_int
->
i
.
max
);
}
const
Sub
*
sub
=
i
.
max
.
as
<
Sub
>
();
if
(
!
sub
)
return
false
;
if
(
is_one
(
sub
->
b
))
return
false
;
const
Add
*
add
=
sub
->
a
.
as
<
Add
>
();
return
add
&&
add
->
a
.
same_as
(
b
->
min
)
&&
add
->
b
.
same_as
(
b
->
extent
);
}
}
inline
bool
MatchPoint
(
const
IntSet
&
a
,
inline
bool
MatchPoint
(
const
IntSet
&
a
,
...
...
Write
Preview
Markdown
is supported
0%
Try again
or
attach a new file
Attach a file
Cancel
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Cancel
Please
register
or
sign in
to comment