brintos

brintos / llvm-project-archived public Read only

0
0
Text · 2.5 KiB · 78715b6 Raw
99 lines · plain
1; NOTE: Assertions have been autogenerated by utils/update_test_checks.py2; RUN: opt -S -passes=early-cse -earlycse-debug-hash < %s | FileCheck %s3 4; While it is normally okay to do memory optimizations over calls to5; @readonly_function and @readnone_function, we cannot do that if6; they're carrying unknown operand bundles since the presence of7; unknown operand bundles implies arbitrary memory effects.8 9declare void @readonly_function() readonly nounwind willreturn10declare void @readnone_function() readnone nounwind willreturn11 12define i32 @test0(ptr %x) {13; CHECK-LABEL: @test0(14; CHECK-NEXT:  entry:15; CHECK-NEXT:    store i32 100, ptr [[X:%.*]], align 416; CHECK-NEXT:    call void @readonly_function() [ "tag"() ]17; CHECK-NEXT:    [[V:%.*]] = load i32, ptr [[X]], align 418; CHECK-NEXT:    ret i32 [[V]]19;20  entry:21  store i32 100, ptr %x22  call void @readonly_function() [ "tag"() ]23 24  %v = load i32, ptr %x25  ret i32 %v26}27 28define i32 @test1(ptr %x) {29; CHECK-LABEL: @test1(30; CHECK-NEXT:  entry:31; CHECK-NEXT:    store i32 100, ptr [[X:%.*]], align 432; CHECK-NEXT:    ret i32 10033;34  entry:35  store i32 100, ptr %x36  call void @readonly_function() readonly [ "tag"() ]37  %v = load i32, ptr %x38  ret i32 %v39}40 41define i32 @test3(ptr %x) {42; CHECK-LABEL: @test3(43; CHECK-NEXT:  entry:44; CHECK-NEXT:    store i32 100, ptr [[X:%.*]], align 445; CHECK-NEXT:    ret i32 10046;47  entry:48  store i32 100, ptr %x49  call void @readonly_function()50  %v = load i32, ptr %x51  ret i32 %v52}53 54define void @test4(ptr %x) {55; CHECK-LABEL: @test4(56; CHECK-NEXT:  entry:57; CHECK-NEXT:    store i32 100, ptr [[X:%.*]], align 458; CHECK-NEXT:    call void @readnone_function() [ "tag"() ]59; CHECK-NEXT:    store i32 200, ptr [[X]], align 460; CHECK-NEXT:    ret void61;62  entry:63  store i32 100, ptr %x64  call void @readnone_function() [ "tag"() ]65  store i32 200, ptr %x66  ret void67}68 69define void @test5(ptr %x) {70; CHECK-LABEL: @test5(71; CHECK-NEXT:  entry:72; CHECK-NEXT:    store i32 200, ptr [[X:%.*]], align 473; CHECK-NEXT:    ret void74;75  entry:76  store i32 100, ptr %x77  call void @readnone_function() readnone [ "tag"() ]78  store i32 200, ptr %x79  ret void80}81 82define void @test6(ptr %x) {83; The "deopt" operand bundle does not make the call to84; @readonly_function read-write; and so the nounwind readonly call can85; be deleted.86; CHECK-LABEL: @test6(87; CHECK-NEXT:  entry:88; CHECK-NEXT:    store i32 200, ptr [[X:%.*]], align 489; CHECK-NEXT:    ret void90;91  entry:92 93 94  store i32 100, ptr %x95  call void @readonly_function() [ "deopt"() ]96  store i32 200, ptr %x97  ret void98}99