File: shl-scalar-widening.ll

package info (click to toggle)
llvm-toolchain-14 1%3A14.0.6-12
  • links: PTS, VCS
  • area: main
  • in suites: bookworm
  • size: 1,496,180 kB
  • sloc: cpp: 5,593,972; ansic: 986,872; asm: 585,869; python: 184,223; objc: 72,530; lisp: 31,119; f90: 27,793; javascript: 9,780; pascal: 9,762; sh: 9,482; perl: 7,468; ml: 5,432; awk: 3,523; makefile: 2,538; xml: 953; cs: 573; fortran: 567
file content (55 lines) | stat: -rw-r--r-- 1,984 bytes parent folder | download | duplicates (21)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
; NOTE: Assertions have been autogenerated by utils/update_llc_test_checks.py
; RUN: llc -mtriple=x86_64-linux-gnu -global-isel -verify-machineinstrs < %s -o - | FileCheck %s --check-prefix=X64

define i16 @test_shl_i4(i16 %v, i16 %a, i16 %b) {
; Let's say the arguments are the following unsigned
; integers in two’s complement representation:
;
; %v: 77 (0000 0000  0100 1101)
; %a: 74 (0000 0000  0100 1010)
; %b: 72 (0000 0000  0100 1000)
; X64-LABEL: test_shl_i4:
; X64:       # %bb.0:
; X64-NEXT:    # kill: def $esi killed $esi def $rsi
; X64-NEXT:    # kill: def $edx killed $edx def $rdx
; X64-NEXT:    leal (%rdx,%rsi), %ecx
; X64-NEXT:    andb $15, %cl
; X64-NEXT:    # kill: def $cl killed $cl killed $ecx
; X64-NEXT:    shlb %cl, %dil
; X64-NEXT:    movzbl %dil, %eax
; X64-NEXT:    andw $15, %ax
; X64-NEXT:    # kill: def $ax killed $ax killed $eax
; X64-NEXT:    retq
  %v.t = trunc i16 %v to i4  ; %v.t: 13 (1101)
  %a.t = trunc i16 %a to i4  ; %a.t: 10 (1010)
  %b.t = trunc i16 %b to i4  ; %b.t:  8 (1000)
  %n.t = add i4 %a.t, %b.t   ; %n.t:  2 (0010)
  %r.t = shl i4 %v.t, %n.t   ; %r.t:  4 (0100)
  %r = zext i4 %r.t to i16
; %r:  4 (0000 0000 0000 0100)
  ret i16 %r

; %di:  77 (0000 0000  0100 1101)
; %si:  74 (0000 0000  0100 1010)
; %dx:  72 (0000 0000  0100 1000)
; %dx: 146 (0000 0000  1001 0010)
; %dx:   2 (0000 0000  0000 0010)
; %cx:   2 (0000 0000  0000 0010)
; %di:  52 (0000 0000  0011 0100)
; %di:   4 (0000 0000  0000 0100)
; %ax:   4 (0000 0000  0000 0100)
; Let's pretend that legalizing G_SHL by widening its second
; source operand is done via G_ANYEXT rather than G_ZEXT and
; see what happens:
;              addb %sil, %dl
; %dx: 146 (0000 0000  1001 0010)
;              movl %edx, %ecx
; %cx: 146 (0000 0000  1001 0010)
;              shlb %cl, %dil
; %di:   0 (0000 0000  0000 0000)
;              andw $15, %di
; %di:   0 (0000 0000  0000 0000)
;              movl %edi, %eax
; %ax:   0 (0000 0000  0000 0000)
;              retq
}