File: load-gep-overalign.ll

package info (click to toggle)
llvm-toolchain-17 1%3A17.0.6-22
  • links: PTS, VCS
  • area: main
  • in suites: forky, sid, trixie
  • size: 1,799,624 kB
  • sloc: cpp: 6,428,607; ansic: 1,383,196; asm: 793,408; python: 223,504; objc: 75,364; f90: 60,502; lisp: 33,869; pascal: 15,282; sh: 9,684; perl: 7,453; ml: 4,937; awk: 3,523; makefile: 2,889; javascript: 2,149; xml: 888; fortran: 619; cs: 573
file content (69 lines) | stat: -rw-r--r-- 2,732 bytes parent folder | download | duplicates (10)
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
56
57
58
59
60
61
62
63
64
65
66
67
68
69
; NOTE: Assertions have been autogenerated by utils/update_test_checks.py
; RUN: opt                        -passes=instcombine -S %s | FileCheck %s --check-prefix=NATURAL
; RUN: opt --data-layout="i16:32" -passes=instcombine -S %s | FileCheck %s --check-prefix=OVERALIGNED

; The data layouts are little endian, so @foo is 0x0123456789ABCDEF in memory.
@foo = constant <4 x i16> <i16 u0x2301, i16 u0x6745, i16 u0xAB89, i16 u0xEFCD>, align 8

declare void @report(i64 %index, i8 %val)

define void @test_vector_load_i8() {
; Access and report each individual byte in @foo.
; OVERALIGNED and NATURAL should have the same result, because the layout of vectors ignores
; element type alignment, and thus the representation of @foo is the same in both cases.
; NATURAL-LABEL: @test_vector_load_i8(
; NATURAL-NEXT:    call void @report(i64 0, i8 1)
; NATURAL-NEXT:    call void @report(i64 1, i8 35)
; NATURAL-NEXT:    call void @report(i64 2, i8 69)
; NATURAL-NEXT:    call void @report(i64 3, i8 103)
; NATURAL-NEXT:    call void @report(i64 4, i8 -119)
; NATURAL-NEXT:    call void @report(i64 5, i8 -85)
; NATURAL-NEXT:    call void @report(i64 6, i8 -51)
; NATURAL-NEXT:    call void @report(i64 7, i8 -17)
; NATURAL-NEXT:    ret void
;
; OVERALIGNED-LABEL: @test_vector_load_i8(
; OVERALIGNED-NEXT:    call void @report(i64 0, i8 1)
; OVERALIGNED-NEXT:    call void @report(i64 1, i8 35)
; OVERALIGNED-NEXT:    call void @report(i64 2, i8 69)
; OVERALIGNED-NEXT:    call void @report(i64 3, i8 103)
; OVERALIGNED-NEXT:    call void @report(i64 4, i8 -119)
; OVERALIGNED-NEXT:    call void @report(i64 5, i8 -85)
; OVERALIGNED-NEXT:    call void @report(i64 6, i8 -51)
; OVERALIGNED-NEXT:    call void @report(i64 7, i8 -17)
; OVERALIGNED-NEXT:    ret void
;
  %ptr0 = getelementptr i8, ptr @foo, i64 0
  %res0 = load i8, ptr %ptr0, align 1
  call void @report(i64 0, i8 %res0)

  %ptr1 = getelementptr i8, ptr @foo, i64 1
  %res1 = load i8, ptr %ptr1, align 1
  call void @report(i64 1, i8 %res1)

  %ptr2 = getelementptr i8, ptr @foo, i64 2
  %res2 = load i8, ptr %ptr2, align 1
  call void @report(i64 2, i8 %res2)

  %ptr3 = getelementptr i8, ptr @foo, i64 3
  %res3 = load i8, ptr %ptr3, align 1
  call void @report(i64 3, i8 %res3)

  %ptr4 = getelementptr i8, ptr @foo, i64 4
  %res4 = load i8, ptr %ptr4, align 1
  call void @report(i64 4, i8 %res4)

  %ptr5 = getelementptr i8, ptr @foo, i64 5
  %res5 = load i8, ptr %ptr5, align 1
  call void @report(i64 5, i8 %res5)

  %ptr6 = getelementptr i8, ptr @foo, i64 6
  %res6 = load i8, ptr %ptr6, align 1
  call void @report(i64 6, i8 %res6)

  %ptr7 = getelementptr i8, ptr @foo, i64 7
  %res7 = load i8, ptr %ptr7, align 1
  call void @report(i64 7, i8 %res7)

  ret void
}