1 ; NOTE: Assertions have been autogenerated by utils/update_test_checks.py UTC_ARGS: --version 2
2 ; RUN: opt -S -passes=instcombine < %s | FileCheck %s
4 ; Instcombine should preserve metadata and alignment while
5 ; folding a bitcast into a store.
7 target datalayout = "e-p:64:64:64-i1:8:8-i8:8:8-i16:16:16-i32:32:32-i64:64:64-f32:32:32-f64:64:64-v64:64:64-v128:128:128-a0:0:64-s0:64:64-f80:128:128-n8:16:32:64"
9 %struct.A = type { ptr }
11 @G = external constant [5 x ptr]
13 define void @foo(i32 %x, ptr %p) nounwind {
14 ; CHECK-LABEL: define void @foo
15 ; CHECK-SAME: (i32 [[X:%.*]], ptr [[P:%.*]]) #[[ATTR0:[0-9]+]] {
17 ; CHECK-NEXT: store i32 [[X]], ptr [[P]], align 16, !noalias !0, !llvm.access.group [[ACC_GRP3:![0-9]+]]
18 ; CHECK-NEXT: ret void
21 %x.cast = bitcast i32 %x to float
22 store float %x.cast, ptr %p, align 16, !noalias !0, !llvm.access.group !3
26 ; Check instcombine doesn't try and fold the following bitcast into the store.
27 ; This transformation would not be safe since we would need to use addrspacecast
28 ; and addrspacecast is not guaranteed to be a no-op cast.
30 define void @bar(ptr addrspace(1) %a, ptr %b) nounwind {
31 ; CHECK-LABEL: define void @bar
32 ; CHECK-SAME: (ptr addrspace(1) [[A:%.*]], ptr [[B:%.*]]) #[[ATTR0]] {
34 ; CHECK-NEXT: store ptr addrspace(1) [[A]], ptr [[B]], align 8
35 ; CHECK-NEXT: ret void
38 store ptr addrspace(1) %a, ptr %b
42 ; Check that we don't combine the bitcast into the store. This would create a
43 ; bitcast of the swifterror which is invalid.
45 %swift.error = type opaque
46 define void @swifterror_store(ptr %x, ptr swifterror %err) {
47 ; CHECK-LABEL: define void @swifterror_store
48 ; CHECK-SAME: (ptr [[X:%.*]], ptr swifterror [[ERR:%.*]]) {
50 ; CHECK-NEXT: store ptr [[X]], ptr [[ERR]], align 8
51 ; CHECK-NEXT: ret void
54 store ptr %x, ptr %err
58 define void @ppcf128_ones_store(ptr %dest) {
59 ; CHECK-LABEL: define void @ppcf128_ones_store
60 ; CHECK-SAME: (ptr [[DEST:%.*]]) {
62 ; CHECK-NEXT: store ppc_fp128 0xMFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFF, ptr [[DEST]], align 16
63 ; CHECK-NEXT: ret void
66 %int = or i128 0, 340282366920938463463374607431768211455 ; 128 ones
67 %val = bitcast i128 %int to ppc_fp128
68 store ppc_fp128 %val, ptr %dest, align 16