[Bug tree-optimization/94802] Failure to recognize identities with __builtin_clz
jakub at gcc dot gnu.org
gcc-bugzilla@gcc.gnu.org
Thu Dec 31 10:15:44 GMT 2020
https://gcc.gnu.org/bugzilla/show_bug.cgi?id=94802
--- Comment #4 from Jakub Jelinek <jakub at gcc dot gnu.org> ---
Not fixed completely yet, (a - b) < 0 is not optimized into a < b yet.
The following patch does that, but it regresses
--- gcc/match.pd.jj 2020-12-30 17:04:27.340815135 +0100
+++ gcc/match.pd 2020-12-30 17:41:44.393443188 +0100
@@ -3966,6 +3966,16 @@ (define_operator_list COND_TERNARY
(cmp (sub@2 @0 @1) integer_zerop)
(if (single_use (@2))
(cmp @0 @1)))))
+#if GIMPLE
+(for cmp (lt le gt ge)
+ (for sub (minus pointer_diff)
+ (simplify
+ (cmp (sub@2 @0 @1) integer_zerop)
+ (if (TYPE_OVERFLOW_UNDEFINED (TREE_TYPE (@0))
+ && !TYPE_OVERFLOW_SANITIZED (TREE_TYPE (@0))
+ && single_use (@2))
+ (cmp @0 @1)))))
+#endif
/* Transform comparisons of the form X * C1 CMP 0 to X CMP 0 in the
signed arithmetic case. That form is created by the compiler
the following test:
+FAIL: gcc.dg/tree-ssa/pr45397.c scan-tree-dump-not evrp " & 255;"
+FAIL: gcc.dg/tree-ssa/pr45397.c scan-tree-dump-not phiopt2 "if "
+FAIL: gcc.dg/tree-ssa/pr45397.c scan-tree-dump-times phiopt2 "MAX_EXPR" 3
+FAIL: gcc.dg/tree-ssa/pr45397.c scan-tree-dump-times phiopt2 "MIN_EXPR" 3
so some more work will be needed.
More information about the Gcc-bugs
mailing list