From: Sanjay Patel Date: Tue, 25 Oct 2016 15:16:39 +0000 (+0000) Subject: [InstCombine] add test and code comment to show potentially misguided icmp trunc... X-Git-Url: https://granicus.if.org/sourcecode?a=commitdiff_plain;h=ce0f082662d57492411c6719db26627142cc5d73;p=llvm [InstCombine] add test and code comment to show potentially misguided icmp trunc transform git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@285075 91177308-0d34-0410-b5e6-96231b3b80d8 --- diff --git a/lib/Transforms/InstCombine/InstCombineCompares.cpp b/lib/Transforms/InstCombine/InstCombineCompares.cpp index 7b59f86d1ea..9a31de4f8aa 100644 --- a/lib/Transforms/InstCombine/InstCombineCompares.cpp +++ b/lib/Transforms/InstCombine/InstCombineCompares.cpp @@ -1950,6 +1950,9 @@ Instruction *InstCombiner::foldICmpShlConstant(ICmpInst &Cmp, And, Constant::getNullValue(And->getType())); } + // FIXME: This transform can create illegal types. Use the DataLayout to + // decide when to try this? + // Transform (icmp pred iM (shl iM %v, N), C) // -> (icmp pred i(M-N) (trunc %v iM to i(M-N)), (trunc (C>>N)) // Transform the shl to a trunc if (trunc (C>>N)) has no loss and M-N. diff --git a/test/Transforms/InstCombine/icmp.ll b/test/Transforms/InstCombine/icmp.ll index da5913e3821..57e02a47e55 100644 --- a/test/Transforms/InstCombine/icmp.ll +++ b/test/Transforms/InstCombine/icmp.ll @@ -1208,6 +1208,19 @@ define i1 @icmp_shl16(i32 %x) { ret i1 %cmp } +; FIXME: We shouldn't be creating illegal types like i15 in InstCombine. + +define i1 @icmp_shl17(i32 %x) { +; CHECK-LABEL: @icmp_shl17( +; CHECK-NEXT: [[TMP1:%.*]] = trunc i32 %x to i15 +; CHECK-NEXT: [[CMP:%.*]] = icmp slt i15 [[TMP1]], 18 +; CHECK-NEXT: ret i1 [[CMP]] +; + %shl = shl i32 %x, 17 + %cmp = icmp slt i32 %shl, 2359296 + ret i1 %cmp +} + define <2 x i1> @icmp_shl16_vec(<2 x i32> %x) { ; CHECK-LABEL: @icmp_shl16_vec( ; CHECK-NEXT: [[TMP1:%.*]] = trunc <2 x i32> %x to <2 x i16>