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> splat (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: [[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)
39 ; CHECK-NEXT: ret i1 [[CMP]]
41 %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)
45 ; Ensure that an "ordered and equal" fcmp of a ConstantExpr to itself is not folded, since the ConstantExpr may be a NaN.
47 define i1 @fcmp_constexpr_oeq(float %conv) {
48 ; CHECK-LABEL: @fcmp_constexpr_oeq(
49 ; CHECK-NEXT: [[CMP:%.*]] = fcmp oeq float bitcast (i32 ptrtoint (ptr @a to i32) to float), bitcast (i32 ptrtoint (ptr @a to i32) to float)
50 ; CHECK-NEXT: ret i1 [[CMP]]
52 %cmp = fcmp oeq float bitcast (i32 ptrtoint (ptr @a to i32) to float), bitcast (i32 ptrtoint (ptr @a to i32) to float)
56 ; Ensure that an "unordered or not equal" fcmp of a ConstantExpr to itself is not folded, since the ConstantExpr may be a NaN.
58 define i1 @fcmp_constexpr_une(float %conv) {
59 ; CHECK-LABEL: @fcmp_constexpr_une(
60 ; CHECK-NEXT: [[CMP:%.*]] = fcmp une float bitcast (i32 ptrtoint (ptr @a to i32) to float), bitcast (i32 ptrtoint (ptr @a to i32) to float)
61 ; CHECK-NEXT: ret i1 [[CMP]]
63 %cmp = fcmp une float bitcast (i32 ptrtoint (ptr @a to i32) to float), bitcast (i32 ptrtoint (ptr @a to i32) to float)
67 define i1 @fcmp_constexpr_ueq(float %conv) {
68 ; CHECK-LABEL: @fcmp_constexpr_ueq(
69 ; CHECK-NEXT: ret i1 true
71 %cmp = fcmp ueq float bitcast (i32 ptrtoint (ptr @a to i32) to float), bitcast (i32 ptrtoint (ptr @a to i32) to float)
75 define i1 @fcmp_constexpr_one(float %conv) {
76 ; CHECK-LABEL: @fcmp_constexpr_one(
77 ; CHECK-NEXT: ret i1 false
79 %cmp = fcmp one float bitcast (i32 ptrtoint (ptr @a to i32) to float), bitcast (i32 ptrtoint (ptr @a to i32) to float)
84 @G = external global %T
86 define ptr @bitcast_to_gep() {
87 ; CHECK-LABEL: @bitcast_to_gep(
88 ; CHECK-NEXT: ret ptr @G
93 define ptr addrspace(1) @addrspacecast_to_gep() {
94 ; CHECK-LABEL: @addrspacecast_to_gep(
95 ; CHECK-NEXT: ret ptr addrspace(1) addrspacecast (ptr @G to ptr addrspace(1))
97 %p = addrspacecast ptr @G to ptr addrspace(1)
98 ret ptr addrspace(1) %p