File: merge-store-partially-alias-loads.ll

package info (click to toggle)
llvm-toolchain-19 1%3A19.1.7-3
  • links: PTS, VCS
  • area: main
  • in suites: forky, sid, trixie
  • size: 1,998,520 kB
  • sloc: cpp: 6,951,680; ansic: 1,486,157; asm: 913,598; python: 232,024; f90: 80,126; objc: 75,281; lisp: 37,276; pascal: 16,990; sh: 10,009; ml: 5,058; perl: 4,724; awk: 3,523; makefile: 3,167; javascript: 2,504; xml: 892; fortran: 664; cs: 573
file content (52 lines) | stat: -rw-r--r-- 2,298 bytes parent folder | download | duplicates (7)
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
; REQUIRES: asserts
; RUN: llc -mtriple=x86_64-unknown-linux-gnu < %s | FileCheck -check-prefix=X86 %s
; RUN: llc -mtriple=x86_64-unknown-linux-gnu -debug-only=isel < %s -o /dev/null 2>&1 | FileCheck -check-prefix=DBGDAG %s

; It's OK to merge the load / store of the first 2 components, but
; they must not be placed on the same chain after merging.

; X86-LABEL: {{^}}merge_store_partial_overlap_load:
; X86-DAG: movzwl ([[BASEREG:%[a-z]+]]), %e[[LO2:[a-z]+]]
; X86-DAG: movzbl 2([[BASEREG]]), %e[[HI1:[a-z]]]

; X86-NEXT: movw %[[LO2]], 1([[BASEREG]])
; X86-NEXT: movb %[[HI1]]l, 3([[BASEREG]])
; X86-NEXT: retq

; DBGDAG-LABEL: Optimized legalized selection DAG: %bb.0 'merge_store_partial_overlap_load:'
; DBGDAG: [[ENTRYTOKEN:t[0-9]+]]: ch,glue = EntryToken
; DBGDAG-DAG: [[BASEPTR:t[0-9]+]]: i64,ch = CopyFromReg [[ENTRYTOKEN]],
; DBGDAG-DAG: [[ADDPTR:t[0-9]+]]: i64 = add {{(nuw )?}}[[BASEPTR]], Constant:i64<2>

; DBGDAG-DAG: [[LD2:t[0-9]+]]: i16,ch = load<(load (s16) from %ir.tmp81, align 1)> [[ENTRYTOKEN]], [[BASEPTR]], undef:i64
; DBGDAG-DAG: [[LD1:t[0-9]+]]: i8,ch = load<(load (s8) from %ir.tmp12)> [[ENTRYTOKEN]], [[ADDPTR]], undef:i64

; DBGDAG-DAG: [[ST1:t[0-9]+]]: ch = store<(store (s8) into %ir.tmp14)> [[ENTRYTOKEN]], [[LD1]], t{{[0-9]+}}, undef:i64
; DBGDAG-DAG: [[LOADTOKEN:t[0-9]+]]: ch = TokenFactor [[LD2]]:1, [[LD1]]:1
; DBGDAG-DAG: [[ST2:t[0-9]+]]: ch = store<(store (s16) into %ir.tmp10, align 1)> [[LOADTOKEN]], [[LD2]], t{{[0-9]+}}, undef:i64

; DBGDAG: X86ISD::RET_GLUE t{{[0-9]+}},

; DBGDAG-LABEL: Instruction selection begins
define void @merge_store_partial_overlap_load(ptr %tmp) {
  %tmp8 = getelementptr inbounds [4 x i8], ptr %tmp, i32 0, i8 0
  %tmp10 = getelementptr inbounds [4 x i8], ptr %tmp, i32 0, i8 1
  %tmp12 = getelementptr inbounds [4 x i8], ptr %tmp, i32 0, i8 2
  %tmp14 = getelementptr [4 x i8], ptr %tmp, i32 0, i8 3

  %tmp9 = load i8, ptr %tmp8, align 1   ; base + 0
  %tmp11 = load i8, ptr %tmp10, align 1 ; base + 1
  %tmp13 = load i8, ptr %tmp12, align 1 ; base + 2

  store i8 %tmp9, ptr %tmp10, align 1   ; base + 1
  store i8 %tmp11, ptr %tmp12, align 1  ; base + 2
  store i8 %tmp13, ptr %tmp14, align 1  ; base + 3

; Should emit
; load base + 0, base + 1
; store base + 1, base + 2
; load base + 2
; store base + 3

  ret void
}