1 ; NOTE: Assertions have been autogenerated by utils/update_test_checks.py
2 ; RUN: opt < %s -passes=instcombine -S | FileCheck %s
4 define i32 @test(ptr %target) {
6 ; CHECK-NEXT: store i8 1, ptr [[TARGET:%.*]], align 1
7 ; CHECK-NEXT: store i16 257, ptr [[TARGET]], align 2
8 ; CHECK-NEXT: store i32 16843009, ptr [[TARGET]], align 4
9 ; CHECK-NEXT: store i64 72340172838076673, ptr [[TARGET]], align 8
10 ; CHECK-NEXT: ret i32 0
12 call void @llvm.memset.p0.i32(ptr %target, i8 1, i32 0, i1 false)
13 call void @llvm.memset.p0.i32(ptr %target, i8 1, i32 1, i1 false)
14 call void @llvm.memset.p0.i32(ptr align 2 %target, i8 1, i32 2, i1 false)
15 call void @llvm.memset.p0.i32(ptr align 4 %target, i8 1, i32 4, i1 false)
16 call void @llvm.memset.p0.i32(ptr align 8 %target, i8 1, i32 8, i1 false)
20 @Unknown = external constant i128
22 define void @memset_to_constant() {
23 ; CHECK-LABEL: @memset_to_constant(
24 ; CHECK-NEXT: ret void
26 call void @llvm.memset.p0.i32(ptr @Unknown, i8 0, i32 16, i1 false)
30 ; FIXME: This is technically incorrect because it might overwrite a poison
31 ; value. Stop folding it once #52930 is resolved.
32 define void @memset_undef(ptr %p) {
33 ; CHECK-LABEL: @memset_undef(
34 ; CHECK-NEXT: ret void
36 call void @llvm.memset.p0.i32(ptr %p, i8 undef, i32 8, i1 false)
40 define void @memset_undef_volatile(ptr %p) {
41 ; CHECK-LABEL: @memset_undef_volatile(
42 ; CHECK-NEXT: call void @llvm.memset.p0.i32(ptr [[P:%.*]], i8 undef, i32 8, i1 true)
43 ; CHECK-NEXT: ret void
45 call void @llvm.memset.p0.i32(ptr %p, i8 undef, i32 8, i1 true)
49 define void @memset_poison(ptr %p) {
50 ; CHECK-LABEL: @memset_poison(
51 ; CHECK-NEXT: ret void
53 call void @llvm.memset.p0.i32(ptr %p, i8 poison, i32 8, i1 false)
57 define void @memset_poison_volatile(ptr %p) {
58 ; CHECK-LABEL: @memset_poison_volatile(
59 ; CHECK-NEXT: call void @llvm.memset.p0.i32(ptr [[P:%.*]], i8 poison, i32 8, i1 true)
60 ; CHECK-NEXT: ret void
62 call void @llvm.memset.p0.i32(ptr %p, i8 poison, i32 8, i1 true)
66 declare void @llvm.memset.p0.i32(ptr nocapture writeonly, i8, i32, i1) argmemonly nounwind