diff options
author | Kazu Hirata <kazu@codesourcery.com> | 2005-12-22 04:03:32 +0000 |
---|---|---|
committer | Kazu Hirata <kazu@gcc.gnu.org> | 2005-12-22 04:03:32 +0000 |
commit | c078a43735c62e3f90ac80ba1ae01e6d0b83baba (patch) | |
tree | 66a616b689f118212742fb5cadb2a0578277dd95 /gcc/fold-const.c | |
parent | 8ad4c89538959cda77bcf90164c79b4b74f9f602 (diff) | |
download | gcc-c078a43735c62e3f90ac80ba1ae01e6d0b83baba.zip gcc-c078a43735c62e3f90ac80ba1ae01e6d0b83baba.tar.gz gcc-c078a43735c62e3f90ac80ba1ae01e6d0b83baba.tar.bz2 |
re PR middle-end/23518 (some gcc optimizations do not take overflow into account with -fwrapv)
gcc/
PR tree-optimization/23518
* fold-const.c (make_range): Don't move a constant to the
other side of the comparison if the type is signed and -fwrapv
is given.
gcc/testsuite/
PR tree-optimization/23518
* testsuite/gcc.dg/pr23518.c: New.
From-SVN: r108940
Diffstat (limited to 'gcc/fold-const.c')
-rw-r--r-- | gcc/fold-const.c | 5 |
1 files changed, 5 insertions, 0 deletions
diff --git a/gcc/fold-const.c b/gcc/fold-const.c index 33e27af..b801f2a 100644 --- a/gcc/fold-const.c +++ b/gcc/fold-const.c @@ -3836,6 +3836,11 @@ make_range (tree exp, int *pin_p, tree *plow, tree *phigh) if (TREE_CODE (arg1) != INTEGER_CST) break; + /* If flag_wrapv and ARG0_TYPE is signed, then we cannot + move a constant to the other side. */ + if (flag_wrapv && !TYPE_UNSIGNED (arg0_type)) + break; + /* If EXP is signed, any overflow in the computation is undefined, so we don't worry about it so long as our computations on the bounds don't overflow. For unsigned, overflow is defined |