From: Sanjay Patel Date: Fri, 4 Aug 2017 20:38:33 +0000 (+0000) Subject: [InstCombine] add vector tests for truncated math; NFC X-Git-Url: https://granicus.if.org/sourcecode?a=commitdiff_plain;h=310c521bc4230b96b5d2789978e0a99ee42c1f6b;p=llvm [InstCombine] add vector tests for truncated math; NFC git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@310122 91177308-0d34-0410-b5e6-96231b3b80d8 --- diff --git a/test/Transforms/InstCombine/trunc.ll b/test/Transforms/InstCombine/trunc.ll index 3ba0b866e47..d606815f9bb 100644 --- a/test/Transforms/InstCombine/trunc.ll +++ b/test/Transforms/InstCombine/trunc.ll @@ -533,3 +533,25 @@ define <8 x i8> @wide_lengthening_splat(<4 x i16> %v) { ret <8 x i8> %tr } +define <2 x i8> @narrow_add_vec_constant(<2 x i32> %x) { +; CHECK-LABEL: @narrow_add_vec_constant( +; CHECK-NEXT: [[ADD:%.*]] = add <2 x i32> %x, +; CHECK-NEXT: [[TR:%.*]] = trunc <2 x i32> [[ADD]] to <2 x i8> +; CHECK-NEXT: ret <2 x i8> [[TR]] +; + %add = add <2 x i32> %x, + %tr = trunc <2 x i32> %add to <2 x i8> + ret <2 x i8> %tr +} + +define <2 x i8> @narrow_sub_vec_constant(<2 x i32> %x) { +; CHECK-LABEL: @narrow_sub_vec_constant( +; CHECK-NEXT: [[SUB:%.*]] = sub <2 x i32> , %x +; CHECK-NEXT: [[TR:%.*]] = trunc <2 x i32> [[SUB]] to <2 x i8> +; CHECK-NEXT: ret <2 x i8> [[TR]] +; + %sub = sub <2 x i32> , %x + %tr = trunc <2 x i32> %sub to <2 x i8> + ret <2 x i8> %tr +} +