| ; NOTE: Assertions have been autogenerated by utils/update_test_checks.py UTC_ARGS: --version 5 |
| ; RUN: opt -S -passes=gvn < %s | FileCheck %s --check-prefixes=CHECK,MDEP |
| ; RUN: opt -S -passes='gvn<memoryssa>' < %s | FileCheck %s --check-prefixes=CHECK,MSSA |
| |
| define i32 @test1(ptr %p, i1 %C) { |
| ; MDEP-LABEL: define i32 @test1( |
| ; MDEP-SAME: ptr [[P:%.*]], i1 [[C:%.*]]) { |
| ; MDEP-NEXT: [[BLOCK1:.*:]] |
| ; MDEP-NEXT: br i1 [[C]], label %[[BLOCK2:.*]], label %[[BLOCK3:.*]] |
| ; MDEP: [[BLOCK2]]: |
| ; MDEP-NEXT: [[PRE_PRE:%.*]] = load i32, ptr [[P]], align 4, !range [[RNG0:![0-9]+]], !invariant.group [[META1:![0-9]+]] |
| ; MDEP-NEXT: br label %[[BLOCK4:.*]] |
| ; MDEP: [[BLOCK3]]: |
| ; MDEP-NEXT: store i32 0, ptr [[P]], align 4 |
| ; MDEP-NEXT: br label %[[BLOCK4]] |
| ; MDEP: [[BLOCK4]]: |
| ; MDEP-NEXT: [[PRE:%.*]] = phi i32 [ 0, %[[BLOCK3]] ], [ [[PRE_PRE]], %[[BLOCK2]] ] |
| ; MDEP-NEXT: ret i32 [[PRE]] |
| ; |
| ; MSSA-LABEL: define i32 @test1( |
| ; MSSA-SAME: ptr [[P:%.*]], i1 [[C:%.*]]) { |
| ; MSSA-NEXT: [[BLOCK1:.*:]] |
| ; MSSA-NEXT: br i1 [[C]], label %[[BLOCK2:.*]], label %[[BLOCK3:.*]] |
| ; MSSA: [[BLOCK2]]: |
| ; MSSA-NEXT: br label %[[BLOCK4:.*]] |
| ; MSSA: [[BLOCK3]]: |
| ; MSSA-NEXT: store i32 0, ptr [[P]], align 4 |
| ; MSSA-NEXT: br label %[[BLOCK4]] |
| ; MSSA: [[BLOCK4]]: |
| ; MSSA-NEXT: [[PRE:%.*]] = load i32, ptr [[P]], align 4, !range [[RNG0:![0-9]+]], !invariant.group [[META1:![0-9]+]] |
| ; MSSA-NEXT: ret i32 [[PRE]] |
| ; |
| block1: |
| br i1 %C, label %block2, label %block3 |
| |
| block2: |
| br label %block4 |
| |
| block3: |
| store i32 0, ptr %p |
| br label %block4 |
| |
| block4: |
| %PRE = load i32, ptr %p, !range !0, !invariant.group !1 |
| ret i32 %PRE |
| } |
| |
| define float @nofpclass(ptr %p, i1 %C) { |
| ; MDEP-LABEL: define float @nofpclass( |
| ; MDEP-SAME: ptr [[P:%.*]], i1 [[C:%.*]]) { |
| ; MDEP-NEXT: [[BLOCK1:.*:]] |
| ; MDEP-NEXT: br i1 [[C]], label %[[BLOCK2:.*]], label %[[BLOCK3:.*]] |
| ; MDEP: [[BLOCK2]]: |
| ; MDEP-NEXT: [[PRE_PRE:%.*]] = load float, ptr [[P]], align 4, !nofpclass [[META2:![0-9]+]] |
| ; MDEP-NEXT: br label %[[BLOCK4:.*]] |
| ; MDEP: [[BLOCK3]]: |
| ; MDEP-NEXT: store float 0.000000e+00, ptr [[P]], align 4 |
| ; MDEP-NEXT: br label %[[BLOCK4]] |
| ; MDEP: [[BLOCK4]]: |
| ; MDEP-NEXT: [[PRE:%.*]] = phi float [ 0.000000e+00, %[[BLOCK3]] ], [ [[PRE_PRE]], %[[BLOCK2]] ] |
| ; MDEP-NEXT: ret float [[PRE]] |
| ; |
| ; MSSA-LABEL: define float @nofpclass( |
| ; MSSA-SAME: ptr [[P:%.*]], i1 [[C:%.*]]) { |
| ; MSSA-NEXT: [[BLOCK1:.*:]] |
| ; MSSA-NEXT: br i1 [[C]], label %[[BLOCK2:.*]], label %[[BLOCK3:.*]] |
| ; MSSA: [[BLOCK2]]: |
| ; MSSA-NEXT: br label %[[BLOCK4:.*]] |
| ; MSSA: [[BLOCK3]]: |
| ; MSSA-NEXT: store float 0.000000e+00, ptr [[P]], align 4 |
| ; MSSA-NEXT: br label %[[BLOCK4]] |
| ; MSSA: [[BLOCK4]]: |
| ; MSSA-NEXT: [[PRE:%.*]] = load float, ptr [[P]], align 4, !nofpclass [[META2:![0-9]+]] |
| ; MSSA-NEXT: ret float [[PRE]] |
| ; |
| block1: |
| br i1 %C, label %block2, label %block3 |
| |
| block2: |
| br label %block4 |
| |
| block3: |
| store float 0.0, ptr %p |
| br label %block4 |
| |
| block4: |
| %PRE = load float, ptr %p, !nofpclass !{i32 3} |
| ret float %PRE |
| } |
| |
| |
| !0 = !{i32 40, i32 100} |
| !1 = !{!"magic ptr"} |
| ;. |
| ; MDEP: [[RNG0]] = !{i32 40, i32 100} |
| ; MDEP: [[META1]] = !{!"magic ptr"} |
| ; MDEP: [[META2]] = !{i32 3} |
| ;. |
| ; MSSA: [[RNG0]] = !{i32 40, i32 100} |
| ; MSSA: [[META1]] = !{!"magic ptr"} |
| ; MSSA: [[META2]] = !{i32 3} |
| ;. |
| ;; NOTE: These prefixes are unused and the list is autogenerated. Do not add tests below this line: |
| ; CHECK: {{.*}} |