summaryrefslogtreecommitdiffstats
path: root/llvm/test/Transforms/NewGVN/load-constant-mem.ll
diff options
context:
space:
mode:
Diffstat (limited to 'llvm/test/Transforms/NewGVN/load-constant-mem.ll')
-rw-r--r--llvm/test/Transforms/NewGVN/load-constant-mem.ll21
1 files changed, 21 insertions, 0 deletions
diff --git a/llvm/test/Transforms/NewGVN/load-constant-mem.ll b/llvm/test/Transforms/NewGVN/load-constant-mem.ll
new file mode 100644
index 00000000000..4c1624e09f6
--- /dev/null
+++ b/llvm/test/Transforms/NewGVN/load-constant-mem.ll
@@ -0,0 +1,21 @@
+; NOTE: Assertions have been autogenerated by utils/update_test_checks.py
+; RUN: opt < %s -basicaa -newgvn -S | FileCheck %s
+; PR4189
+@G = external constant [4 x i32]
+
+define i32 @test(i8* %p, i32 %i) nounwind {
+; CHECK-LABEL: @test(
+; CHECK-NEXT: entry:
+; CHECK-NEXT: [[P:%.*]] = getelementptr [4 x i32], [4 x i32]* @G, i32 0, i32 [[I:%.*]]
+; CHECK-NEXT: store i8 4, i8* [[P:%.*]]
+; CHECK-NEXT: ret i32 0
+;
+entry:
+ %P = getelementptr [4 x i32], [4 x i32]* @G, i32 0, i32 %i
+ %A = load i32, i32* %P
+ store i8 4, i8* %p
+ %B = load i32, i32* %P
+ %C = sub i32 %A, %B
+ ret i32 %C
+}
+
OpenPOWER on IntegriCloud