File: volatile_load_cast.ll

package info (click to toggle)
llvm-toolchain-11 1%3A11.0.1-2
  • links: PTS, VCS
  • area: main
  • in suites: bullseye
  • size: 995,808 kB
  • sloc: cpp: 4,767,656; ansic: 760,916; asm: 477,436; python: 170,940; objc: 69,804; lisp: 29,914; sh: 23,855; f90: 18,173; pascal: 7,551; perl: 7,471; ml: 5,603; awk: 3,489; makefile: 2,573; xml: 915; cs: 573; fortran: 503; javascript: 452
file content (59 lines) | stat: -rw-r--r-- 2,078 bytes parent folder | download | duplicates (8)
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
; RUN: opt < %s -instcombine -S | FileCheck %s

; Ensure that volatile loads followed by a bitcast don't get transformed into a
; volatile load of the bitcast-target type. This is unlikely to provide much in
; terms of optimizations, and might break the programmer's expectation for code
; generation, however brittle that expectation might be.
;
; See llvm.org/D75644 and llvm.org/D75505
target datalayout = "e-p:64:64-i32:32:32-i64:64:64-f32:32:32-f64:64:64"

define float @float_load(i32* %addr) {
; CHECK-LABEL: @float_load(
; CHECK:         %i32 = load volatile i32, i32* %addr, align 4
; CHECK-NEXT:    %float = bitcast i32 %i32 to float
; CHECK-NEXT:    ret float %float
  %i32 = load volatile i32, i32* %addr, align 4
  %float = bitcast i32 %i32 to float
  ret float %float
}

define i32 @i32_load(float* %addr) {
; CHECK-LABEL: @i32_load(
; CHECK:         %float = load volatile float, float* %addr, align 4
; CHECK-NEXT:    %i32 = bitcast float %float to i32
; CHECK-NEXT:    ret i32 %i32
  %float = load volatile float, float* %addr, align 4
  %i32 = bitcast float %float to i32
  ret i32 %i32
}

define double @double_load(i64* %addr) {
; CHECK-LABEL: @double_load(
; CHECK:         %i64 = load volatile i64, i64* %addr, align 8
; CHECK-NEXT:    %double = bitcast i64 %i64 to double
; CHECK-NEXT:    ret double %double
  %i64 = load volatile i64, i64* %addr, align 8
  %double = bitcast i64 %i64 to double
  ret double %double
}

define i64 @i64_load(double* %addr) {
; CHECK-LABEL: @i64_load(
; CHECK:         %double = load volatile double, double* %addr, align 8
; CHECK-NEXT:    %i64 = bitcast double %double to i64
; CHECK-NEXT:    ret i64 %i64
  %double = load volatile double, double* %addr, align 8
  %i64 = bitcast double %double to i64
  ret i64 %i64
}

define i8* @ptr_load(i64* %addr) {
; CHECK-LABEL: @ptr_load(
; CHECK:         %i64 = load volatile i64, i64* %addr, align 8
; CHECK-NEXT:    %ptr = inttoptr i64 %i64 to i8*
; CHECK-NEXT:    ret i8* %ptr
  %i64 = load volatile i64, i64* %addr, align 8
  %ptr = inttoptr i64 %i64 to i8*
  ret i8* %ptr
}