[C++] Handle ?: for vectors

Jason Merrill jason@redhat.com
Thu Oct 25 02:34:00 GMT 2012


On 10/24/2012 04:15 PM, Marc Glisse wrote:
> I don't understand how < 0 differs from != 0 for that purpose. In both
> cases, the front-end will produce the extra comparison, and the
> middle-end will need an optimization to detect "truth values" (vectors
> of -1 and 0) and simplify trivial operations on those (<0, !=0, etc).

True; if we aren't going to assume that the operand is already a 
truthvalue vector, it would be the same.  So let's go with != 0 after all.

> (at a point, based on Richard's words but apparently not on his
> suggestion, I was tempted to introduce a new boolean vector type, whose
> only values are 0 and -1, but that seems a bit complicated and doesn't
> answer whether x?y:z should mean x<0 or x!=0)

That would make sense to me; it would avoid the extra comparison if the 
condition is a boolean vector.

Jason



More information about the Gcc-patches mailing list