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
c35a27f3
Commit
c35a27f3
authored
Dec 07, 2013
by
Stefan Behnel
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
avoid useless signedness checks in overflow handling when we know the type is signed
parent
17191aad
Changes
1
Hide whitespace changes
Inline
Side-by-side
Showing
1 changed file
with
9 additions
and
5 deletions
+9
-5
Cython/Compiler/ExprNodes.py
Cython/Compiler/ExprNodes.py
+9
-5
No files found.
Cython/Compiler/ExprNodes.py
View file @
c35a27f3
...
...
@@ -9239,13 +9239,17 @@ class DivNode(NumBinopNode):
code
.
putln
(
"}"
)
if
self
.
type
.
is_int
and
self
.
type
.
signed
and
self
.
operator
!=
'%'
:
code
.
globalstate
.
use_utility_code
(
division_overflow_test_code
)
type_of_op2
=
self
.
operand2
.
type
.
declaration_code
(
''
)
code
.
putln
(
"else if (sizeof(%s) == sizeof(long)"
" && (!(((%s)-1) > 0)) && unlikely(%s == (%s)-1)"
if
self
.
operand2
.
type
.
signed
==
2
:
# explicitly signed, no runtime check needed
minus1_check
=
'unlikely(%s == -1)'
%
self
.
operand2
.
result
()
else
:
type_of_op2
=
self
.
operand2
.
type
.
declaration_code
(
''
)
minus1_check
=
'(!(((%s)-1) > 0)) && unlikely(%s == (%s)-1)'
%
(
type_of_op2
,
self
.
operand2
.
result
(),
type_of_op2
)
code
.
putln
(
"else if (sizeof(%s) == sizeof(long) && %s "
" && unlikely(UNARY_NEG_WOULD_OVERFLOW(%s))) {"
%
(
self
.
type
.
declaration_code
(
''
),
type_of_op2
,
self
.
operand2
.
result
(),
type_of_op2
,
minus1_check
,
self
.
operand1
.
result
()))
code
.
put_ensure_gil
()
code
.
putln
(
'PyErr_SetString(PyExc_OverflowError, "value too large to perform division");'
)
...
...
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