1 ; NOTE: Assertions have been autogenerated by utils/update_test_checks.py
2 ; RUN: opt < %s -passes=instsimplify -S | FileCheck %s
5 define <1 x i64> @test1() {
7 ; CHECK-NEXT: ret <1 x i64> <i64 63>
9 %A = bitcast i64 63 to <1 x i64>
13 ; Ensure that a FP source operand isn't propagated to an icmp.
15 @a = external global i16, align 1
16 @b = external global i16, align 1
18 define i1 @bad_icmp_constexpr_bitcast() {
19 ; CHECK-LABEL: @bad_icmp_constexpr_bitcast(
20 ; CHECK-NEXT: [[FADD:%.*]] = fadd float bitcast (i32 ptrtoint (ptr @b to i32) to float), 2.000000e+00
21 ; CHECK-NEXT: [[BITCAST:%.*]] = bitcast float [[FADD]] to i32
22 ; CHECK-NEXT: [[CMP:%.*]] = icmp eq i32 ptrtoint (ptr @a to i32), [[BITCAST]]
23 ; CHECK-NEXT: ret i1 [[CMP]]
25 %fadd = fadd float bitcast (i32 ptrtoint (ptr @b to i32) to float), 2.0
26 %bitcast = bitcast float %fadd to i32
27 %cmp = icmp eq i32 ptrtoint (ptr @a to i32), %bitcast
31 ; Ensure that an integer source operand isn't propagated to a fcmp.
33 @c = external global i16, align 1
34 @d = external global i16, align 1
36 define i1 @bad_fcmp_constexpr_bitcast() {
37 ; CHECK-LABEL: @bad_fcmp_constexpr_bitcast(
38 ; 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))
40 %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)
44 ; Ensure that an "ordered and equal" fcmp of a ConstantExpr to itself is not folded, since the ConstantExpr may be a NaN.
46 define i1 @fcmp_constexpr_oeq(float %conv) {
47 ; CHECK-LABEL: @fcmp_constexpr_oeq(
48 ; 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))
50 %cmp = fcmp oeq float bitcast (i32 ptrtoint (ptr @a to i32) to float), bitcast (i32 ptrtoint (ptr @a to i32) to float)
54 ; Ensure that an "unordered or not equal" fcmp of a ConstantExpr to itself is not folded, since the ConstantExpr may be a NaN.
56 define i1 @fcmp_constexpr_une(float %conv) {
57 ; CHECK-LABEL: @fcmp_constexpr_une(
58 ; 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))
60 %cmp = fcmp une float bitcast (i32 ptrtoint (ptr @a to i32) to float), bitcast (i32 ptrtoint (ptr @a to i32) to float)
64 define i1 @fcmp_constexpr_ueq(float %conv) {
65 ; CHECK-LABEL: @fcmp_constexpr_ueq(
66 ; CHECK-NEXT: ret i1 true
68 %cmp = fcmp ueq float bitcast (i32 ptrtoint (ptr @a to i32) to float), bitcast (i32 ptrtoint (ptr @a to i32) to float)
72 define i1 @fcmp_constexpr_one(float %conv) {
73 ; CHECK-LABEL: @fcmp_constexpr_one(
74 ; CHECK-NEXT: ret i1 false
76 %cmp = fcmp one float bitcast (i32 ptrtoint (ptr @a to i32) to float), bitcast (i32 ptrtoint (ptr @a to i32) to float)
81 @G = external global %T
83 define ptr @bitcast_to_gep() {
84 ; CHECK-LABEL: @bitcast_to_gep(
85 ; CHECK-NEXT: ret ptr @G
90 define ptr addrspace(1) @addrspacecast_to_gep() {
91 ; CHECK-LABEL: @addrspacecast_to_gep(
92 ; CHECK-NEXT: ret ptr addrspace(1) addrspacecast (ptr @G to ptr addrspace(1))
94 %p = addrspacecast ptr @G to ptr addrspace(1)
95 ret ptr addrspace(1) %p