From 0415b1810bbf93f434f1c561e172bf24c1cb37dc Mon Sep 17 00:00:00 2001 From: Tim Northover Date: Wed, 4 Sep 2013 11:57:17 +0000 Subject: InstCombine: allow unmasked icmps to be combined with logical ops "(icmp op i8 A, B)" is equivalent to "(icmp op i8 (A & 0xff), B)" as a degenerate case. Allowing this as a "masked" comparison when analysing "(icmp) &/| (icmp)" allows us to combine them in more cases. rdar://problem/7625728 git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@189931 91177308-0d34-0410-b5e6-96231b3b80d8 --- test/Transforms/InstCombine/icmp-logical.ll | 30 +++++++++++++++++++++++++++++ 1 file changed, 30 insertions(+) (limited to 'test/Transforms/InstCombine/icmp-logical.ll') diff --git a/test/Transforms/InstCombine/icmp-logical.ll b/test/Transforms/InstCombine/icmp-logical.ll index c0c5a61ef0..d5d8cbc8c2 100644 --- a/test/Transforms/InstCombine/icmp-logical.ll +++ b/test/Transforms/InstCombine/icmp-logical.ll @@ -120,3 +120,33 @@ define i1 @masked_or_allzeroes_notoptimised(i32 %A) { ret i1 %res } +define i1 @nomask_lhs(i32 %in) { +; CHECK-LABEL: @nomask_lhs +; CHECK: [[MASK:%.*]] = and i32 %in, 1 +; CHECK: icmp eq i32 [[MASK]], 0 +; CHECK-NOT: icmp +; CHECK: ret i1 + %tst1 = icmp eq i32 %in, 0 + + %masked = and i32 %in, 1 + %tst2 = icmp eq i32 %masked, 0 + + %val = or i1 %tst1, %tst2 + ret i1 %val +} + + +define i1 @nomask_rhs(i32 %in) { +; CHECK-LABEL: @nomask_rhs +; CHECK: [[MASK:%.*]] = and i32 %in, 1 +; CHECK: icmp eq i32 [[MASK]], 0 +; CHECK-NOT: icmp +; CHECK: ret i1 + %masked = and i32 %in, 1 + %tst1 = icmp eq i32 %masked, 0 + + %tst2 = icmp eq i32 %in, 0 + + %val = or i1 %tst1, %tst2 + ret i1 %val +} -- cgit v1.2.3