[PATCH] D25200: [InstCombine] New opportunities for FoldAndOfICmp and FoldXorOfICmp

Sanjay Patel via llvm-commits llvm-commits at lists.llvm.org
Wed Oct 5 11:15:43 PDT 2016


spatel added a reviewer: efriedma.
spatel added a comment.

I know we want to expand the patterns that are matched beyond what's included in this patch, but it's not clear to me why we need IsAnyBitSet() for these cases. Eg, there are no tests for the 'icmp ugt' case.

Is it simpler to just use more direct pattern matching for now and then see how it can be recoded as we add cases?

I'm also wondering if there's some way to reuse the existing decomposeBitTestICmp() or the code in foldSelectInstWithICmp() that is marked with a FIXME. We also have isSignBitCheck() and isSignTest() in InstCombineCompares.cpp. There must be some way to refactor all of this logic because we're looking for similar patterns in several different places?



> and-or-icmps.ll:54-60
> +define i1 @test2(i32 %a, i32 %b) {
> +
> +; CHECK-LABEL: @test2(
> +; CHECK-NEXT: val1 = and i32 %a, 8
> +; CHECK-NEXT: val2 = and i32 %b, 8
> +; CHECK-NEXT: [[TEST2TMP:%.*]] = icmp ult i32 %val2, %val1
> +; CHECK-NEXT: ret i1 [[TEST2TMP]]

You can use utils/update_test_checks.py to auto-generate better checks for all of these tests. That's how the existing checks in this file were produced.

https://reviews.llvm.org/D25200





More information about the llvm-commits mailing list