[Bug tree-optimization/114999] A few missing optimizations due to `a - b` and `b - a` not being detected as negatives of each other

2024-05-31 Thread pinskia at gcc dot gnu.org via Gcc-bugs
https://gcc.gnu.org/bugzilla/show_bug.cgi?id=114999 --- Comment #9 from Andrew Pinski --- ``` float f(float a, float b, float x) { x = a - b; float t = 0; t = t - x; return t/x; } ``` ! HONOR_NANS (type) && ! HONOR_INFINITIES (type) ``` int f(int a, int b, int A) { A = ~A; int t

[Bug tree-optimization/114999] A few missing optimizations due to `a - b` and `b - a` not being detected as negatives of each other

2024-05-31 Thread pinskia at gcc dot gnu.org via Gcc-bugs
https://gcc.gnu.org/bugzilla/show_bug.cgi?id=114999 --- Comment #8 from Andrew Pinski --- ``` int f(int x) { x = ~x; int t = (x >= 0 ? x : 0); int t1 = (x <= 0 ? -x : 0); return t + t1; } ``` abs(~x)

[Bug tree-optimization/114999] A few missing optimizations due to `a - b` and `b - a` not being detected as negatives of each other

2024-05-24 Thread pinskia at gcc dot gnu.org via Gcc-bugs
https://gcc.gnu.org/bugzilla/show_bug.cgi?id=114999 --- Comment #7 from Andrew Pinski --- ``` inline int func0(int y){ return -~y; } int func2(int y){ return (~y)/(-(~y)); } int func2a(int y){ return (~y)/func0(y); } int func1(int y){ return (~y)/(y+1); } ``` What is interesting

[Bug tree-optimization/114999] A few missing optimizations due to `a - b` and `b - a` not being detected as negatives of each other

2024-05-24 Thread pinskia at gcc dot gnu.org via Gcc-bugs
https://gcc.gnu.org/bugzilla/show_bug.cgi?id=114999 --- Comment #6 from Andrew Pinski --- `~a` and `a + 1` are also negative of each other too: ``` int f(int a, int b) { int t = ~a; int t1 = -t; return t1 == t; } int f1(int a) { return (~a) == (-~a); } int f2(int a) { return (a) ==

[Bug tree-optimization/114999] A few missing optimizations due to `a - b` and `b - a` not being detected as negatives of each other

2024-05-08 Thread pinskia at gcc dot gnu.org via Gcc-bugs
https://gcc.gnu.org/bugzilla/show_bug.cgi?id=114999 --- Comment #5 from Andrew Pinski --- The following patterns could be improved/removed while doing this: ``` /* (A - B) == 0 ? (A - B) : (B - A)same as (B - A) */ /* (A - B) != 0 ? (A - B) : (B - A)same as (A - B) */ /* (A - B) >=/>

[Bug tree-optimization/114999] A few missing optimizations due to `a - b` and `b - a` not being detected as negatives of each other

2024-05-08 Thread pinskia at gcc dot gnu.org via Gcc-bugs
https://gcc.gnu.org/bugzilla/show_bug.cgi?id=114999 Andrew Pinski changed: What|Removed |Added Blocks||113265 --- Comment #4 from Andrew

[Bug tree-optimization/114999] A few missing optimizations due to `a - b` and `b - a` not being detected as negatives of each other

2024-05-08 Thread pinskia at gcc dot gnu.org via Gcc-bugs
https://gcc.gnu.org/bugzilla/show_bug.cgi?id=114999 --- Comment #3 from Andrew Pinski --- (In reply to Andrew Pinski from comment #2) > Another one: > ``` > int f(int a, int b, int x) > { > x = a - b; > int y = -x; > return (x >= 0 ? x : 0) + (x <= 0 ? y : 0); > } > ``` > > This should be

[Bug tree-optimization/114999] A few missing optimizations due to `a - b` and `b - a` not being detected as negatives of each other

2024-05-08 Thread pinskia at gcc dot gnu.org via Gcc-bugs
https://gcc.gnu.org/bugzilla/show_bug.cgi?id=114999 Andrew Pinski changed: What|Removed |Added Summary|`a - b == b - a` -> `a == |A few missing optimizations