[prev in list] [next in list] [prev in thread] [next in thread] 

List:       gcc-bugs
Subject:    [Bug tree-optimization/69984] [4.9/5/6] Signed comparison instruction emitted for unsigned variable 
From:       "edmar at freescale dot com" <gcc-bugzilla () gcc ! gnu ! org>
Date:       2016-02-29 20:06:24
Message-ID: bug-69984-4-EPXs7p0S51 () http ! gcc ! gnu ! org/bugzilla/
[Download RAW message or body]

https://gcc.gnu.org/bugzilla/show_bug.cgi?id=69984

--- Comment #9 from Edmar Wienskoski <edmar at freescale dot com> ---
Ok. Thanks for the clarification.

The comparison is made with an unsigned variable, but gcc
is certain that this variable cannot have (legally) a value that
cannot be represented in an int.

That is why 
C = (long) ((int)A) * ((int)B))
generates the same code as:
C = A * B
but
C = (unsigned long) ((int)A) * ((int)B))
does not.

The assignment is made after the computation of the expression,
therefore just assigning something to "C", does not change what
gcc can infer from the right side, and by consequence what can
be known from "C"

While on the second case, the type cast is not implicit in the assignment
but it is part of the expression itself, and that changes the range of values
the expression can take.

Lots of thanks for your time.=
[prev in list] [next in list] [prev in thread] [next in thread] 

Configure | About | News | Add a list | Sponsored by KoreLogic