public inbox for gcc-cvs@sourceware.org
help / color / mirror / Atom feed
* [gcc r14-1883] tree-optimization/110278 - uns < (typeof uns)(uns != 0) is always false
@ 2023-06-16 11:46 Richard Biener
0 siblings, 0 replies; only message in thread
From: Richard Biener @ 2023-06-16 11:46 UTC (permalink / raw)
To: gcc-cvs
https://gcc.gnu.org/g:69b04fe7445c88edafd6983e28353a158e4314b5
commit r14-1883-g69b04fe7445c88edafd6983e28353a158e4314b5
Author: Richard Biener <rguenther@suse.de>
Date: Fri Jun 16 11:47:45 2023 +0200
tree-optimization/110278 - uns < (typeof uns)(uns != 0) is always false
The following adds two patterns simplifying comparisons,
uns < (typeof uns)(uns != 0) is always false and x != (typeof x)(x == 0)
is always true.
PR tree-optimization/110278
* match.pd (uns < (typeof uns)(uns != 0) -> false): New.
(x != (typeof x)(x == 0) -> true): Likewise.
Diff:
---
gcc/match.pd | 11 +++++++++++
1 file changed, 11 insertions(+)
diff --git a/gcc/match.pd b/gcc/match.pd
index b7baad6bf1b..2dd23826034 100644
--- a/gcc/match.pd
+++ b/gcc/match.pd
@@ -6410,6 +6410,17 @@ DEFINE_INT_AND_FLOAT_ROUND_FN (RINT)
(if (cmp == GT_EXPR)
(lt (view_convert:st @0) { build_zero_cst (st); })))))))))))
+/* unsigned < (typeof unsigned)(unsigned != 0) is always false. */
+(simplify
+ (lt:c @0 (convert (ne @0 integer_zerop)))
+ (if (TYPE_UNSIGNED (TREE_TYPE (@0)))
+ { constant_boolean_node (false, type); }))
+
+/* x != (typeof x)(x == 0) is always true. */
+(simplify
+ (ne:c @0 (convert (eq @0 integer_zerop)))
+ { constant_boolean_node (true, type); })
+
(for cmp (unordered ordered unlt unle ungt unge uneq ltgt)
/* If the second operand is NaN, the result is constant. */
(simplify
^ permalink raw reply [flat|nested] only message in thread
only message in thread, other threads:[~2023-06-16 11:46 UTC | newest]
Thread overview: (only message) (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2023-06-16 11:46 [gcc r14-1883] tree-optimization/110278 - uns < (typeof uns)(uns != 0) is always false Richard Biener
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).