x UNORD x should set NAN on the TRUE side.
The false side of x == x should set NAN.
The true side of x != x should set NAN.
gcc/testsuite/
* gcc.dg/tree-ssa/vrp-float-3a.c: New.
* gcc.dg/tree-ssa/vrp-float-4a.c: New.
* gcc.dg/tree-ssa/vrp-float-5a.c: New.
--- /dev/null
+// { dg-do compile }
+// { dg-options "-O2 -fno-thread-jumps -fdisable-tree-fre1 -fdump-tree-evrp" }
+
+void link_error ();
+void bar ();
+
+float
+foo (float x)
+{
+ if (x != x)
+ {
+ // The true side of x != x implies NAN, so we should be able to
+ // fold this.
+ if (!__builtin_isnan (x))
+ link_error ();
+ }
+}
+
+// { dg-final { scan-tree-dump-not "link_error" "evrp" } }
--- /dev/null
+// { dg-do compile }
+// { dg-options "-O2 -fno-thread-jumps -fdisable-tree-fre1 -fdump-tree-evrp" }
+
+void link_error ();
+void bar ();
+
+float
+foo (float x)
+{
+ if (x == x)
+ {
+ bar ();
+ }
+ else
+ {
+ // The false side of x == x implies NAN, so we should be able to
+ // fold this.
+ if (!__builtin_isnan (x))
+ link_error ();
+ }
+}
+
+// { dg-final { scan-tree-dump-not "link_error" "evrp" } }
--- /dev/null
+// { dg-do compile }
+// { dg-options "-O2 -fno-thread-jumps -fdisable-tree-fre1 -fdump-tree-evrp" }
+
+void link_error ();
+
+float
+foo (float x)
+{
+ if (__builtin_isnan (x))
+ {
+ if (!__builtin_isnan (x))
+ link_error ();
+ }
+}
+
+// { dg-final { scan-tree-dump-not "link_error" "evrp" } }