1 ; NOTE: Assertions have been autogenerated by utils/update_test_checks.py
2 ; RUN: opt -S -passes=early-cse -earlycse-debug-hash < %s | FileCheck %s
4 ; While it is normally okay to do memory optimizations over calls to
5 ; @readonly_function and @readnone_function, we cannot do that if
6 ; they're carrying unknown operand bundles since the presence of
7 ; unknown operand bundles implies arbitrary memory effects.
9 declare void @readonly_function() readonly nounwind willreturn
10 declare void @readnone_function() readnone nounwind willreturn
12 define i32 @test0(ptr %x) {
13 ; CHECK-LABEL: @test0(
15 ; CHECK-NEXT: store i32 100, ptr [[X:%.*]], align 4
16 ; CHECK-NEXT: call void @readonly_function() [ "tag"() ]
17 ; CHECK-NEXT: [[V:%.*]] = load i32, ptr [[X]], align 4
18 ; CHECK-NEXT: ret i32 [[V]]
22 call void @readonly_function() [ "tag"() ]
28 define i32 @test1(ptr %x) {
29 ; CHECK-LABEL: @test1(
31 ; CHECK-NEXT: store i32 100, ptr [[X:%.*]], align 4
32 ; CHECK-NEXT: ret i32 100
36 call void @readonly_function() readonly [ "tag"() ]
41 define i32 @test3(ptr %x) {
42 ; CHECK-LABEL: @test3(
44 ; CHECK-NEXT: store i32 100, ptr [[X:%.*]], align 4
45 ; CHECK-NEXT: ret i32 100
49 call void @readonly_function()
54 define void @test4(ptr %x) {
55 ; CHECK-LABEL: @test4(
57 ; CHECK-NEXT: store i32 100, ptr [[X:%.*]], align 4
58 ; CHECK-NEXT: call void @readnone_function() [ "tag"() ]
59 ; CHECK-NEXT: store i32 200, ptr [[X]], align 4
60 ; CHECK-NEXT: ret void
64 call void @readnone_function() [ "tag"() ]
69 define void @test5(ptr %x) {
70 ; CHECK-LABEL: @test5(
72 ; CHECK-NEXT: store i32 200, ptr [[X:%.*]], align 4
73 ; CHECK-NEXT: ret void
77 call void @readnone_function() readnone [ "tag"() ]
82 define void @test6(ptr %x) {
83 ; The "deopt" operand bundle does not make the call to
84 ; @readonly_function read-write; and so the nounwind readonly call can
86 ; CHECK-LABEL: @test6(
88 ; CHECK-NEXT: store i32 200, ptr [[X:%.*]], align 4
89 ; CHECK-NEXT: ret void
95 call void @readonly_function() [ "deopt"() ]