diff options
author | Jakub Jelinek <jakub@redhat.com> | 2013-09-11 13:35:51 +0200 |
---|---|---|
committer | Jakub Jelinek <jakub@gcc.gnu.org> | 2013-09-11 13:35:51 +0200 |
commit | 427e6a142188fcfdc0efd4eed41ae717ee233e94 (patch) | |
tree | 42d315e8135a2794966c5168c32d699c516aa57e /gcc | |
parent | df45c0cc8ddd4c277311cf2b0267c032a74faa01 (diff) | |
download | gcc-427e6a142188fcfdc0efd4eed41ae717ee233e94.zip gcc-427e6a142188fcfdc0efd4eed41ae717ee233e94.tar.gz gcc-427e6a142188fcfdc0efd4eed41ae717ee233e94.tar.bz2 |
re PR middle-end/58385 (likely wrong code bug)
PR tree-optimization/58385
* fold-const.c (build_range_check): If both low and high are NULL,
use omit_one_operand_loc to preserve exp side-effects.
* gcc.c-torture/execute/pr58385.c: New test.
From-SVN: r202494
Diffstat (limited to 'gcc')
-rw-r--r-- | gcc/ChangeLog | 6 | ||||
-rw-r--r-- | gcc/fold-const.c | 2 | ||||
-rw-r--r-- | gcc/testsuite/ChangeLog | 5 | ||||
-rw-r--r-- | gcc/testsuite/gcc.c-torture/execute/pr58385.c | 21 |
4 files changed, 33 insertions, 1 deletions
diff --git a/gcc/ChangeLog b/gcc/ChangeLog index 8b2e2bb..e5e1702 100644 --- a/gcc/ChangeLog +++ b/gcc/ChangeLog @@ -1,3 +1,9 @@ +2013-09-11 Jakub Jelinek <jakub@redhat.com> + + PR tree-optimization/58385 + * fold-const.c (build_range_check): If both low and high are NULL, + use omit_one_operand_loc to preserve exp side-effects. + 2013-09-11 Kyrylo Tkachov <kyrylo.tkachov@arm.com> * config/arm/arm.md (arm_shiftsi3): New alternative l/l/M. diff --git a/gcc/fold-const.c b/gcc/fold-const.c index 9956b2c..8d57928 100644 --- a/gcc/fold-const.c +++ b/gcc/fold-const.c @@ -4299,7 +4299,7 @@ build_range_check (location_t loc, tree type, tree exp, int in_p, } if (low == 0 && high == 0) - return build_int_cst (type, 1); + return omit_one_operand_loc (loc, type, build_int_cst (type, 1), exp); if (low == 0) return fold_build2_loc (loc, LE_EXPR, type, exp, diff --git a/gcc/testsuite/ChangeLog b/gcc/testsuite/ChangeLog index 718e542..c924967 100644 --- a/gcc/testsuite/ChangeLog +++ b/gcc/testsuite/ChangeLog @@ -1,3 +1,8 @@ +2013-09-11 Jakub Jelinek <jakub@redhat.com> + + PR tree-optimization/58385 + * gcc.c-torture/execute/pr58385.c: New test. + 2013-09-11 Kyrylo Tkachov <kyrylo.tkachov@arm.com> * gcc.target/arm/thumb-ifcvt-2.c: New test. diff --git a/gcc/testsuite/gcc.c-torture/execute/pr58385.c b/gcc/testsuite/gcc.c-torture/execute/pr58385.c new file mode 100644 index 0000000..8d7da6f --- /dev/null +++ b/gcc/testsuite/gcc.c-torture/execute/pr58385.c @@ -0,0 +1,21 @@ +/* PR tree-optimization/58385 */ + +extern void abort (void); + +int a, b = 1; + +int +foo () +{ + b = 0; + return 0; +} + +int +main () +{ + ((0 || a) & foo () >= 0) <= 1 && 1; + if (b) + abort (); + return 0; +} |