[llvm-dev] Why doesn't this `and` get eliminated

Craig Topper via llvm-dev llvm-dev at lists.llvm.org
Thu Jun 11 18:56:51 PDT 2020


I don't think its legal to remove it. That code is equivalent to asking (%0
mod 8) == 7. Which is true for 7 and 15 and 23, etc. You can't just remove
the mod part of that or it would just return true for %0 == 7.

~Craig


On Thu, Jun 11, 2020 at 6:31 PM Riyaz Puthiyapurayil via llvm-dev <
llvm-dev at lists.llvm.org> wrote:

> define dso_local i32 @f(i32 %0) {
>
>   %2 = and i32 %0, 7
>
>   %3 = icmp eq i32 %2, 7
>
>   %4 = zext i1 %3 to i32
>
>   ret i32 %4
>
> }
>
>
>
> I thought instcombine would remove it. It doesn’t and nothing else does
> either. LLVM Version is 10.0.0.
>
>
>
> /Riyaz
> _______________________________________________
> LLVM Developers mailing list
> llvm-dev at lists.llvm.org
> https://lists.llvm.org/cgi-bin/mailman/listinfo/llvm-dev
>
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://lists.llvm.org/pipermail/llvm-dev/attachments/20200611/22199736/attachment.html>


More information about the llvm-dev mailing list