diff options
author | Roger Sayle <roger@eyesopen.com> | 2003-10-03 21:33:57 +0000 |
---|---|---|
committer | Roger Sayle <sayle@gcc.gnu.org> | 2003-10-03 21:33:57 +0000 |
commit | 875eda9c345e57676c4f21f753274ee51025fa41 (patch) | |
tree | 09c0fbd9595e9411be41c39493368c74ad3a13be /gcc/testsuite/gcc.c-torture | |
parent | 4dbe1556cce68a32108fbad54c6e445240f8bb4b (diff) | |
download | gcc-875eda9c345e57676c4f21f753274ee51025fa41.zip gcc-875eda9c345e57676c4f21f753274ee51025fa41.tar.gz gcc-875eda9c345e57676c4f21f753274ee51025fa41.tar.bz2 |
PR optimization/9325, PR java/6391
PR optimization/9325, PR java/6391
* fold-const.c (fold_convert): For floating point to integer
conversions, return the maximum/minimum representable integer
value if the real constant overflows the destination type.
* tree.c (real_value_from_int_cst): Allow the type to be NULL,
meaning don't truncate the result to a floating point mode.
Simplify the logic by calling real_from_integer directly.
* simplify-rtx.c (simplify_unary_operation): Implement the
same semantics for folding floating point to integer conversions
in RTL.
* gcc.c-torture/execute/20031003-1.c: New test case.
From-SVN: r72079
Diffstat (limited to 'gcc/testsuite/gcc.c-torture')
-rw-r--r-- | gcc/testsuite/gcc.c-torture/execute/20031003-1.c | 42 |
1 files changed, 42 insertions, 0 deletions
diff --git a/gcc/testsuite/gcc.c-torture/execute/20031003-1.c b/gcc/testsuite/gcc.c-torture/execute/20031003-1.c new file mode 100644 index 0000000..b60711f --- /dev/null +++ b/gcc/testsuite/gcc.c-torture/execute/20031003-1.c @@ -0,0 +1,42 @@ +/* PR optimization/9325 */ + +extern void abort (void); + +int f1() +{ + return (int)2147483648.0f; +} + +int f2() +{ + return (int)(float)(2147483647); +} + +int f3() +{ + float a = 2147483648.0f; + return (int)a; +} + +int f4() +{ + int a = 2147483647; + float b = (float)a; + return (int)b; +} + +int main() +{ + if (f1() != 2147483647) + abort (); + if (f2() != 2147483647) + abort (); +#ifdef __OPTIMIZE__ + if (f3() != 2147483647) + abort (); + if (f4() != 2147483647) + abort (); +#endif + return 0; +} + |