This is the mail archive of the gcc-patches@gcc.gnu.org mailing list for the GCC project.


Index Nav: [Date Index] [Subject Index] [Author Index] [Thread Index]
Message Nav: [Date Prev] [Date Next] [Thread Prev] [Thread Next]
Other format: [Raw text]

Re: PATCH: PR target/42542: Vectorizer produces incorrect results on max of signed intergers


On 01/05/2010 05:11 PM, Uros Bizjak wrote:
On 01/05/2010 04:55 PM, Paolo Bonzini wrote:
I see no other way to fixup the underflow. Some comments below:

You can always subtract (or XOR) the sign bit to turn an unsigned value to the corresponding signed value. The attached patch (on top of the code before H.J.'s patch) fixes the C testcase in the PR, but I didn't test it further and I don't have time unfortunately.

It will work until you change the sign bit of 0x80000000, either of an input operand or an intermediate result of subtraction. For the reference of interested readers, this problem is described in [1].

No, that's a different thing. The problems with 0x8000000 arise when you have 0x80000000 as a signed number, while here you have 0x80000000 as an unsigned number.


Subtracting 0x80000000 from a number in the range 0 to 0xFFFFFFFF will produce a result in the range -0x80000000 to 0x7FFFFFFF which is exactly two's complement. XOR just happens to give the same result.

It's a very well known trick IMNSHO. Please provide a counterexample if you think there is one.

Paolo


Index Nav: [Date Index] [Subject Index] [Author Index] [Thread Index]
Message Nav: [Date Prev] [Date Next] [Thread Prev] [Thread Next]