* [PATCH] Add testcase for c/68513
@ 2015-12-02 19:53 Marek Polacek
2015-12-02 19:55 ` Jakub Jelinek
0 siblings, 1 reply; 2+ messages in thread
From: Marek Polacek @ 2015-12-02 19:53 UTC (permalink / raw)
To: GCC Patches
So Richi fixed this PR via changes for genmatch.c:
<https://gcc.gnu.org/ml/gcc-patches/2015-12/msg00248.html>.
I'd like to add this testcase which shows the original problem, and on top of
that, I've added a bunch of other functions that try to exercises other
patterns with save_exprs, both from match.pd and fold-const.c.
Tested on x86_64-linux, ok for trunk?
2015-12-02 Marek Polacek <polacek@redhat.com>
PR c/68513
* gcc.dg/pr68513.c: New test.
diff --git gcc/testsuite/gcc.dg/pr68513.c gcc/testsuite/gcc.dg/pr68513.c
index e69de29..71298d8 100644
--- gcc/testsuite/gcc.dg/pr68513.c
+++ gcc/testsuite/gcc.dg/pr68513.c
@@ -0,0 +1,125 @@
+/* PR c/68513 */
+/* { dg-do compile } */
+/* { dg-options "-funsafe-math-optimizations -fno-math-errno -O -Wno-div-by-zero" } */
+
+int i;
+unsigned u;
+volatile int *e;
+
+#define E (i ? *e : 0)
+
+/* Can't trigger some of them because operand_equal_p will return false
+ for side-effects. */
+
+/* (x & ~m) | (y & m) -> ((x ^ y) & m) ^ x */
+int
+fn1 (void)
+{
+ int r = 0;
+ r += (short) (E & ~u | i & u);
+ r += -(short) (E & ~u | i & u);
+ r += (short) -(E & ~u | i & u);
+ return r;
+}
+
+/* sqrt(x) < y is x >= 0 && x != +Inf, when y is large. */
+double
+fn2 (void)
+{
+ double r;
+ r = __builtin_sqrt (E) < __builtin_inf ();
+ return r;
+}
+
+/* sqrt(x) < c is the same as x >= 0 && x < c*c. */
+double
+fn3 (void)
+{
+ double r;
+ r = __builtin_sqrt (E) < 1.3;
+ return r;
+}
+
+/* copysign(x,y)*copysign(x,y) -> x*x. */
+double
+fn4 (double y, double x)
+{
+ return __builtin_copysign (E, y) * __builtin_copysign (E, y);
+}
+
+/* x <= +Inf is the same as x == x, i.e. !isnan(x). */
+int
+fn5 (void)
+{
+ return E <= __builtin_inf ();
+}
+
+/* Fold (A & ~B) - (A & B) into (A ^ B) - B. */
+int
+fn6 (void)
+{
+ return (i & ~E) - (i & E);
+}
+
+/* Fold (A & B) - (A & ~B) into B - (A ^ B). */
+int
+fn7 (void)
+{
+ return (i & E) - (i & ~E);
+}
+
+/* x + (x & 1) -> (x + 1) & ~1 */
+int
+fn8 (void)
+{
+ return E + (E & 1);
+}
+
+/* Simplify comparison of something with itself. */
+int
+fn9 (void)
+{
+ return E <= E | E >= E;
+}
+
+/* Fold (A & ~B) - (A & B) into (A ^ B) - B. */
+int
+fn10 (void)
+{
+ return (i & ~E) - (i & E);
+}
+
+/* abs(x)*abs(x) -> x*x. Should be valid for all types. */
+int
+fn11 (void)
+{
+ return __builtin_abs (E) * __builtin_abs (E);
+}
+
+/* (x | CST1) & CST2 -> (x & CST2) | (CST1 & CST2) */
+int
+fn12 (void)
+{
+ return (E | 11) & 12;
+}
+
+/* fold_range_test */
+int
+fn13 (const char *s)
+{
+ return s[E] != '\0' && s[E] != '/';
+}
+
+/* fold_comparison */
+int
+fn14 (void)
+{
+ return (!!i ? : (u *= E / 0)) >= (u = E);
+}
+
+/* fold_mult_zconjz */
+_Complex int
+fn15 (_Complex volatile int *z)
+{
+ return *z * ~*z;
+}
Marek
^ permalink raw reply [flat|nested] 2+ messages in thread
* Re: [PATCH] Add testcase for c/68513
2015-12-02 19:53 [PATCH] Add testcase for c/68513 Marek Polacek
@ 2015-12-02 19:55 ` Jakub Jelinek
0 siblings, 0 replies; 2+ messages in thread
From: Jakub Jelinek @ 2015-12-02 19:55 UTC (permalink / raw)
To: Marek Polacek; +Cc: GCC Patches
On Wed, Dec 02, 2015 at 08:53:11PM +0100, Marek Polacek wrote:
> So Richi fixed this PR via changes for genmatch.c:
> <https://gcc.gnu.org/ml/gcc-patches/2015-12/msg00248.html>.
>
> I'd like to add this testcase which shows the original problem, and on top of
> that, I've added a bunch of other functions that try to exercises other
> patterns with save_exprs, both from match.pd and fold-const.c.
>
> Tested on x86_64-linux, ok for trunk?
>
> 2015-12-02 Marek Polacek <polacek@redhat.com>
>
> PR c/68513
> * gcc.dg/pr68513.c: New test.
Ok, thanks.
Jakub
^ permalink raw reply [flat|nested] 2+ messages in thread
end of thread, other threads:[~2015-12-02 19:55 UTC | newest]
Thread overview: 2+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2015-12-02 19:53 [PATCH] Add testcase for c/68513 Marek Polacek
2015-12-02 19:55 ` Jakub Jelinek
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for read-only IMAP folder(s) and NNTP newsgroup(s).