1; NOTE: Assertions have been autogenerated by utils/update_test_checks.py 2; RUN: opt < %s -passes=instsimplify -S | FileCheck %s 3; PR2165 4 5define <1 x i64> @test1() { 6; CHECK-LABEL: @test1( 7; CHECK-NEXT: ret <1 x i64> <i64 63> 8; 9 %A = bitcast i64 63 to <1 x i64> 10 ret <1 x i64> %A 11} 12 13; Ensure that a FP source operand isn't propagated to an icmp. 14 15@a = external global i16, align 1 16@b = external global i16, align 1 17 18define 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]] 24; 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 28 ret i1 %cmp 29} 30 31; Ensure that an integer source operand isn't propagated to a fcmp. 32 33@c = external global i16, align 1 34@d = external global i16, align 1 35 36define 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)) 39; 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) 41 ret i1 %cmp 42} 43 44; Ensure that an "ordered and equal" fcmp of a ConstantExpr to itself is not folded, since the ConstantExpr may be a NaN. 45 46define 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)) 49; 50 %cmp = fcmp oeq float bitcast (i32 ptrtoint (ptr @a to i32) to float), bitcast (i32 ptrtoint (ptr @a to i32) to float) 51 ret i1 %cmp 52} 53 54; Ensure that an "unordered or not equal" fcmp of a ConstantExpr to itself is not folded, since the ConstantExpr may be a NaN. 55 56define 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)) 59; 60 %cmp = fcmp une float bitcast (i32 ptrtoint (ptr @a to i32) to float), bitcast (i32 ptrtoint (ptr @a to i32) to float) 61 ret i1 %cmp 62} 63 64define i1 @fcmp_constexpr_ueq(float %conv) { 65; CHECK-LABEL: @fcmp_constexpr_ueq( 66; CHECK-NEXT: ret i1 true 67; 68 %cmp = fcmp ueq float bitcast (i32 ptrtoint (ptr @a to i32) to float), bitcast (i32 ptrtoint (ptr @a to i32) to float) 69 ret i1 %cmp 70} 71 72define i1 @fcmp_constexpr_one(float %conv) { 73; CHECK-LABEL: @fcmp_constexpr_one( 74; CHECK-NEXT: ret i1 false 75; 76 %cmp = fcmp one float bitcast (i32 ptrtoint (ptr @a to i32) to float), bitcast (i32 ptrtoint (ptr @a to i32) to float) 77 ret i1 %cmp 78} 79 80%T = type { i8 } 81@G = external global %T 82 83define ptr @bitcast_to_gep() { 84; CHECK-LABEL: @bitcast_to_gep( 85; CHECK-NEXT: ret ptr @G 86; 87 ret ptr @G 88} 89 90define 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)) 93; 94 %p = addrspacecast ptr @G to ptr addrspace(1) 95 ret ptr addrspace(1) %p 96} 97