File: bitcast.ll

package info (click to toggle)
llvm-toolchain-16 1%3A16.0.6-15~deb12u1
  • links: PTS, VCS
  • area: main
  • in suites: bookworm
  • size: 1,634,792 kB
  • sloc: cpp: 6,179,261; ansic: 1,216,205; asm: 741,319; python: 196,614; objc: 75,325; f90: 49,640; lisp: 32,396; pascal: 12,286; sh: 9,394; perl: 7,442; ml: 5,494; awk: 3,523; makefile: 2,723; javascript: 1,206; xml: 886; fortran: 581; cs: 573
file content (96 lines) | stat: -rw-r--r-- 3,402 bytes parent folder | download | duplicates (6)
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
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
; NOTE: Assertions have been autogenerated by utils/update_test_checks.py
; RUN: opt < %s -passes=instsimplify -S | FileCheck %s
; PR2165

define <1 x i64> @test1() {
; CHECK-LABEL: @test1(
; CHECK-NEXT:    ret <1 x i64> <i64 63>
;
  %A = bitcast i64 63 to <1 x i64>
  ret <1 x i64> %A
}

; Ensure that a FP source operand isn't propagated to an icmp.

@a = external global i16, align 1
@b = external global i16, align 1

define i1 @bad_icmp_constexpr_bitcast() {
; CHECK-LABEL: @bad_icmp_constexpr_bitcast(
; CHECK-NEXT:    [[FADD:%.*]] = fadd float bitcast (i32 ptrtoint (ptr @b to i32) to float), 2.000000e+00
; CHECK-NEXT:    [[BITCAST:%.*]] = bitcast float [[FADD]] to i32
; CHECK-NEXT:    [[CMP:%.*]] = icmp eq i32 ptrtoint (ptr @a to i32), [[BITCAST]]
; CHECK-NEXT:    ret i1 [[CMP]]
;
  %fadd = fadd float bitcast (i32 ptrtoint (ptr @b to i32) to float), 2.0
  %bitcast = bitcast float %fadd to i32
  %cmp = icmp eq i32 ptrtoint (ptr @a to i32), %bitcast
  ret i1 %cmp
}

; Ensure that an integer source operand isn't propagated to a fcmp.

@c = external global i16, align 1
@d = external global i16, align 1

define i1 @bad_fcmp_constexpr_bitcast() {
; CHECK-LABEL: @bad_fcmp_constexpr_bitcast(
; CHECK-NEXT:    ret i1 fcmp oeq (float bitcast (i32 ptrtoint (ptr @c to i32) to float), float bitcast (i32 add (i32 ptrtoint (ptr @d to i32), i32 2) to float))
;
  %cmp = fcmp oeq float bitcast (i32 ptrtoint (ptr @c to i32) to float), bitcast (i32 add (i32 ptrtoint (ptr @d to i32), i32 2) to float)
  ret i1 %cmp
}

; Ensure that an "ordered and equal" fcmp of a ConstantExpr to itself is not folded, since the ConstantExpr may be a NaN.

define i1 @fcmp_constexpr_oeq(float %conv) {
; CHECK-LABEL: @fcmp_constexpr_oeq(
; CHECK-NEXT:    ret i1 fcmp oeq (float bitcast (i32 ptrtoint (ptr @a to i32) to float), float bitcast (i32 ptrtoint (ptr @a to i32) to float))
;
  %cmp = fcmp oeq float bitcast (i32 ptrtoint (ptr @a to i32) to float), bitcast (i32 ptrtoint (ptr @a to i32) to float)
  ret i1 %cmp
}

; Ensure that an "unordered or not equal" fcmp of a ConstantExpr to itself is not folded, since the ConstantExpr may be a NaN.

define i1 @fcmp_constexpr_une(float %conv) {
; CHECK-LABEL: @fcmp_constexpr_une(
; CHECK-NEXT:    ret i1 fcmp une (float bitcast (i32 ptrtoint (ptr @a to i32) to float), float bitcast (i32 ptrtoint (ptr @a to i32) to float))
;
  %cmp = fcmp une float bitcast (i32 ptrtoint (ptr @a to i32) to float), bitcast (i32 ptrtoint (ptr @a to i32) to float)
  ret i1 %cmp
}

define i1 @fcmp_constexpr_ueq(float %conv) {
; CHECK-LABEL: @fcmp_constexpr_ueq(
; CHECK-NEXT:    ret i1 true
;
  %cmp = fcmp ueq float bitcast (i32 ptrtoint (ptr @a to i32) to float), bitcast (i32 ptrtoint (ptr @a to i32) to float)
  ret i1 %cmp
}

define i1 @fcmp_constexpr_one(float %conv) {
; CHECK-LABEL: @fcmp_constexpr_one(
; CHECK-NEXT:    ret i1 false
;
  %cmp = fcmp one float bitcast (i32 ptrtoint (ptr @a to i32) to float), bitcast (i32 ptrtoint (ptr @a to i32) to float)
  ret i1 %cmp
}

%T = type { i8 }
@G = external global %T

define ptr @bitcast_to_gep() {
; CHECK-LABEL: @bitcast_to_gep(
; CHECK-NEXT:    ret ptr @G
;
  ret ptr @G
}

define ptr addrspace(1) @addrspacecast_to_gep() {
; CHECK-LABEL: @addrspacecast_to_gep(
; CHECK-NEXT:    ret ptr addrspace(1) addrspacecast (ptr @G to ptr addrspace(1))
;
  %p = addrspacecast ptr @G to ptr addrspace(1)
  ret ptr addrspace(1) %p
}