[Bug tree-optimization/101590] (len & - N) <= len is not optimized to 1

2023-10-27 Thread pinskia at gcc dot gnu.org via Gcc-bugs
https://gcc.gnu.org/bugzilla/show_bug.cgi?id=101590 Andrew Pinski changed: What|Removed |Added Resolution|--- |FIXED Target Milestone|---

[Bug tree-optimization/101590] (len & - N) <= len is not optimized to 1

2023-10-27 Thread cvs-commit at gcc dot gnu.org via Gcc-bugs
https://gcc.gnu.org/bugzilla/show_bug.cgi?id=101590 --- Comment #10 from CVS Commits --- The trunk branch has been updated by Andrew Pinski : https://gcc.gnu.org/g:a5e69e94591ae282857d59e868ff6cea7306c802 commit r14-4965-ga5e69e94591ae282857d59e868ff6cea7306c802 Author: Andrew Pinski Date: T

[Bug tree-optimization/101590] (len & - N) <= len is not optimized to 1

2023-10-25 Thread pinskia at gcc dot gnu.org via Gcc-bugs
https://gcc.gnu.org/bugzilla/show_bug.cgi?id=101590 --- Comment #9 from Andrew Pinski --- Just an FYI the corrected and full version (which I will be submitting later today or tomorrow morning) is: /* U & N <= U -> true U & N > U -> false U needs to be non-negative. U | N < U ->

[Bug tree-optimization/101590] (len & - N) <= len is not optimized to 1

2023-10-24 Thread pinskia at gcc dot gnu.org via Gcc-bugs
https://gcc.gnu.org/bugzilla/show_bug.cgi?id=101590 --- Comment #8 from Andrew Pinski --- So the test in the end should be: INTEGRAL_TYPE_P (TREE_TYPE (@0)) && tree_expr_nonnegative_p (@0) as it does not matter if @1 has the sign bit set or not. since nonzero & XYZ is still nonzero and in this

[Bug tree-optimization/101590] (len & - N) <= len is not optimized to 1

2023-10-24 Thread pinskia at gcc dot gnu.org via Gcc-bugs
https://gcc.gnu.org/bugzilla/show_bug.cgi?id=101590 --- Comment #7 from Andrew Pinski --- We could use tree_expr_nonnegative_p here . Though I noticed that tree_single_nonnegative_warnv_p could be improved to use nonzerobits if it is there to speed up things ... I will handle that part seperate

[Bug tree-optimization/101590] (len & - N) <= len is not optimized to 1

2023-10-24 Thread pinskia at gcc dot gnu.org via Gcc-bugs
https://gcc.gnu.org/bugzilla/show_bug.cgi?id=101590 --- Comment #6 from Andrew Pinski --- We should also handle: int foo(int len, int N) { len &= 0x; N &= 0xff; int newlen = len & ~N; return newlen <= len; } That is (TREE_UNSIGNED (TREE_TYPE (@0)) || (signbi

[Bug tree-optimization/101590] (len & - N) <= len is not optimized to 1

2023-08-22 Thread pinskia at gcc dot gnu.org via Gcc-bugs
https://gcc.gnu.org/bugzilla/show_bug.cgi?id=101590 --- Comment #5 from Andrew Pinski --- (In reply to Andrew Pinski from comment #4) > U | N < U -> false > U & N <= U -> true > U & N > U -> false > U | N >= U -> true > > >I don't see an easy way to combine these two patterns though. > I totally

[Bug tree-optimization/101590] (len & - N) <= len is not optimized to 1

2023-08-22 Thread pinskia at gcc dot gnu.org via Gcc-bugs
https://gcc.gnu.org/bugzilla/show_bug.cgi?id=101590 --- Comment #4 from Andrew Pinski --- U | N < U -> false U & N <= U -> true U & N > U -> false U | N >= U -> true >I don't see an easy way to combine these two patterns though. I totally missed that the for loop is a pair for. (for cmp (lt

[Bug tree-optimization/101590] (len & - N) <= len is not optimized to 1

2021-07-27 Thread pinskia at gcc dot gnu.org via Gcc-bugs
https://gcc.gnu.org/bugzilla/show_bug.cgi?id=101590 --- Comment #3 from Andrew Pinski --- (In reply to Andrew Pinski from comment #2) > (In reply to Richard Biener from comment #1) > > it doesn't even have to be -N, any unsigned & N <= unsigned > > Here are the ones which are valid: > > U | N <

[Bug tree-optimization/101590] (len & - N) <= len is not optimized to 1

2021-07-27 Thread pinskia at gcc dot gnu.org via Gcc-bugs
https://gcc.gnu.org/bugzilla/show_bug.cgi?id=101590 Andrew Pinski changed: What|Removed |Added Last reconfirmed||2021-07-27 Status|UNCONFIRM

[Bug tree-optimization/101590] (len & - N) <= len is not optimized to 1

2021-07-27 Thread rguenth at gcc dot gnu.org via Gcc-bugs
https://gcc.gnu.org/bugzilla/show_bug.cgi?id=101590 --- Comment #1 from Richard Biener --- it doesn't even have to be -N, any unsigned & N <= unsigned