Skip to content
Projects
Groups
Snippets
Help
Loading...
Help
Support
Keyboard shortcuts
?
Submit feedback
Contribute to GitLab
Sign in / Register
Toggle navigation
C
cython
Project overview
Project overview
Details
Activity
Releases
Repository
Repository
Files
Commits
Branches
Tags
Contributors
Graph
Compare
Issues
0
Issues
0
List
Boards
Labels
Milestones
Merge Requests
0
Merge Requests
0
Analytics
Analytics
Repository
Value Stream
Wiki
Wiki
Snippets
Snippets
Members
Members
Collapse sidebar
Close sidebar
Activity
Graph
Create a new issue
Commits
Issue Boards
Open sidebar
Gwenaël Samain
cython
Commits
83d7bd2c
Commit
83d7bd2c
authored
Dec 14, 2013
by
Stefan Behnel
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
fix constant folding with false partial result
parent
a4cb6877
Changes
1
Hide whitespace changes
Inline
Side-by-side
Showing
1 changed file
with
4 additions
and
4 deletions
+4
-4
Cython/Compiler/Optimize.py
Cython/Compiler/Optimize.py
+4
-4
No files found.
Cython/Compiler/Optimize.py
View file @
83d7bd2c
...
@@ -3353,13 +3353,13 @@ class ConstantFolding(Visitor.VisitorTransform, SkipDeclarations):
...
@@ -3353,13 +3353,13 @@ class ConstantFolding(Visitor.VisitorTransform, SkipDeclarations):
# collect partial cascades: [[value, CmpNode...], [value, CmpNode, ...], ...]
# collect partial cascades: [[value, CmpNode...], [value, CmpNode, ...], ...]
cascades
=
[[
node
.
operand1
]]
cascades
=
[[
node
.
operand1
]]
final_
result
=
[
True
]
final_
false_result
=
[
]
def
split_cascades
(
cmp_node
):
def
split_cascades
(
cmp_node
):
if
cmp_node
.
has_constant_result
():
if
cmp_node
.
has_constant_result
():
if
not
cmp_node
.
constant_result
:
if
not
cmp_node
.
constant_result
:
# False => short-circuit
# False => short-circuit
final_
result
[
0
]
=
False
final_
false_result
.
append
(
self
.
_bool_node
(
cmp_node
,
False
))
return
return
else
:
else
:
# True => discard and start new cascade
# True => discard and start new cascade
...
@@ -3391,9 +3391,9 @@ class ConstantFolding(Visitor.VisitorTransform, SkipDeclarations):
...
@@ -3391,9 +3391,9 @@ class ConstantFolding(Visitor.VisitorTransform, SkipDeclarations):
last_cmp_node
=
cmp_node
last_cmp_node
=
cmp_node
last_cmp_node
.
cascade
=
None
last_cmp_node
.
cascade
=
None
if
not
final_result
[
0
]
:
if
final_false_result
:
# last cascade was constant False
# last cascade was constant False
cmp_nodes
.
append
(
self
.
_bool_node
(
cmp_node
,
False
)
)
cmp_nodes
.
append
(
final_false_result
[
0
]
)
elif
not
cmp_nodes
:
elif
not
cmp_nodes
:
# only constants, but no False result
# only constants, but no False result
return
self
.
_bool_node
(
node
,
True
)
return
self
.
_bool_node
(
node
,
True
)
...
...
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