@@ -365,20 +365,52 @@ define i32 @load_after_memset_unknown(ptr %a, i8 %byte) {
365365 ret i32 %v
366366}
367367
368- ; TODO: Handle load at offset.
369368define i32 @load_after_memset_0_offset (ptr %a ) {
370369; CHECK-LABEL: @load_after_memset_0_offset(
371370; CHECK-NEXT: call void @llvm.memset.p0.i64(ptr noundef nonnull align 1 dereferenceable(16) [[A:%.*]], i8 0, i64 16, i1 false)
372- ; CHECK-NEXT: [[GEP:%.*]] = getelementptr i8, ptr [[A]], i64 4
373- ; CHECK-NEXT: [[V:%.*]] = load i32, ptr [[GEP]], align 4
374- ; CHECK-NEXT: ret i32 [[V]]
371+ ; CHECK-NEXT: ret i32 0
375372;
376373 call void @llvm.memset.p0.i64 (ptr %a , i8 0 , i64 16 , i1 false )
377374 %gep = getelementptr i8 , ptr %a , i64 4
378375 %v = load i32 , ptr %gep
379376 ret i32 %v
380377}
381378
379+ define i32 @load_after_memset_1_offset (ptr %a ) {
380+ ; CHECK-LABEL: @load_after_memset_1_offset(
381+ ; CHECK-NEXT: call void @llvm.memset.p0.i64(ptr noundef nonnull align 1 dereferenceable(16) [[A:%.*]], i8 1, i64 16, i1 false)
382+ ; CHECK-NEXT: ret i32 16843009
383+ ;
384+ call void @llvm.memset.p0.i64 (ptr %a , i8 1 , i64 16 , i1 false )
385+ %gep = getelementptr i8 , ptr %a , i64 4
386+ %v = load i32 , ptr %gep
387+ ret i32 %v
388+ }
389+
390+ define i1 @load_after_memset_0_offset_i1 (ptr %a ) {
391+ ; CHECK-LABEL: @load_after_memset_0_offset_i1(
392+ ; CHECK-NEXT: call void @llvm.memset.p0.i64(ptr noundef nonnull align 1 dereferenceable(16) [[A:%.*]], i8 0, i64 16, i1 false)
393+ ; CHECK-NEXT: ret i1 false
394+ ;
395+ call void @llvm.memset.p0.i64 (ptr %a , i8 0 , i64 16 , i1 false )
396+ %gep = getelementptr i1 , ptr %a , i64 12
397+ %v = load i1 , ptr %gep
398+ ret i1 %v
399+ }
400+
401+ define i8 @neg_load_after_memset_0_neg_offset (ptr %a ) {
402+ ; CHECK-LABEL: @neg_load_after_memset_0_neg_offset(
403+ ; CHECK-NEXT: [[GEP:%.*]] = getelementptr i8, ptr [[A:%.*]], i64 2
404+ ; CHECK-NEXT: call void @llvm.memset.p0.i64(ptr noundef nonnull align 1 dereferenceable(16) [[GEP]], i8 0, i64 16, i1 false)
405+ ; CHECK-NEXT: [[V:%.*]] = load i8, ptr [[A]], align 1
406+ ; CHECK-NEXT: ret i8 [[V]]
407+ ;
408+ %gep = getelementptr i8 , ptr %a , i64 2
409+ call void @llvm.memset.p0.i64 (ptr %gep , i8 0 , i64 16 , i1 false )
410+ %v = load i8 , ptr %a
411+ ret i8 %v
412+ }
413+
382414define i32 @load_after_memset_0_offset_too_large (ptr %a ) {
383415; CHECK-LABEL: @load_after_memset_0_offset_too_large(
384416; CHECK-NEXT: call void @llvm.memset.p0.i64(ptr noundef nonnull align 1 dereferenceable(16) [[A:%.*]], i8 0, i64 16, i1 false)
0 commit comments