Skip to content
Projects
Groups
Snippets
Help
This project
Loading...
Sign in / Register
Toggle navigation
R
riscv-gcc-1
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
lvzhengyang
riscv-gcc-1
Commits
3122945e
Commit
3122945e
authored
Mar 25, 1994
by
Richard Kenner
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
(fold, case *_DIV_EXPR): Correct result when product of constants
overflows. From-SVN: r6900
parent
0273f326
Hide whitespace changes
Inline
Side-by-side
Showing
1 changed file
with
29 additions
and
15 deletions
+29
-15
gcc/fold-const.c
+29
-15
No files found.
gcc/fold-const.c
View file @
3122945e
...
...
@@ -4008,30 +4008,44 @@ fold (expr)
tem
=
const_binop
(
MULT_EXPR
,
TREE_OPERAND
(
arg0
,
1
),
arg1
,
0
);
/* If it overflows, the result is +/- 1 or zero, depending on
the signs of the two constants and the division operation. */
the signs of the constants and remaining operand and on which
division operation is being performed. */
if
(
TREE_OVERFLOW
(
tem
))
{
/* 1 if C1 * C2 is negative (i.e., C1 and C2 have
different signs). */
int
c_neg
=
((
tree_int_cst_sgn
(
arg1
)
<
0
)
==
(
tree_int_cst_sgn
(
TREE_OPERAND
(
arg0
,
1
))
<
0
));
switch
(
code
)
{
case
EXACT_DIV_EXPR
:
/* If this overflowed, it couldn't have been exact. */
abort
();
case
TRUNC_DIV_EXPR
:
tem
=
integer_zero_node
;
break
;
return
omit_one_operand
(
type
,
integer_zero_node
,
TREE_OPERAND
(
arg0
,
0
));
case
FLOOR_DIV_EXPR
:
/* -1 if signs disagree, else 0. */
tem
=
(((
tree_int_cst_sgn
(
TREE_OPERAND
(
arg0
,
1
))
<
0
)
!=
(
tree_int_cst_sgn
(
arg1
)
<
0
))
?
build_int_2
(
-
1
,
-
1
)
:
integer_zero_node
);
break
;
/* -1 or zero, depending on signs of remaining
operand and constants. */
tem
=
build
(
c_neg
?
GE_EXPR
:
LE_EXPR
,
integer_type_node
,
TREE_OPERAND
(
arg0
,
0
),
convert
(
type
,
integer_zero_node
));
return
fold
(
build
(
NEGATE_EXPR
,
type
,
convert
(
type
,
fold
(
tem
))));
case
CEIL_DIV_EXPR
:
/* 1 if signs agree, else 0. */
tem
=
(((
tree_int_cst_sgn
(
TREE_OPERAND
(
arg0
,
1
))
<
0
)
==
(
tree_int_cst_sgn
(
arg1
)
<
0
))
?
integer_one_node
:
integer_zero_node
);
break
;
/* Zero or 1, depending on signs of remaining
operand and constants. */
tem
=
build
(
c_neg
?
LE_EXPR
:
GE_EXPR
,
integer_type_node
,
TREE_OPERAND
(
arg0
,
0
),
convert
(
type
,
integer_zero_node
));
return
convert
(
type
,
fold
(
tem
));
}
return
omit_one_operand
(
type
,
tem
,
TREE_OPERAND
(
arg0
,
0
));
}
else
/* If no overflow, divide by C1*C2. */
...
...
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