90 lines · plain
1; NOTE: Assertions have been autogenerated by utils/update_test_checks.py2; RUN: opt < %s -passes=aggressive-instcombine -S | FileCheck %s3 4define <4 x i16> @shuffle(<2 x i8> %a, <2 x i8> %b) {5; CHECK-LABEL: @shuffle(6; CHECK-NEXT: [[ZEXTA:%.*]] = zext <2 x i8> [[A:%.*]] to <2 x i32>7; CHECK-NEXT: [[ZEXTB:%.*]] = zext <2 x i8> [[B:%.*]] to <2 x i32>8; CHECK-NEXT: [[SHUF:%.*]] = shufflevector <2 x i32> [[ZEXTA]], <2 x i32> [[ZEXTB]], <4 x i32> <i32 3, i32 2, i32 1, i32 0>9; CHECK-NEXT: [[TRUNC:%.*]] = trunc <4 x i32> [[SHUF]] to <4 x i16>10; CHECK-NEXT: ret <4 x i16> [[TRUNC]]11;12 %zexta = zext <2 x i8> %a to <2 x i32>13 %zextb = zext <2 x i8> %b to <2 x i32>14 %shuf = shufflevector <2 x i32> %zexta, <2 x i32> %zextb, <4 x i32> <i32 3, i32 2, i32 1, i32 0>15 %trunc = trunc <4 x i32> %shuf to <4 x i16>16 ret <4 x i16> %trunc17}18 19define <2 x i16> @unary_shuffle(<2 x i8> %a) {20; CHECK-LABEL: @unary_shuffle(21; CHECK-NEXT: [[ZEXTA:%.*]] = zext <2 x i8> [[A:%.*]] to <2 x i32>22; CHECK-NEXT: [[SHUF:%.*]] = shufflevector <2 x i32> [[ZEXTA]], <2 x i32> poison, <2 x i32> <i32 1, i32 0>23; CHECK-NEXT: [[TRUNC:%.*]] = trunc <2 x i32> [[SHUF]] to <2 x i16>24; CHECK-NEXT: ret <2 x i16> [[TRUNC]]25;26 %zexta = zext <2 x i8> %a to <2 x i32>27 %shuf = shufflevector <2 x i32> %zexta, <2 x i32> poison, <2 x i32> <i32 1, i32 0>28 %trunc = trunc <2 x i32> %shuf to <2 x i16>29 ret <2 x i16> %trunc30}31 32define <4 x i16> @const_shuffle() {33; CHECK-LABEL: @const_shuffle(34; CHECK-NEXT: [[SHUF:%.*]] = shufflevector <2 x i32> <i32 1, i32 2>, <2 x i32> <i32 3, i32 7>, <4 x i32> <i32 3, i32 2, i32 1, i32 0>35; CHECK-NEXT: [[TRUNC:%.*]] = trunc <4 x i32> [[SHUF]] to <4 x i16>36; CHECK-NEXT: ret <4 x i16> [[TRUNC]]37;38 %shuf = shufflevector <2 x i32> <i32 1, i32 2>, <2 x i32> <i32 3, i32 7>, <4 x i32> <i32 3, i32 2, i32 1, i32 0>39 %trunc = trunc <4 x i32> %shuf to <4 x i16>40 ret <4 x i16> %trunc41}42 43 44define <2 x i16> @extract_insert(<2 x i8> %a, <2 x i8> %b) {45; CHECK-LABEL: @extract_insert(46; CHECK-NEXT: [[ZEXTA:%.*]] = zext <2 x i8> [[A:%.*]] to <2 x i16>47; CHECK-NEXT: [[ZEXTB:%.*]] = zext <2 x i8> [[B:%.*]] to <2 x i16>48; CHECK-NEXT: [[EXTR:%.*]] = extractelement <2 x i16> [[ZEXTA]], i32 049; CHECK-NEXT: [[INSR:%.*]] = insertelement <2 x i16> [[ZEXTB]], i16 [[EXTR]], i32 150; CHECK-NEXT: ret <2 x i16> [[INSR]]51;52 %zexta = zext <2 x i8> %a to <2 x i32>53 %zextb = zext <2 x i8> %b to <2 x i32>54 %extr = extractelement <2 x i32> %zexta, i32 055 %insr = insertelement <2 x i32> %zextb, i32 %extr, i32 156 %trunc = trunc <2 x i32> %insr to <2 x i16>57 ret <2 x i16> %trunc58}59 60define <2 x i16> @insert_poison(i8 %a) {61; CHECK-LABEL: @insert_poison(62; CHECK-NEXT: [[ZEXTA:%.*]] = zext i8 [[A:%.*]] to i1663; CHECK-NEXT: [[INSR:%.*]] = insertelement <2 x i16> poison, i16 [[ZEXTA]], i32 064; CHECK-NEXT: ret <2 x i16> [[INSR]]65;66 %zexta = zext i8 %a to i3267 %insr = insertelement <2 x i32> poison, i32 %zexta, i32 068 %trunc = trunc <2 x i32> %insr to <2 x i16>69 ret <2 x i16> %trunc70}71 72; This demonstrates test not folded by 'opt -instcombine'73define <2 x i16> @extract_mul_insert(<2 x i8> %x) {74; CHECK-LABEL: @extract_mul_insert(75; CHECK-NEXT: [[ZEXT:%.*]] = zext <2 x i8> [[X:%.*]] to <2 x i16>76; CHECK-NEXT: [[LSHR:%.*]] = lshr <2 x i16> [[ZEXT]], <i16 4, i16 5>77; CHECK-NEXT: [[EXTR:%.*]] = extractelement <2 x i16> [[LSHR]], i32 178; CHECK-NEXT: [[MUL:%.*]] = mul i16 [[EXTR]], 579; CHECK-NEXT: [[INSR:%.*]] = insertelement <2 x i16> [[LSHR]], i16 [[MUL]], i32 180; CHECK-NEXT: ret <2 x i16> [[INSR]]81;82 %zext = zext <2 x i8> %x to <2 x i32>83 %lshr = lshr <2 x i32> %zext, <i32 4, i32 5>84 %extr = extractelement <2 x i32> %lshr, i32 185 %mul = mul i32 %extr, 586 %insr = insertelement <2 x i32> %lshr, i32 %mul, i32 187 %trunc = trunc <2 x i32> %insr to <2 x i16>88 ret <2 x i16> %trunc89}90