From 9c2e7ceb1a0d77a619b247d3be4774f209fd0d02 Mon Sep 17 00:00:00 2001 From: Sanjay Patel Date: Wed, 4 Jul 2018 17:44:04 +0000 Subject: [InstCombine] allow narrowing of min/max/abs We have bailout hacks based on min/max in various places in instcombine that shouldn't be necessary. The affected test was added for: D48930 ...which is a consequence of the improvement in: D48584 (https://reviews.llvm.org/rL336172) I'm assuming the visitTrunc bailout in this patch was added specifically to avoid a change from SimplifyDemandedBits, so I'm just moving that below the EvaluateInDifferentType optimization. A narrow min/max is still a min/max. llvm-svn: 336293 --- llvm/test/Transforms/InstCombine/max_known_bits.ll | 9 +++------ 1 file changed, 3 insertions(+), 6 deletions(-) (limited to 'llvm/test') diff --git a/llvm/test/Transforms/InstCombine/max_known_bits.ll b/llvm/test/Transforms/InstCombine/max_known_bits.ll index 2b1676ba0c0..9dca48116fb 100644 --- a/llvm/test/Transforms/InstCombine/max_known_bits.ll +++ b/llvm/test/Transforms/InstCombine/max_known_bits.ll @@ -6,12 +6,9 @@ define i16 @foo(i16 %x) { ; CHECK-LABEL: @foo( ; CHECK-NEXT: [[T1:%.*]] = and i16 [[X:%.*]], 255 -; CHECK-NEXT: [[T2:%.*]] = zext i16 [[T1]] to i32 -; CHECK-NEXT: [[T3:%.*]] = icmp ult i32 [[T2]], 255 -; CHECK-NEXT: [[T4:%.*]] = select i1 [[T3]], i32 [[T2]], i32 255 -; CHECK-NEXT: [[T5:%.*]] = trunc i32 [[T4]] to i16 -; CHECK-NEXT: [[T6:%.*]] = and i16 [[T5]], 255 -; CHECK-NEXT: ret i16 [[T6]] +; CHECK-NEXT: [[T3:%.*]] = icmp ult i16 [[T1]], 255 +; CHECK-NEXT: [[T4:%.*]] = select i1 [[T3]], i16 [[T1]], i16 255 +; CHECK-NEXT: ret i16 [[T4]] ; %t1 = and i16 %x, 255 %t2 = zext i16 %t1 to i32 -- cgit v1.2.3