1; RUN: llc -mtriple=x86_64-linux-gnu -global-isel -verify-machineinstrs < %s -o - | FileCheck %s --check-prefix=X64 2 3define i16 @test_shl_i4(i16 %v, i16 %a, i16 %b) { 4; Let's say the arguments are the following unsigned 5; integers in two’s complement representation: 6; 7; %v: 77 (0000 0000 0100 1101) 8; %a: 74 (0000 0000 0100 1010) 9; %b: 72 (0000 0000 0100 1000) 10 %v.t = trunc i16 %v to i4 ; %v.t: 13 (1101) 11 %a.t = trunc i16 %a to i4 ; %a.t: 10 (1010) 12 %b.t = trunc i16 %b to i4 ; %b.t: 8 (1000) 13 %n.t = add i4 %a.t, %b.t ; %n.t: 2 (0010) 14 %r.t = shl i4 %v.t, %n.t ; %r.t: 4 (0100) 15 %r = zext i4 %r.t to i16 16; %r: 4 (0000 0000 0000 0100) 17 ret i16 %r 18 19; X64-LABEL: test_shl_i4 20; 21; %di: 77 (0000 0000 0100 1101) 22; %si: 74 (0000 0000 0100 1010) 23; %dx: 72 (0000 0000 0100 1000) 24; 25; X64: # %bb.0: 26; 27; X64-NEXT: addb %sil, %dl 28; %dx: 146 (0000 0000 1001 0010) 29; 30; X64-NEXT: andb $15, %dl 31; %dx: 2 (0000 0000 0000 0010) 32; 33; X64-NEXT: movl %edx, %ecx 34; %cx: 2 (0000 0000 0000 0010) 35; 36; X64-NEXT: shlb %cl, %dil 37; %di: 52 (0000 0000 0011 0100) 38; 39; X64-NEXT: andw $15, %di 40; %di: 4 (0000 0000 0000 0100) 41; 42; X64-NEXT: movl %edi, %eax 43; %ax: 4 (0000 0000 0000 0100) 44; 45; X64-NEXT: retq 46; 47; Let's pretend that legalizing G_SHL by widening its second 48; source operand is done via G_ANYEXT rather than G_ZEXT and 49; see what happens: 50; 51; addb %sil, %dl 52; %dx: 146 (0000 0000 1001 0010) 53; 54; movl %edx, %ecx 55; %cx: 146 (0000 0000 1001 0010) 56; 57; shlb %cl, %dil 58; %di: 0 (0000 0000 0000 0000) 59; 60; andw $15, %di 61; %di: 0 (0000 0000 0000 0000) 62; 63; movl %edi, %eax 64; %ax: 0 (0000 0000 0000 0000) 65; 66; retq 67} 68