[Bug tree-optimization/105903] Missed optimization for __synth3way
pinskia at gcc dot gnu.org
gcc-bugzilla@gcc.gnu.org
Wed Jun 29 01:51:31 GMT 2022
https://gcc.gnu.org/bugzilla/show_bug.cgi?id=105903
Andrew Pinski <pinskia at gcc dot gnu.org> changed:
What |Removed |Added
----------------------------------------------------------------------------
Assignee|unassigned at gcc dot gnu.org |pinskia at gcc dot gnu.org
Status|NEW |ASSIGNED
Depends on| |96923
--- Comment #3 from Andrew Pinski <pinskia at gcc dot gnu.org> ---
(In reply to luoxhu from comment #2)
> diff --git a/gcc/match.pd b/gcc/match.pd
> index 4a570894b2e..f6b5415a351 100644
> --- a/gcc/match.pd
> +++ b/gcc/match.pd
> @@ -5718,6 +5718,22 @@ DEFINE_INT_AND_FLOAT_ROUND_FN (RINT)
> (bit_xor (convert (rshift @0 {shifter;})) @1)
> (bit_not (bit_xor (convert (rshift @0 {shifter;})) @1)))))))
>
> +/* X >= Y ? X > Y : 0 into X > Y. */
> +(simplify
> + (cond (ge @0 @1) (gt @0 @1) integer_zerop)
> + (if (INTEGRAL_TYPE_P (type)
> + && POINTER_TYPE_P (TREE_TYPE (@0))
> + && POINTER_TYPE_P (TREE_TYPE (@1)))
> + (gt @0 @1)))
> +
> +/* X < Y ? 0 : X > Y into X > Y. */
> +(simplify
> + (cond (lt @0 @1) integer_zerop (gt @0 @1))
> + (if (INTEGRAL_TYPE_P (type)
> + && POINTER_TYPE_P (TREE_TYPE (@0))
> + && POINTER_TYPE_P (TREE_TYPE (@1)))
> + (gt @0 @1)))
> +
Hmm, could be simplified to just:
+#if GIMPLE
+/* a ? b : c -> (a & b) | (!a & c) for truth (boolean) values
+ Only if either b or c are integer constants. */
+(simplify
+ (cond @0 truth_valued_p@1 truth_valued_p@2)
+ (if (TREE_CODE (@1) == INTEGER_CST
+ || TREE_CODE (@2) == INTEGER_CST)
+ (with {
+ tree booltrue = constant_boolean_node (true, type);
+ }
+ (bit_ior (bit_and (convert @0) @1) (bit_and (bit_xor (convert @0) {
booltrue; }) @2)))))
+#endif
Which is PR 96923 so mine.
Referenced Bugs:
https://gcc.gnu.org/bugzilla/show_bug.cgi?id=96923
[Bug 96923] Failure to optimize a select-related bool pattern to or+not
More information about the Gcc-bugs
mailing list