[LLVMdev] struct with signed bitfield (PR17827)

Henrique Santos henrique.nazare.santos at gmail.com
Sat Nov 16 15:00:58 PST 2013


On Sat, Nov 16, 2013 at 3:39 PM, Kay Tiong Khoo <kkhoo at perfwizard.com>wrote:

> I need to read up on how nsw would make this different, but I see your
> point about the shift:
>

If the nsw flag is set, we can assume the sign bit isn't affected and apply
the simplification.
If the nuw flag is set, we can assume no bits are shifted out and apply the
simplification if the comparison is unsigned.
If no flag is set (and no flag is settable), then I don't think there's
anything to be done.


>   %bf.result.shl = shl i8 %bf.value, 5
>   %bf.result.ashr = ashr i8 %bf.result.shl, 5
>
> This should have splatted the sign bit across the upper 5 bits of the
> char, so the subsequent compare:
>  %cmp = icmp slt i32 %bf.cast, 1
>
> Can't be transformed to a check for 'equal to 0'.
>
> Thanks!
>

H.
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://lists.llvm.org/pipermail/llvm-dev/attachments/20131116/283d630a/attachment.html>


More information about the llvm-dev mailing list