[Bug tree-optimization/107880] bool tautology missed optimisation

2023-09-12 Thread pinskia at gcc dot gnu.org via Gcc-bugs
https://gcc.gnu.org/bugzilla/show_bug.cgi?id=107880
Bug 107880 depends on bug 107881, which changed state.

Bug 107881 Summary: (a <= b) == (b >= a) should be optimized to (a == b)
https://gcc.gnu.org/bugzilla/show_bug.cgi?id=107881

   What|Removed |Added

 Status|ASSIGNED|RESOLVED
 Resolution|--- |FIXED

[Bug tree-optimization/107880] bool tautology missed optimisation

2023-08-28 Thread pinskia at gcc dot gnu.org via Gcc-bugs
https://gcc.gnu.org/bugzilla/show_bug.cgi?id=107880

Andrew Pinski  changed:

   What|Removed |Added

 Status|NEW |ASSIGNED

--- Comment #4 from Andrew Pinski  ---
With a patch I have for PR 95185

we get:
```
  _1 = b_2(D) == a_3(D);
  _10 = b_2(D) ^ a_3(D);
  _5 = _1 ^ _10;
```

Which is better than before.

One more improvement would be:
```
bool a(bool x, bool y)
{
bool t = x == y;
return t ^ x;
}
```

Into:
```
bool a0(bool x, bool y)
{
bool t = (x ^ y);
return t ^ x ^1; // ~y
}
```

So the 2 which are needed still:

/* (a == b) ^ a -> b^1 */
(simplify
 (bit_xor:c (eq:c zero_one_valued_p@0 zero_one_valued_p@1) @0)
 (bit_xor @1 { build_one_cst (type); })

/* (a == b) ^ (a^b) -> b^(b^1) or (b^b)^1 or rather 1 */
(simplify
 (bit_xor:c (eq:c zero_one_valued_p@0 zero_one_valued_p@1) (bit_xor:c @0 @1))
 { build_one_cst (type); })

So mine.

[Bug tree-optimization/107880] bool tautology missed optimisation

2023-08-28 Thread pinskia at gcc dot gnu.org via Gcc-bugs
https://gcc.gnu.org/bugzilla/show_bug.cgi?id=107880
Bug 107880 depends on bug 107881, which changed state.

Bug 107881 Summary: (a <= b) == (b >= a) should be optimized to (a == b)
https://gcc.gnu.org/bugzilla/show_bug.cgi?id=107881

   What|Removed |Added

 Status|RESOLVED|ASSIGNED
 Resolution|DUPLICATE   |---

[Bug tree-optimization/107880] bool tautology missed optimisation

2023-08-28 Thread pinskia at gcc dot gnu.org via Gcc-bugs
https://gcc.gnu.org/bugzilla/show_bug.cgi?id=107880
Bug 107880 depends on bug 107881, which changed state.

Bug 107881 Summary: (a <= b) == (b >= a) should be optimized to (a == b)
https://gcc.gnu.org/bugzilla/show_bug.cgi?id=107881

   What|Removed |Added

 Status|ASSIGNED|RESOLVED
 Resolution|--- |DUPLICATE

[Bug tree-optimization/107880] bool tautology missed optimisation

2023-05-23 Thread pinskia at gcc dot gnu.org via Gcc-bugs
https://gcc.gnu.org/bugzilla/show_bug.cgi?id=107880

Andrew Pinski  changed:

   What|Removed |Added

   See Also||https://gcc.gnu.org/bugzill
   ||a/show_bug.cgi?id=71762

--- Comment #3 from Andrew Pinski  ---
Turns out this was there before but was removed (r7-4801-g0eb078fe20d443e2)
because it caused some issues.
See PR 71762 .

[Bug tree-optimization/107880] bool tautology missed optimisation

2022-11-26 Thread pinskia at gcc dot gnu.org via Gcc-bugs
https://gcc.gnu.org/bugzilla/show_bug.cgi?id=107880

Andrew Pinski  changed:

   What|Removed |Added

   See Also||https://gcc.gnu.org/bugzill
   ||a/show_bug.cgi?id=101807

--- Comment #2 from Andrew Pinski  ---
One way of fixing this is first transform:
  _9 = ~a_4(D);
  _10 = b_3(D) | _9;
Into:

_10 = a_4(D) <= b_3(D);

And then we have:
  _8 = b_3(D) >= a_4(D);
  _7 = b_3(D) <= a_4(D);
  _1 = _7 == _8;
  _2 = b_3(D) == a_4(D);
  _6 = _1 == _2;

But  _1 is true iff a_4(D) == b_3(D) .
Let me file that second one as we don't optimize it also for int.

[Bug tree-optimization/107880] bool tautology missed optimisation

2022-11-26 Thread pinskia at gcc dot gnu.org via Gcc-bugs
https://gcc.gnu.org/bugzilla/show_bug.cgi?id=107880

Andrew Pinski  changed:

   What|Removed |Added

 Ever confirmed|0   |1
 Status|UNCONFIRMED |NEW
   Last reconfirmed||2022-11-26

--- Comment #1 from Andrew Pinski  ---
We get in optimized:
  _9 = ~a_4(D);
  _10 = b_3(D) | _9;
  _7 = ~b_3(D);
  _8 = a_4(D) | _7;
  _1 = _8 == _10;
  _2 = b_3(D) == a_4(D);
  _6 = _1 == _2;