summaryrefslogtreecommitdiffstats
path: root/llvm/test/Transforms/JumpThreading
diff options
context:
space:
mode:
authorEli Friedman <eli.friedman@gmail.com>2016-08-08 04:10:22 +0000
committerEli Friedman <eli.friedman@gmail.com>2016-08-08 04:10:22 +0000
commit02419a98499704e98236cda2e9b1b3c996ad4908 (patch)
treef9c507ee5717bd9a24076682962c5fac36b7c944 /llvm/test/Transforms/JumpThreading
parentd931b9f20060ce3751614e889fa4629db13e9e66 (diff)
downloadbcm5719-llvm-02419a98499704e98236cda2e9b1b3c996ad4908.tar.gz
bcm5719-llvm-02419a98499704e98236cda2e9b1b3c996ad4908.zip
[JumpThreading] Fix handling of aliasing metadata.
Summary: The correctness fix here is that when we CSE a load with another load, we need to combine the metadata on the two loads. This matches the behavior of other passes, like instcombine and GVN. There's also a minor optimization improvement here: for load PRE, the aliasing metadata on the inserted load should be the same as the metadata on the original load. Not sure why the old code was throwing it away. Issue found by inspection. Differential Revision: http://reviews.llvm.org/D21460 llvm-svn: 277977
Diffstat (limited to 'llvm/test/Transforms/JumpThreading')
-rw-r--r--llvm/test/Transforms/JumpThreading/thread-loads.ll63
1 files changed, 63 insertions, 0 deletions
diff --git a/llvm/test/Transforms/JumpThreading/thread-loads.ll b/llvm/test/Transforms/JumpThreading/thread-loads.ll
index 4b482cb15f9..71f5538c173 100644
--- a/llvm/test/Transforms/JumpThreading/thread-loads.ll
+++ b/llvm/test/Transforms/JumpThreading/thread-loads.ll
@@ -246,7 +246,70 @@ bb3:
ret i32 %res.0
}
+; Make sure we merge the aliasing metadata. (If we don't, we have a load
+; with the wrong metadata, so the branch gets incorrectly eliminated.)
+define void @test8(i32*, i32*, i32*) {
+; CHECK-LABEL: @test8(
+; CHECK: %a = load i32, i32* %0, !range !4
+; CHECK-NEXT: store i32 %a
+; CHECK: br i1 %c
+ %a = load i32, i32* %0, !tbaa !0, !range !4, !alias.scope !9, !noalias !10
+ %b = load i32, i32* %0, !range !5
+ store i32 %a, i32* %1
+ %c = icmp eq i32 %b, 8
+ br i1 %c, label %ret1, label %ret2
+
+ret1:
+ ret void
+
+ret2:
+ %xxx = tail call i32 (...) @f1() nounwind
+ ret void
+}
+
+; Make sure we merge/PRE aliasing metadata correctly. That means that
+; we need to remove metadata from the existing load, and add appropriate
+; metadata to the newly inserted load.
+define void @test9(i32*, i32*, i32*, i1 %c) {
+; CHECK-LABEL: @test9(
+ br i1 %c, label %d1, label %d2
+
+; CHECK: d1:
+; CHECK-NEXT: %a = load i32, i32* %0{{$}}
+d1:
+ %a = load i32, i32* %0, !range !4, !alias.scope !9, !noalias !10
+ br label %d3
+
+; CHECK: d2:
+; CHECK-NEXT: %xxxx = tail call i32 (...) @f1()
+; CHECK-NEXT: %b.pr = load i32, i32* %0, !tbaa !0{{$}}
+d2:
+ %xxxx = tail call i32 (...) @f1() nounwind
+ br label %d3
+
+d3:
+ %p = phi i32 [ 1, %d2 ], [ %a, %d1 ]
+ %b = load i32, i32* %0, !tbaa !0
+ store i32 %p, i32* %1
+ %c2 = icmp eq i32 %b, 8
+ br i1 %c2, label %ret1, label %ret2
+
+ret1:
+ ret void
+
+ret2:
+ %xxx = tail call i32 (...) @f1() nounwind
+ ret void
+}
+
!0 = !{!3, !3, i64 0}
!1 = !{!"omnipotent char", !2}
!2 = !{!"Simple C/C++ TBAA", null}
!3 = !{!"int", !1}
+!4 = !{ i32 0, i32 1 }
+!5 = !{ i32 8, i32 10 }
+!6 = !{!6}
+!7 = !{!7, !6}
+!8 = !{!8, !6}
+!9 = !{!7}
+!10 = !{!8}
OpenPOWER on IntegriCloud