diff options
| author | Simon Pilgrim <llvm-dev@redking.me.uk> | 2017-01-20 13:21:30 +0000 |
|---|---|---|
| committer | Simon Pilgrim <llvm-dev@redking.me.uk> | 2017-01-20 13:21:30 +0000 |
| commit | 2817b476e8b2356418f98bc3538d868214516b83 (patch) | |
| tree | b5de632625fc5785d8cafdf4efcdc03d849fdacd | |
| parent | 2db2a947f64b9291d6ef445e6df272ae159e0e21 (diff) | |
| download | bcm5719-llvm-2817b476e8b2356418f98bc3538d868214516b83.tar.gz bcm5719-llvm-2817b476e8b2356418f98bc3538d868214516b83.zip | |
[InstCombine][SSE] Tests showing missed opportunities to constant fold packss/packus
llvm-svn: 292609
| -rw-r--r-- | llvm/test/Transforms/InstCombine/x86-pack.ll | 76 |
1 files changed, 76 insertions, 0 deletions
diff --git a/llvm/test/Transforms/InstCombine/x86-pack.ll b/llvm/test/Transforms/InstCombine/x86-pack.ll index db546685927..00ccc24d0d9 100644 --- a/llvm/test/Transforms/InstCombine/x86-pack.ll +++ b/llvm/test/Transforms/InstCombine/x86-pack.ll @@ -78,6 +78,82 @@ define <32 x i8> @undef_packuswb_256() { } ; +; Constant Folding +; + +define <8 x i16> @fold_packssdw_128() { +; CHECK-LABEL: @fold_packssdw_128( +; CHECK-NEXT: [[TMP1:%.*]] = call <8 x i16> @llvm.x86.sse2.packssdw.128(<4 x i32> <i32 0, i32 -1, i32 65536, i32 -131072>, <4 x i32> zeroinitializer) +; CHECK-NEXT: ret <8 x i16> [[TMP1]] +; + %1 = call <8 x i16> @llvm.x86.sse2.packssdw.128(<4 x i32> <i32 0, i32 -1, i32 65536, i32 -131072>, <4 x i32> zeroinitializer) + ret <8 x i16> %1 +} + +define <8 x i16> @fold_packusdw_128() { +; CHECK-LABEL: @fold_packusdw_128( +; CHECK-NEXT: [[TMP1:%.*]] = call <8 x i16> @llvm.x86.sse41.packusdw(<4 x i32> undef, <4 x i32> <i32 0, i32 -1, i32 32768, i32 65537>) +; CHECK-NEXT: ret <8 x i16> [[TMP1]] +; + %1 = call <8 x i16> @llvm.x86.sse41.packusdw(<4 x i32> undef, <4 x i32> <i32 0, i32 -1, i32 32768, i32 65537>) + ret <8 x i16> %1 +} + +define <16 x i8> @fold_packsswb_128() { +; CHECK-LABEL: @fold_packsswb_128( +; CHECK-NEXT: [[TMP1:%.*]] = call <16 x i8> @llvm.x86.sse2.packsswb.128(<8 x i16> zeroinitializer, <8 x i16> undef) +; CHECK-NEXT: ret <16 x i8> [[TMP1]] +; + %1 = call <16 x i8> @llvm.x86.sse2.packsswb.128(<8 x i16> zeroinitializer, <8 x i16> undef) + ret <16 x i8> %1 +} + +define <16 x i8> @fold_packuswb_128() { +; CHECK-LABEL: @fold_packuswb_128( +; CHECK-NEXT: [[TMP1:%.*]] = call <16 x i8> @llvm.x86.sse2.packuswb.128(<8 x i16> <i16 0, i16 1, i16 -1, i16 255, i16 -1, i16 -32768, i16 -127, i16 15>, <8 x i16> <i16 -15, i16 127, i16 -32768, i16 1, i16 -255, i16 1, i16 -1, i16 0>) +; CHECK-NEXT: ret <16 x i8> [[TMP1]] +; + %1 = call <16 x i8> @llvm.x86.sse2.packuswb.128(<8 x i16> <i16 0, i16 1, i16 -1, i16 255, i16 65535, i16 -32768, i16 -127, i16 15>, <8 x i16> <i16 -15, i16 127, i16 32768, i16 -65535, i16 -255, i16 1, i16 -1, i16 0>) + ret <16 x i8> %1 +} + +define <16 x i16> @fold_packssdw_256() { +; CHECK-LABEL: @fold_packssdw_256( +; CHECK-NEXT: [[TMP1:%.*]] = call <16 x i16> @llvm.x86.avx2.packssdw(<8 x i32> <i32 0, i32 256, i32 65535, i32 -65536, i32 -127, i32 -32768, i32 -32767, i32 32767>, <8 x i32> undef) +; CHECK-NEXT: ret <16 x i16> [[TMP1]] +; + %1 = call <16 x i16> @llvm.x86.avx2.packssdw(<8 x i32> <i32 0, i32 256, i32 65535, i32 -65536, i32 -127, i32 -32768, i32 -32767, i32 32767>, <8 x i32> undef) + ret <16 x i16> %1 +} + +define <16 x i16> @fold_packusdw_256() { +; CHECK-LABEL: @fold_packusdw_256( +; CHECK-NEXT: [[TMP1:%.*]] = call <16 x i16> @llvm.x86.avx2.packusdw(<8 x i32> <i32 0, i32 -256, i32 -65535, i32 65536, i32 127, i32 32768, i32 32767, i32 -32767>, <8 x i32> <i32 0, i32 256, i32 65535, i32 -65536, i32 -127, i32 -32768, i32 -32767, i32 32767>) +; CHECK-NEXT: ret <16 x i16> [[TMP1]] +; + %1 = call <16 x i16> @llvm.x86.avx2.packusdw(<8 x i32> <i32 0, i32 -256, i32 -65535, i32 65536, i32 127, i32 32768, i32 32767, i32 -32767>, <8 x i32> <i32 0, i32 256, i32 65535, i32 -65536, i32 -127, i32 -32768, i32 -32767, i32 32767>) + ret <16 x i16> %1 +} + +define <32 x i8> @fold_packsswb_256() { +; CHECK-LABEL: @fold_packsswb_256( +; CHECK-NEXT: [[TMP1:%.*]] = call <32 x i8> @llvm.x86.avx2.packsswb(<16 x i16> undef, <16 x i16> zeroinitializer) +; CHECK-NEXT: ret <32 x i8> [[TMP1]] +; + %1 = call <32 x i8> @llvm.x86.avx2.packsswb(<16 x i16> undef, <16 x i16> zeroinitializer) + ret <32 x i8> %1 +} + +define <32 x i8> @fold_packuswb_256() { +; CHECK-LABEL: @fold_packuswb_256( +; CHECK-NEXT: [[TMP1:%.*]] = call <32 x i8> @llvm.x86.avx2.packuswb(<16 x i16> zeroinitializer, <16 x i16> <i16 0, i16 -127, i16 -128, i16 -32768, i16 0, i16 255, i16 256, i16 512, i16 -1, i16 1, i16 2, i16 4, i16 8, i16 16, i16 32, i16 64>) +; CHECK-NEXT: ret <32 x i8> [[TMP1]] +; + %1 = call <32 x i8> @llvm.x86.avx2.packuswb(<16 x i16> zeroinitializer, <16 x i16> <i16 0, i16 -127, i16 -128, i16 -32768, i16 65536, i16 255, i16 256, i16 512, i16 -1, i16 1, i16 2, i16 4, i16 8, i16 16, i16 32, i16 64>) + ret <32 x i8> %1 +} + +; ; Demanded Elts ; |

