blob: bc629cdfe9eafb48bcb825095b6f294600b32e73 [file] [log] [blame]
Shuxin Yang408bdad2013-03-06 17:48:48 +00001; RUN: opt < %s -basicaa -gvn -S | FileCheck %s
2
3; The input *.ll is obtained by manually annotating "invariant.load" to the
4; two loads. With "invariant.load" metadata, the second load is redundant.
5;
6; int foo(int *p, char *q) {
7; *q = (char)*p;
8; return *p + 1;
9; }
10
11define i32 @foo(i32* nocapture %p, i8* nocapture %q) {
12entry:
Manman Ren662ece42013-04-29 22:42:01 +000013 %0 = load i32* %p, align 4, !invariant.load !3
Shuxin Yang408bdad2013-03-06 17:48:48 +000014 %conv = trunc i32 %0 to i8
Manman Ren662ece42013-04-29 22:42:01 +000015 store i8 %conv, i8* %q, align 1
16 %1 = load i32* %p, align 4, !invariant.load !3
Shuxin Yang408bdad2013-03-06 17:48:48 +000017 %add = add nsw i32 %1, 1
18 ret i32 %add
19
20; CHECK: foo
21; CHECK: %0 = load i32* %p
22; CHECK: store i8 %conv, i8* %q,
23; CHECK: %add = add nsw i32 %0, 1
24}
25
Duncan P. N. Exon Smithbe7ea192014-12-15 19:07:53 +000026!3 = !{}