invariant_load.ll 679 B

1234567891011121314151617181920212223242526
  1. ; RUN: opt < %s -basicaa -gvn -S | FileCheck %s
  2. ; The input *.ll is obtained by manually annotating "invariant.load" to the
  3. ; two loads. With "invariant.load" metadata, the second load is redundant.
  4. ;
  5. ; int foo(int *p, char *q) {
  6. ; *q = (char)*p;
  7. ; return *p + 1;
  8. ; }
  9. define i32 @foo(i32* nocapture %p, i8* nocapture %q) {
  10. entry:
  11. %0 = load i32, i32* %p, align 4, !invariant.load !3
  12. %conv = trunc i32 %0 to i8
  13. store i8 %conv, i8* %q, align 1
  14. %1 = load i32, i32* %p, align 4, !invariant.load !3
  15. %add = add nsw i32 %1, 1
  16. ret i32 %add
  17. ; CHECK: foo
  18. ; CHECK: %0 = load i32, i32* %p
  19. ; CHECK: store i8 %conv, i8* %q,
  20. ; CHECK: %add = add nsw i32 %0, 1
  21. }
  22. !3 = !{}