[cfe-dev] Why no NSW/NUW with SHL instruction?

Ryan Taylor ryta1203 at gmail.com
Fri Nov 21 09:39:50 PST 2014


So again, I'm not sure why this is the case. I know this has probably been
discussed ad nauseam (as evidenced by the multiple posts asking about this,
including mine), but it seems pretty clear cut that you'd want separate
shl, one for logical (non-overflow) and one for arithmetic (overflow). In
fact, you might want a logical, signed arith and unsigned arith, at least
in the hardware.

I don't care if clang only produces shl, I'm more curious how to get the
signed info to the backend for shl when it's not producing a nsw/nuw flag?
I'm currently not sure how this would be done, is there another arch that
manages this somehow?

Thanks.

On Wed, Nov 19, 2014 at 1:52 PM, Reid Kleckner <rnk at google.com> wrote:

> What is the difference between logical and arithmetic left shift on your
> target? LLVM only makes that distinction for right shift, and not for left
> shift.
>
> On Wed, Nov 19, 2014 at 10:32 AM, Ryan Taylor <ryta1203 at gmail.com> wrote:
>
>> I'm curious why there is not always a nsw/nuw flag with shl instruction?
>> For example, I have a signed int I'm shifting left (want to generate an
>> arithmetic left shift in backend for signed int shift lefts and logical for
>> unsigned, at the moment).... but shl on a signed int does not always have
>> nsw/nuw flag present, why is this?
>>
>> Thank you.
>>
>> _______________________________________________
>> cfe-dev mailing list
>> cfe-dev at cs.uiuc.edu
>> http://lists.cs.uiuc.edu/mailman/listinfo/cfe-dev
>>
>>
>
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://lists.llvm.org/pipermail/cfe-dev/attachments/20141121/a04bb181/attachment.html>


More information about the cfe-dev mailing list