1; NOTE: Assertions have been autogenerated by utils/update_test_checks.py 2; RUN: opt < %s -instcombine -S | FileCheck %s 3 4target datalayout = "e-p:64:64:64-i1:8:8-i8:8:8-i16:16:16-i32:32:32-i64:64:64-f32:32:32-f64:64:64-v64:64:64-v128:128:128-a0:0:64-s0:64:64-f80:128:128" 5 6define i16 @test1(i16 %a) { 7; CHECK-LABEL: @test1( 8; CHECK-NEXT: [[C:%.*]] = lshr i16 [[A:%.*]], 8 9; CHECK-NEXT: [[D:%.*]] = mul i16 [[A]], 5 10; CHECK-NEXT: [[E:%.*]] = or i16 [[C]], [[D]] 11; CHECK-NEXT: ret i16 [[E]] 12; 13 %b = zext i16 %a to i32 ; <i32> [#uses=2] 14 %c = lshr i32 %b, 8 ; <i32> [#uses=1] 15 %d = mul i32 %b, 5 ; <i32> [#uses=1] 16 %e = or i32 %c, %d ; <i32> [#uses=1] 17 %f = trunc i32 %e to i16 ; <i16> [#uses=1] 18 ret i16 %f 19} 20 21define <2 x i16> @test1_vec(<2 x i16> %a) { 22; CHECK-LABEL: @test1_vec( 23; CHECK-NEXT: [[C:%.*]] = lshr <2 x i16> [[A:%.*]], <i16 8, i16 8> 24; CHECK-NEXT: [[D:%.*]] = mul <2 x i16> [[A]], <i16 5, i16 5> 25; CHECK-NEXT: [[E:%.*]] = or <2 x i16> [[C]], [[D]] 26; CHECK-NEXT: ret <2 x i16> [[E]] 27; 28 %b = zext <2 x i16> %a to <2 x i32> 29 %c = lshr <2 x i32> %b, <i32 8, i32 8> 30 %d = mul <2 x i32> %b, <i32 5, i32 5> 31 %e = or <2 x i32> %c, %d 32 %f = trunc <2 x i32> %e to <2 x i16> 33 ret <2 x i16> %f 34} 35 36define <2 x i16> @test1_vec_nonuniform(<2 x i16> %a) { 37; CHECK-LABEL: @test1_vec_nonuniform( 38; CHECK-NEXT: [[C:%.*]] = lshr <2 x i16> [[A:%.*]], <i16 8, i16 9> 39; CHECK-NEXT: [[D:%.*]] = mul <2 x i16> [[A]], <i16 5, i16 6> 40; CHECK-NEXT: [[E:%.*]] = or <2 x i16> [[C]], [[D]] 41; CHECK-NEXT: ret <2 x i16> [[E]] 42; 43 %b = zext <2 x i16> %a to <2 x i32> 44 %c = lshr <2 x i32> %b, <i32 8, i32 9> 45 %d = mul <2 x i32> %b, <i32 5, i32 6> 46 %e = or <2 x i32> %c, %d 47 %f = trunc <2 x i32> %e to <2 x i16> 48 ret <2 x i16> %f 49} 50 51define <2 x i16> @test1_vec_undef(<2 x i16> %a) { 52; CHECK-LABEL: @test1_vec_undef( 53; CHECK-NEXT: [[B:%.*]] = zext <2 x i16> [[A:%.*]] to <2 x i32> 54; CHECK-NEXT: [[C:%.*]] = lshr <2 x i32> [[B]], <i32 8, i32 undef> 55; CHECK-NEXT: [[D:%.*]] = mul <2 x i32> [[B]], <i32 5, i32 undef> 56; CHECK-NEXT: [[E:%.*]] = or <2 x i32> [[C]], [[D]] 57; CHECK-NEXT: [[F:%.*]] = trunc <2 x i32> [[E]] to <2 x i16> 58; CHECK-NEXT: ret <2 x i16> [[F]] 59; 60 %b = zext <2 x i16> %a to <2 x i32> 61 %c = lshr <2 x i32> %b, <i32 8, i32 undef> 62 %d = mul <2 x i32> %b, <i32 5, i32 undef> 63 %e = or <2 x i32> %c, %d 64 %f = trunc <2 x i32> %e to <2 x i16> 65 ret <2 x i16> %f 66} 67