[Bug tree-optimization/81110] tree-vrp optimize unsigned comparison to signed

2017-06-16 Thread pinskia at gcc dot gnu.org
https://gcc.gnu.org/bugzilla/show_bug.cgi?id=81110 --- Comment #6 from Andrew Pinski --- (In reply to Ada Liu from comment #5) > But (65536*d[1]+d[0]) is convered to (unsigned long), should not be treated > as unsigned? NO. Both C and C++ language is clear here about the expression "65536*d[1]

[Bug tree-optimization/81110] tree-vrp optimize unsigned comparison to signed

2017-06-16 Thread qian.liu at ingenic dot com
https://gcc.gnu.org/bugzilla/show_bug.cgi?id=81110 --- Comment #5 from Ada Liu --- (In reply to Andrew Pinski from comment #3) > 65536*d[1] will overflow if d[1] is 65535 (0x). > > If you did this instead it would be defined: > 65536u*d[1] > > as that is an unsigned * unsigned short so the

[Bug tree-optimization/81110] tree-vrp optimize unsigned comparison to signed

2017-06-15 Thread pinskia at gcc dot gnu.org
https://gcc.gnu.org/bugzilla/show_bug.cgi?id=81110 --- Comment #4 from Andrew Pinski --- Note you can also use -fwrapv to get the behavior you want.

[Bug tree-optimization/81110] tree-vrp optimize unsigned comparison to signed

2017-06-15 Thread pinskia at gcc dot gnu.org
https://gcc.gnu.org/bugzilla/show_bug.cgi?id=81110 Andrew Pinski changed: What|Removed |Added Status|UNCONFIRMED |RESOLVED Resolution|---

[Bug tree-optimization/81110] tree-vrp optimize unsigned comparison to signed

2017-06-15 Thread qian.liu at ingenic dot com
https://gcc.gnu.org/bugzilla/show_bug.cgi?id=81110 --- Comment #2 from Ada Liu --- Comment on attachment 41567 --> https://gcc.gnu.org/bugzilla/attachment.cgi?id=41567 reduced testcase > >unsigned short d[2]; >__attribute__ ((noinline))int DiffInt () >{ > if ((unsigned long)(65536*d[1]+d[0]

[Bug tree-optimization/81110] tree-vrp optimize unsigned comparison to signed

2017-06-15 Thread qian.liu at ingenic dot com
https://gcc.gnu.org/bugzilla/show_bug.cgi?id=81110 --- Comment #1 from Ada Liu --- Comment on attachment 41567 --> https://gcc.gnu.org/bugzilla/attachment.cgi?id=41567 reduced testcase > >unsigned short d[2]; >__attribute__ ((noinline))int DiffInt () >{ > if ((unsigned long)(65536*d[1]+d[0]