diff options
author | sayle <sayle@138bc75d-0d04-0410-961f-82ee72b054a4> | 2003-04-14 20:16:58 +0000 |
---|---|---|
committer | sayle <sayle@138bc75d-0d04-0410-961f-82ee72b054a4> | 2003-04-14 20:16:58 +0000 |
commit | edc21ba8088e0e485b3bdccaba28005747e2ba61 (patch) | |
tree | a3d2d13cfa04d1656aee06fd96e6f08bdbc67e20 /gcc/testsuite/gcc.dg/20030414-2.c | |
parent | 6419e9ffc71872b1286b807082d907e644e84122 (diff) | |
download | gcc-edc21ba8088e0e485b3bdccaba28005747e2ba61.tar.gz |
* fold-const.c (fold): Transform (c1 - x) cmp c2, where cmp is a
comparison operation and c1/c2 are floating point constants into
x swap(cmp) (c1 - c2).
* gcc.dg/20030414-2.c: New test case.
git-svn-id: svn+ssh://gcc.gnu.org/svn/gcc/trunk@65584 138bc75d-0d04-0410-961f-82ee72b054a4
Diffstat (limited to 'gcc/testsuite/gcc.dg/20030414-2.c')
-rw-r--r-- | gcc/testsuite/gcc.dg/20030414-2.c | 38 |
1 files changed, 38 insertions, 0 deletions
diff --git a/gcc/testsuite/gcc.dg/20030414-2.c b/gcc/testsuite/gcc.dg/20030414-2.c new file mode 100644 index 00000000000..f4eb8bf36ec --- /dev/null +++ b/gcc/testsuite/gcc.dg/20030414-2.c @@ -0,0 +1,38 @@ +/* Copyright (C) 2003 Free Software Foundation. + + Check that constant folding (c1 - x) op c2 into x swap(op) c1-c2 + doesn't break anything. + + Written by Roger Sayle, 27th March 2003. */ + +/* { dg-do run } */ +/* { dg-options "-O2 -ffast-math" } */ + +extern void abort (void); + +int foo(double x) +{ + return (10.0 - x) > 3.0; +} + +int bar (double x) +{ + return (10.0 - x) == 5.0; +} + +int main() +{ + if (foo (8.0)) + abort (); + + if (! foo (6.0)) + abort (); + + if (bar (1.0)) + abort (); + + if (! bar (5.0)) + abort (); + return 0; +} + |