Home | History | Annotate | Download | only in GVN
      1 ; Test if the !invariant.load metadata is maintained by GVN.
      2 ; RUN: opt -basicaa -gvn -S < %s | FileCheck %s
      3 
      4 define i32 @test1(i32* nocapture %p, i8* nocapture %q) {
      5 ; CHECK-LABEL: test1
      6 ; CHECK: %x = load i32* %p, align 4, !invariant.load !0
      7 ; CHECK-NOT: %y = load
      8 entry:
      9   %x = load i32* %p, align 4, !invariant.load !0
     10   %conv = trunc i32 %x to i8
     11   store i8 %conv, i8* %q, align 1
     12   %y = load i32* %p, align 4, !invariant.load !0
     13   %add = add i32 %y, 1
     14   ret i32 %add
     15 }
     16 
     17 define i32 @test2(i32* nocapture %p, i8* nocapture %q) {
     18 ; CHECK-LABEL: test2
     19 ; CHECK-NOT: !invariant.load
     20 ; CHECK-NOT: %y = load
     21 entry:
     22   %x = load i32* %p, align 4
     23   %conv = trunc i32 %x to i8
     24   store i8 %conv, i8* %q, align 1
     25   %y = load i32* %p, align 4, !invariant.load !0
     26   %add = add i32 %y, 1
     27   ret i32 %add
     28 }
     29 
     30 !0 = metadata !{ }
     31 
     32