From 55a2b24410a87da4b6b05f47b79ce7eef60348f8 Mon Sep 17 00:00:00 2001 From: Sanjay Patel Date: Tue, 23 Feb 2016 22:03:44 +0000 Subject: [PATCH] minimize test and use FileCheck llvm-svn: 261701 --- llvm/test/Transforms/InstCombine/zext-or-icmp.ll | 50 +++++++++--------------- 1 file changed, 18 insertions(+), 32 deletions(-) diff --git a/llvm/test/Transforms/InstCombine/zext-or-icmp.ll b/llvm/test/Transforms/InstCombine/zext-or-icmp.ll index 3a27f9a..8176e45 100644 --- a/llvm/test/Transforms/InstCombine/zext-or-icmp.ll +++ b/llvm/test/Transforms/InstCombine/zext-or-icmp.ll @@ -1,35 +1,21 @@ -; RUN: opt < %s -instcombine -S | grep icmp | count 1 +; RUN: opt < %s -instcombine -S | FileCheck %s - %struct.FooBar = type <{ i8, i8, [2 x i8], i8, i8, i8, i8, i16, i16, [4 x i8], [8 x %struct.Rock] }> - %struct.Rock = type { i16, i16 } -@some_idx = internal constant [4 x i8] c"\0A\0B\0E\0F" ; <[4 x i8]*> [#uses=1] +; Remove an icmp by using its operand in the subsequent logic directly. -define zeroext i8 @t(%struct.FooBar* %up, i8 zeroext %intra_flag, i32 %blk_i) nounwind { -entry: - %tmp2 = lshr i32 %blk_i, 1 ; [#uses=1] - %tmp3 = and i32 %tmp2, 2 ; [#uses=1] - %tmp5 = and i32 %blk_i, 1 ; [#uses=1] - %tmp6 = or i32 %tmp3, %tmp5 ; [#uses=1] - %tmp8 = getelementptr %struct.FooBar, %struct.FooBar* %up, i32 0, i32 7 ; [#uses=1] - %tmp9 = load i16, i16* %tmp8, align 1 ; [#uses=1] - %tmp910 = zext i16 %tmp9 to i32 ; [#uses=1] - %tmp12 = getelementptr [4 x i8], [4 x i8]* @some_idx, i32 0, i32 %tmp6 ; [#uses=1] - %tmp13 = load i8, i8* %tmp12, align 1 ; [#uses=1] - %tmp1314 = zext i8 %tmp13 to i32 ; [#uses=1] - %tmp151 = lshr i32 %tmp910, %tmp1314 ; [#uses=1] - %tmp1516 = trunc i32 %tmp151 to i8 ; [#uses=1] - %tmp18 = getelementptr %struct.FooBar, %struct.FooBar* %up, i32 0, i32 0 ; [#uses=1] - %tmp19 = load i8, i8* %tmp18, align 1 ; [#uses=1] - %tmp22 = and i8 %tmp1516, %tmp19 ; [#uses=1] - %tmp24 = getelementptr %struct.FooBar, %struct.FooBar* %up, i32 0, i32 0 ; [#uses=1] - %tmp25 = load i8, i8* %tmp24, align 1 ; [#uses=1] - %tmp26.mask = and i8 %tmp25, 1 ; [#uses=1] - %toBool = icmp eq i8 %tmp26.mask, 0 ; [#uses=1] - %toBool.not = xor i1 %toBool, true ; [#uses=1] - %toBool33 = icmp eq i8 %intra_flag, 0 ; [#uses=1] - %bothcond = or i1 %toBool.not, %toBool33 ; [#uses=1] - %iftmp.1.0 = select i1 %bothcond, i8 0, i8 1 ; [#uses=1] - %tmp40 = or i8 %tmp22, %iftmp.1.0 ; [#uses=1] - %tmp432 = and i8 %tmp40, 1 ; [#uses=1] - ret i8 %tmp432 +define i8 @zext_or_icmp_icmp(i8 %a, i8 %b) { + %mask = and i8 %a, 1 + %toBool1 = icmp eq i8 %mask, 0 + %toBool2 = icmp eq i8 %b, 0 + %bothCond = or i1 %toBool1, %toBool2 + %zext = zext i1 %bothCond to i8 + ret i8 %zext + +; CHECK-LABEL: zext_or_icmp_icmp( +; CHECK-NEXT: %mask = and i8 %a, 1 +; CHECK-NEXT: %toBool2 = icmp eq i8 %b, 0 +; CHECK-NEXT: %1 = xor i8 %mask, 1 +; CHECK-NEXT: %toBool22 = zext i1 %toBool2 to i8 +; CHECK-NEXT: %zext = or i8 %1, %toBool22 +; CHECK-NEXT: ret i8 %zext } + -- 2.7.4