From 5907f77236807afeb0ea80ecb6169d4a7bb762ac Mon Sep 17 00:00:00 2001 From: Sanjay Patel Date: Fri, 7 Sep 2018 21:40:41 +0000 Subject: [PATCH] [InstCombine][x86] add tests for possible blendv transform (PR38814); NFC llvm-svn: 341715 --- test/Transforms/InstCombine/X86/blend_x86.ll | 132 ++++++++++++++----- 1 file changed, 98 insertions(+), 34 deletions(-) diff --git a/test/Transforms/InstCombine/X86/blend_x86.ll b/test/Transforms/InstCombine/X86/blend_x86.ll index 39ceb0186ef..fa5595575f0 100644 --- a/test/Transforms/InstCombine/X86/blend_x86.ll +++ b/test/Transforms/InstCombine/X86/blend_x86.ll @@ -1,8 +1,9 @@ +; NOTE: Assertions have been autogenerated by utils/update_test_checks.py ; RUN: opt < %s -instcombine -mtriple=x86_64-apple-macosx -mcpu=core-avx2 -S | FileCheck %s define <2 x double> @constant_blendvpd(<2 x double> %xy, <2 x double> %ab) { ; CHECK-LABEL: @constant_blendvpd( -; CHECK-NEXT: [[TMP1:%.*]] = shufflevector <2 x double> %ab, <2 x double> %xy, <2 x i32> +; CHECK-NEXT: [[TMP1:%.*]] = shufflevector <2 x double> [[AB:%.*]], <2 x double> [[XY:%.*]], <2 x i32> ; CHECK-NEXT: ret <2 x double> [[TMP1]] ; %1 = tail call <2 x double> @llvm.x86.sse41.blendvpd(<2 x double> %xy, <2 x double> %ab, <2 x double> ) @@ -10,22 +11,24 @@ define <2 x double> @constant_blendvpd(<2 x double> %xy, <2 x double> %ab) { } define <2 x double> @constant_blendvpd_zero(<2 x double> %xy, <2 x double> %ab) { -; CHECK-LABEL: @constant_blendvpd_zero -; CHECK-NEXT: ret <2 x double> %xy +; CHECK-LABEL: @constant_blendvpd_zero( +; CHECK-NEXT: ret <2 x double> [[XY:%.*]] +; %1 = tail call <2 x double> @llvm.x86.sse41.blendvpd(<2 x double> %xy, <2 x double> %ab, <2 x double> zeroinitializer) ret <2 x double> %1 } define <2 x double> @constant_blendvpd_dup(<2 x double> %xy, <2 x double> %sel) { -; CHECK-LABEL: @constant_blendvpd_dup -; CHECK-NEXT: ret <2 x double> %xy +; CHECK-LABEL: @constant_blendvpd_dup( +; CHECK-NEXT: ret <2 x double> [[XY:%.*]] +; %1 = tail call <2 x double> @llvm.x86.sse41.blendvpd(<2 x double> %xy, <2 x double> %xy, <2 x double> %sel) ret <2 x double> %1 } define <4 x float> @constant_blendvps(<4 x float> %xyzw, <4 x float> %abcd) { ; CHECK-LABEL: @constant_blendvps( -; CHECK-NEXT: [[TMP1:%.*]] = shufflevector <4 x float> %abcd, <4 x float> %xyzw, <4 x i32> +; CHECK-NEXT: [[TMP1:%.*]] = shufflevector <4 x float> [[ABCD:%.*]], <4 x float> [[XYZW:%.*]], <4 x i32> ; CHECK-NEXT: ret <4 x float> [[TMP1]] ; %1 = tail call <4 x float> @llvm.x86.sse41.blendvps(<4 x float> %xyzw, <4 x float> %abcd, <4 x float> ) @@ -33,22 +36,24 @@ define <4 x float> @constant_blendvps(<4 x float> %xyzw, <4 x float> %abcd) { } define <4 x float> @constant_blendvps_zero(<4 x float> %xyzw, <4 x float> %abcd) { -; CHECK-LABEL: @constant_blendvps_zero -; CHECK-NEXT: ret <4 x float> %xyzw +; CHECK-LABEL: @constant_blendvps_zero( +; CHECK-NEXT: ret <4 x float> [[XYZW:%.*]] +; %1 = tail call <4 x float> @llvm.x86.sse41.blendvps(<4 x float> %xyzw, <4 x float> %abcd, <4 x float> zeroinitializer) ret <4 x float> %1 } define <4 x float> @constant_blendvps_dup(<4 x float> %xyzw, <4 x float> %sel) { -; CHECK-LABEL: @constant_blendvps_dup -; CHECK-NEXT: ret <4 x float> %xyzw +; CHECK-LABEL: @constant_blendvps_dup( +; CHECK-NEXT: ret <4 x float> [[XYZW:%.*]] +; %1 = tail call <4 x float> @llvm.x86.sse41.blendvps(<4 x float> %xyzw, <4 x float> %xyzw, <4 x float> %sel) ret <4 x float> %1 } define <16 x i8> @constant_pblendvb(<16 x i8> %xyzw, <16 x i8> %abcd) { ; CHECK-LABEL: @constant_pblendvb( -; CHECK-NEXT: [[TMP1:%.*]] = shufflevector <16 x i8> %abcd, <16 x i8> %xyzw, <16 x i32> +; CHECK-NEXT: [[TMP1:%.*]] = shufflevector <16 x i8> [[ABCD:%.*]], <16 x i8> [[XYZW:%.*]], <16 x i32> ; CHECK-NEXT: ret <16 x i8> [[TMP1]] ; %1 = tail call <16 x i8> @llvm.x86.sse41.pblendvb(<16 x i8> %xyzw, <16 x i8> %abcd, <16 x i8> ) @@ -56,22 +61,24 @@ define <16 x i8> @constant_pblendvb(<16 x i8> %xyzw, <16 x i8> %abcd) { } define <16 x i8> @constant_pblendvb_zero(<16 x i8> %xyzw, <16 x i8> %abcd) { -; CHECK-LABEL: @constant_pblendvb_zero -; CHECK-NEXT: ret <16 x i8> %xyzw +; CHECK-LABEL: @constant_pblendvb_zero( +; CHECK-NEXT: ret <16 x i8> [[XYZW:%.*]] +; %1 = tail call <16 x i8> @llvm.x86.sse41.pblendvb(<16 x i8> %xyzw, <16 x i8> %abcd, <16 x i8> zeroinitializer) ret <16 x i8> %1 } define <16 x i8> @constant_pblendvb_dup(<16 x i8> %xyzw, <16 x i8> %sel) { -; CHECK-LABEL: @constant_pblendvb_dup -; CHECK-NEXT: ret <16 x i8> %xyzw +; CHECK-LABEL: @constant_pblendvb_dup( +; CHECK-NEXT: ret <16 x i8> [[XYZW:%.*]] +; %1 = tail call <16 x i8> @llvm.x86.sse41.pblendvb(<16 x i8> %xyzw, <16 x i8> %xyzw, <16 x i8> %sel) ret <16 x i8> %1 } define <4 x double> @constant_blendvpd_avx(<4 x double> %xy, <4 x double> %ab) { ; CHECK-LABEL: @constant_blendvpd_avx( -; CHECK-NEXT: [[TMP1:%.*]] = shufflevector <4 x double> %ab, <4 x double> %xy, <4 x i32> +; CHECK-NEXT: [[TMP1:%.*]] = shufflevector <4 x double> [[AB:%.*]], <4 x double> [[XY:%.*]], <4 x i32> ; CHECK-NEXT: ret <4 x double> [[TMP1]] ; %1 = tail call <4 x double> @llvm.x86.avx.blendv.pd.256(<4 x double> %xy, <4 x double> %ab, <4 x double> ) @@ -79,22 +86,24 @@ define <4 x double> @constant_blendvpd_avx(<4 x double> %xy, <4 x double> %ab) { } define <4 x double> @constant_blendvpd_avx_zero(<4 x double> %xy, <4 x double> %ab) { -; CHECK-LABEL: @constant_blendvpd_avx_zero -; CHECK-NEXT: ret <4 x double> %xy +; CHECK-LABEL: @constant_blendvpd_avx_zero( +; CHECK-NEXT: ret <4 x double> [[XY:%.*]] +; %1 = tail call <4 x double> @llvm.x86.avx.blendv.pd.256(<4 x double> %xy, <4 x double> %ab, <4 x double> zeroinitializer) ret <4 x double> %1 } define <4 x double> @constant_blendvpd_avx_dup(<4 x double> %xy, <4 x double> %sel) { -; CHECK-LABEL: @constant_blendvpd_avx_dup -; CHECK-NEXT: ret <4 x double> %xy +; CHECK-LABEL: @constant_blendvpd_avx_dup( +; CHECK-NEXT: ret <4 x double> [[XY:%.*]] +; %1 = tail call <4 x double> @llvm.x86.avx.blendv.pd.256(<4 x double> %xy, <4 x double> %xy, <4 x double> %sel) ret <4 x double> %1 } define <8 x float> @constant_blendvps_avx(<8 x float> %xyzw, <8 x float> %abcd) { ; CHECK-LABEL: @constant_blendvps_avx( -; CHECK-NEXT: [[TMP1:%.*]] = shufflevector <8 x float> %abcd, <8 x float> %xyzw, <8 x i32> +; CHECK-NEXT: [[TMP1:%.*]] = shufflevector <8 x float> [[ABCD:%.*]], <8 x float> [[XYZW:%.*]], <8 x i32> ; CHECK-NEXT: ret <8 x float> [[TMP1]] ; %1 = tail call <8 x float> @llvm.x86.avx.blendv.ps.256(<8 x float> %xyzw, <8 x float> %abcd, <8 x float> ) @@ -102,46 +111,100 @@ define <8 x float> @constant_blendvps_avx(<8 x float> %xyzw, <8 x float> %abcd) } define <8 x float> @constant_blendvps_avx_zero(<8 x float> %xyzw, <8 x float> %abcd) { -; CHECK-LABEL: @constant_blendvps_avx_zero -; CHECK-NEXT: ret <8 x float> %xyzw +; CHECK-LABEL: @constant_blendvps_avx_zero( +; CHECK-NEXT: ret <8 x float> [[XYZW:%.*]] +; %1 = tail call <8 x float> @llvm.x86.avx.blendv.ps.256(<8 x float> %xyzw, <8 x float> %abcd, <8 x float> zeroinitializer) ret <8 x float> %1 } define <8 x float> @constant_blendvps_avx_dup(<8 x float> %xyzw, <8 x float> %sel) { -; CHECK-LABEL: @constant_blendvps_avx_dup -; CHECK-NEXT: ret <8 x float> %xyzw +; CHECK-LABEL: @constant_blendvps_avx_dup( +; CHECK-NEXT: ret <8 x float> [[XYZW:%.*]] +; %1 = tail call <8 x float> @llvm.x86.avx.blendv.ps.256(<8 x float> %xyzw, <8 x float> %xyzw, <8 x float> %sel) ret <8 x float> %1 } define <32 x i8> @constant_pblendvb_avx2(<32 x i8> %xyzw, <32 x i8> %abcd) { ; CHECK-LABEL: @constant_pblendvb_avx2( -; CHECK-NEXT: [[TMP1:%.*]] = shufflevector <32 x i8> %abcd, <32 x i8> %xyzw, <32 x i32> +; CHECK-NEXT: [[TMP1:%.*]] = shufflevector <32 x i8> [[ABCD:%.*]], <32 x i8> [[XYZW:%.*]], <32 x i32> ; CHECK-NEXT: ret <32 x i8> [[TMP1]] ; %1 = tail call <32 x i8> @llvm.x86.avx2.pblendvb(<32 x i8> %xyzw, <32 x i8> %abcd, - <32 x i8> ) + <32 x i8> ) ret <32 x i8> %1 } define <32 x i8> @constant_pblendvb_avx2_zero(<32 x i8> %xyzw, <32 x i8> %abcd) { -; CHECK-LABEL: @constant_pblendvb_avx2_zero -; CHECK-NEXT: ret <32 x i8> %xyzw +; CHECK-LABEL: @constant_pblendvb_avx2_zero( +; CHECK-NEXT: ret <32 x i8> [[XYZW:%.*]] +; %1 = tail call <32 x i8> @llvm.x86.avx2.pblendvb(<32 x i8> %xyzw, <32 x i8> %abcd, <32 x i8> zeroinitializer) ret <32 x i8> %1 } define <32 x i8> @constant_pblendvb_avx2_dup(<32 x i8> %xyzw, <32 x i8> %sel) { -; CHECK-LABEL: @constant_pblendvb_avx2_dup -; CHECK-NEXT: ret <32 x i8> %xyzw +; CHECK-LABEL: @constant_pblendvb_avx2_dup( +; CHECK-NEXT: ret <32 x i8> [[XYZW:%.*]] +; %1 = tail call <32 x i8> @llvm.x86.avx2.pblendvb(<32 x i8> %xyzw, <32 x i8> %xyzw, <32 x i8> %sel) ret <32 x i8> %1 } +define <4 x float> @sel_v4f32(<4 x float> %x, <4 x float> %y, <4 x i1> %cond) { +; CHECK-LABEL: @sel_v4f32( +; CHECK-NEXT: [[S:%.*]] = sext <4 x i1> [[COND:%.*]] to <4 x i32> +; CHECK-NEXT: [[B:%.*]] = bitcast <4 x i32> [[S]] to <4 x float> +; CHECK-NEXT: [[R:%.*]] = call <4 x float> @llvm.x86.sse41.blendvps(<4 x float> [[X:%.*]], <4 x float> [[Y:%.*]], <4 x float> [[B]]) +; CHECK-NEXT: ret <4 x float> [[R]] +; + %s = sext <4 x i1> %cond to <4 x i32> + %b = bitcast <4 x i32> %s to <4 x float> + %r = call <4 x float> @llvm.x86.sse41.blendvps(<4 x float> %x, <4 x float> %y, <4 x float> %b) + ret <4 x float> %r +} + +define <2 x double> @sel_v2f64(<2 x double> %x, <2 x double> %y, <2 x i1> %cond) { +; CHECK-LABEL: @sel_v2f64( +; CHECK-NEXT: [[S:%.*]] = sext <2 x i1> [[COND:%.*]] to <2 x i64> +; CHECK-NEXT: [[B:%.*]] = bitcast <2 x i64> [[S]] to <2 x double> +; CHECK-NEXT: [[R:%.*]] = call <2 x double> @llvm.x86.sse41.blendvpd(<2 x double> [[X:%.*]], <2 x double> [[Y:%.*]], <2 x double> [[B]]) +; CHECK-NEXT: ret <2 x double> [[R]] +; + %s = sext <2 x i1> %cond to <2 x i64> + %b = bitcast <2 x i64> %s to <2 x double> + %r = call <2 x double> @llvm.x86.sse41.blendvpd(<2 x double> %x, <2 x double> %y, <2 x double> %b) + ret <2 x double> %r +} + +define <16 x i8> @sel_v4i32(<16 x i8> %x, <16 x i8> %y, <4 x i1> %cond) { +; CHECK-LABEL: @sel_v4i32( +; CHECK-NEXT: [[S:%.*]] = sext <4 x i1> [[COND:%.*]] to <4 x i32> +; CHECK-NEXT: [[B:%.*]] = bitcast <4 x i32> [[S]] to <16 x i8> +; CHECK-NEXT: [[R:%.*]] = call <16 x i8> @llvm.x86.sse41.pblendvb(<16 x i8> [[X:%.*]], <16 x i8> [[Y:%.*]], <16 x i8> [[B]]) +; CHECK-NEXT: ret <16 x i8> [[R]] +; + %s = sext <4 x i1> %cond to <4 x i32> + %b = bitcast <4 x i32> %s to <16 x i8> + %r = call <16 x i8> @llvm.x86.sse41.pblendvb(<16 x i8> %x, <16 x i8> %y, <16 x i8> %b) + ret <16 x i8> %r +} + +define <16 x i8> @sel_v16i8(<16 x i8> %x, <16 x i8> %y, <16 x i1> %cond) { +; CHECK-LABEL: @sel_v16i8( +; CHECK-NEXT: [[S:%.*]] = sext <16 x i1> [[COND:%.*]] to <16 x i8> +; CHECK-NEXT: [[R:%.*]] = tail call <16 x i8> @llvm.x86.sse41.pblendvb(<16 x i8> [[X:%.*]], <16 x i8> [[Y:%.*]], <16 x i8> [[S]]) +; CHECK-NEXT: ret <16 x i8> [[R]] +; + %s = sext <16 x i1> %cond to <16 x i8> + %r = tail call <16 x i8> @llvm.x86.sse41.pblendvb(<16 x i8> %x, <16 x i8> %y, <16 x i8> %s) + ret <16 x i8> %r +} + declare <16 x i8> @llvm.x86.sse41.pblendvb(<16 x i8>, <16 x i8>, <16 x i8>) declare <4 x float> @llvm.x86.sse41.blendvps(<4 x float>, <4 x float>, <4 x float>) declare <2 x double> @llvm.x86.sse41.blendvpd(<2 x double>, <2 x double>, <2 x double>) @@ -149,3 +212,4 @@ declare <2 x double> @llvm.x86.sse41.blendvpd(<2 x double>, <2 x double>, <2 x d declare <32 x i8> @llvm.x86.avx2.pblendvb(<32 x i8>, <32 x i8>, <32 x i8>) declare <8 x float> @llvm.x86.avx.blendv.ps.256(<8 x float>, <8 x float>, <8 x float>) declare <4 x double> @llvm.x86.avx.blendv.pd.256(<4 x double>, <4 x double>, <4 x double>) +