[PATCH] D112634: [InstCombine] canonicalize icmp with trunc op into mask and cmp, part 2
Sanjay Patel via Phabricator via llvm-commits
llvm-commits at lists.llvm.org
Fri Dec 2 08:12:26 PST 2022
spatel added a comment.
In D112634#3965504 <https://reviews.llvm.org/D112634#3965504>, @MatzeB wrote:
> It seems this leads to slightly worse x86 codegen. Where we previously had:
>
> %v1 = trunc i64 %v0 to i32
> %cmp = icmp slt i32 %v1, 0
>
> resulting in:
>
> testl %eax, %eax
> js .LBB0_1
>
> instcombine now changes this to:
>
> %v1 = and i64 %v0, 2147483648
> %cmp = icmp eq i64 %v1, 0
>
> resulting in
>
> testl $-2147483648, %eax # imm = 0x80000000
> jne .LBB0_2
>
> Though I guess we best fix this by adding more x86 patterns...
Yes, we can fix this up at some point in codegen/isel. For any mask+cmp of an i64/i32/i16 try to convert to a signbit test of a smaller power-of-2 type to avoid using a constant in the test instruction?
Repository:
rG LLVM Github Monorepo
CHANGES SINCE LAST ACTION
https://reviews.llvm.org/D112634/new/
https://reviews.llvm.org/D112634
More information about the llvm-commits
mailing list