diff options
author | Jason Eckhardt <jle@redhat.com> | 2001-02-27 00:48:11 +0000 |
---|---|---|
committer | Jason Eckhardt <jle@gcc.gnu.org> | 2001-02-27 00:48:11 +0000 |
commit | ac4cdf4033c6587c0cc361522d42b9732881b488 (patch) | |
tree | 5701f29dd30ba3424d394826ae84a75ec39ebb0d /gcc | |
parent | 6a163d7cae1634d98c4c458725eb161adc7f946d (diff) | |
download | gcc-ac4cdf4033c6587c0cc361522d42b9732881b488.zip gcc-ac4cdf4033c6587c0cc361522d42b9732881b488.tar.gz gcc-ac4cdf4033c6587c0cc361522d42b9732881b488.tar.bz2 |
combine.c (known_cond): Do not reverse the condition when SMAX/UMAX is being considered and the...
* combine.c (known_cond): Do not reverse the condition when
SMAX/UMAX is being considered and the condition is for equality
or inequality.
* testsuite/gcc.c-torture/execute/20010221-1.c: New test.
From-SVN: r40077
Diffstat (limited to 'gcc')
-rw-r--r-- | gcc/ChangeLog | 8 | ||||
-rw-r--r-- | gcc/combine.c | 7 | ||||
-rw-r--r-- | gcc/testsuite/gcc.c-torture/execute/20010221-1.c | 17 |
3 files changed, 31 insertions, 1 deletions
diff --git a/gcc/ChangeLog b/gcc/ChangeLog index b21ad17..f7a50fd 100644 --- a/gcc/ChangeLog +++ b/gcc/ChangeLog @@ -1,3 +1,11 @@ +2001-02-26 Jason Eckhardt <jle@redhat.com> + + * combine.c (known_cond): Do not reverse the condition when + SMAX/UMAX is being considered and the condition is for equality + or inequality. + + * testsuite/gcc.c-torture/execute/20010221-1.c: New test. + 2001-02-26 Philip Blundell <philb@gnu.org> * config.gcc: Remove obsolete targets "arm*-*-linuxoldld" and diff --git a/gcc/combine.c b/gcc/combine.c index b5735be..5dc26a8 100644 --- a/gcc/combine.c +++ b/gcc/combine.c @@ -7512,7 +7512,12 @@ known_cond (x, cond, reg, val) { int unsignedp = (code == UMIN || code == UMAX); - if (code == SMAX || code == UMAX) + /* Do not reverse the condition when it is NE or EQ. + This is because we cannot conclude anything about + the value of 'SMAX (x, y)' when x is not equal to y, + but we can when x equals y. */ + if ((code == SMAX || code == UMAX) + && ! (cond == EQ || cond == NE)) cond = reverse_condition (cond); switch (cond) diff --git a/gcc/testsuite/gcc.c-torture/execute/20010221-1.c b/gcc/testsuite/gcc.c-torture/execute/20010221-1.c new file mode 100644 index 0000000..3caff81 --- /dev/null +++ b/gcc/testsuite/gcc.c-torture/execute/20010221-1.c @@ -0,0 +1,17 @@ + +int n = 2; + +main () +{ + int i, x = 45; + + for (i = 0; i < n; i++) + { + if (i != 0) + x = ( i > 0 ) ? i : 0; + } + + if (x != 1) + abort (); + exit (0); +} |