File: memset-unknown-sizes.ll

package info (click to toggle)
llvm-toolchain-14 1%3A14.0.6-12
  • links: PTS, VCS
  • area: main
  • in suites: bookworm
  • size: 1,496,180 kB
  • sloc: cpp: 5,593,972; ansic: 986,872; asm: 585,869; python: 184,223; objc: 72,530; lisp: 31,119; f90: 27,793; javascript: 9,780; pascal: 9,762; sh: 9,482; perl: 7,468; ml: 5,432; awk: 3,523; makefile: 2,538; xml: 953; cs: 573; fortran: 567
file content (71 lines) | stat: -rw-r--r-- 2,758 bytes parent folder | download | duplicates (4)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
; NOTE: Assertions have been autogenerated by utils/update_test_checks.py
; RUN: opt -dse -S %s | FileCheck %s

declare i8* @_Znwm() local_unnamed_addr #0

; Function Attrs: argmemonly nounwind willreturn writeonly
declare void @llvm.memset.p0i8.i64(i8* nocapture writeonly, i8, i64, i1 immarg) #1

define i8* @test1(i1 %c, i64 %N) {
; CHECK-LABEL: @test1(
; CHECK-NEXT:  entry:
; CHECK-NEXT:    br i1 [[C:%.*]], label [[COND_TRUE_I_I_I:%.*]], label [[COND_END_I_I_I:%.*]]
; CHECK:       cond.true.i.i.i:
; CHECK-NEXT:    ret i8* null
; CHECK:       cond.end.i.i.i:
; CHECK-NEXT:    [[ALLOC:%.*]] = tail call noalias nonnull i8* @_Znam() #[[ATTR2:[0-9]+]]
; CHECK-NEXT:    [[ALLOC_BC:%.*]] = bitcast i8* [[ALLOC]] to i64*
; CHECK-NEXT:    tail call void @llvm.memset.p0i8.i64(i8* nonnull align 8 [[ALLOC]], i8 0, i64 [[N:%.*]], i1 false) #[[ATTR3:[0-9]+]]
; CHECK-NEXT:    store i64 0, i64* [[ALLOC_BC]], align 8
; CHECK-NEXT:    ret i8* [[ALLOC]]
;
entry:
  br i1 %c, label %cond.true.i.i.i, label %cond.end.i.i.i

cond.true.i.i.i:                                  ; preds = %entry
  ret i8* null

cond.end.i.i.i:                                   ; preds = %entry
  %alloc = tail call noalias nonnull i8* @_Znam() #2
  %alloc.bc = bitcast i8* %alloc to i64*
  tail call void @llvm.memset.p0i8.i64(i8* nonnull align 8 %alloc, i8 0, i64 %N, i1 false) #3
  store i64 0, i64* %alloc.bc, align 8
  ret i8* %alloc
}

declare i8* @_Znam()


define i8* @test2(i1 %c, i64 %N) {
; CHECK-LABEL: @test2(
; CHECK-NEXT:  entry:
; CHECK-NEXT:    br i1 [[C:%.*]], label [[CLEANUP_CONT104:%.*]], label [[IF_THEN:%.*]]
; CHECK:       if.then:
; CHECK-NEXT:    [[MUL:%.*]] = shl nuw nsw i64 [[N:%.*]], 3
; CHECK-NEXT:    [[ALLOC:%.*]] = call noalias nonnull i8* @_Znwm() #[[ATTR2]]
; CHECK-NEXT:    [[ALLOC_BC:%.*]] = bitcast i8* [[ALLOC]] to i64*
; CHECK-NEXT:    store i64 0, i64* [[ALLOC_BC]], align 8
; CHECK-NEXT:    call void @llvm.memset.p0i8.i64(i8* nonnull align 8 [[ALLOC]], i8 0, i64 [[MUL]], i1 false) #[[ATTR3]]
; CHECK-NEXT:    ret i8* [[ALLOC]]
; CHECK:       cleanup.cont104:
; CHECK-NEXT:    ret i8* null
;
entry:
  br i1 %c, label %cleanup.cont104, label %if.then

if.then:                                          ; preds = %entry
  %mul = shl nuw nsw i64 %N, 3
  %alloc = call noalias nonnull i8* @_Znwm() #2
  %alloc.bc = bitcast i8* %alloc to i64*
  store i64 0, i64* %alloc.bc, align 8
  call void @llvm.memset.p0i8.i64(i8* nonnull align 8 %alloc, i8 0, i64 %mul, i1 false) #3
  ret i8* %alloc

cleanup.cont104:                                  ; preds = %entry
  ret i8* null
}

attributes #0 = { "use-soft-float"="false" }
attributes #1 = { argmemonly nounwind willreturn writeonly }
attributes #2 = { builtin nounwind }
attributes #3 = { nounwind }