OverlappingInsertvalues.ll 1.3 KB

123456789101112131415161718192021222324252627282930313233343536
  1. ; RUN: opt < %s -instcombine -S | FileCheck %s
  2. target datalayout = "e-m:e-i64:64-f80:128-n8:16:32:64-S128"
  3. ; Check that we can find and remove redundant insertvalues
  4. ; CHECK-LABEL: foo_simple
  5. ; CHECK-NOT: i8* %x, 0
  6. define { i8*, i64, i32 } @foo_simple(i8* %x, i8* %y) nounwind {
  7. entry:
  8. %0 = insertvalue { i8*, i64, i32 } undef, i8* %x, 0
  9. %1 = insertvalue { i8*, i64, i32 } %0, i8* %y, 0
  10. ret { i8*, i64, i32 } %1
  11. }
  12. ; Check that we can find and remove redundant nodes in insertvalues chain
  13. ; CHECK-LABEL: foo_ovwrt_chain
  14. ; CHECK-NOT: i64 %y, 1
  15. ; CHECK-NOT: i32 555, 2
  16. define { i8*, i64, i32 } @foo_ovwrt_chain(i8* %x, i64 %y, i64 %z) nounwind {
  17. entry:
  18. %0 = insertvalue { i8*, i64, i32 } undef, i8* %x, 0
  19. %1 = insertvalue { i8*, i64, i32 } %0, i64 %y, 1
  20. %2 = insertvalue { i8*, i64, i32 } %1, i32 555, 2
  21. %3 = insertvalue { i8*, i64, i32 } %2, i64 %z, 1
  22. %4 = insertvalue { i8*, i64, i32 } %3, i32 777, 2
  23. ret { i8*, i64, i32 } %4
  24. }
  25. ; Check that we propagate insertvalues only if they are use as the first
  26. ; operand (as initial value of aggregate)
  27. ; CHECK-LABEL: foo_use_as_second_operand
  28. ; CHECK: i16 %x, 0
  29. ; CHECK: %0, 1
  30. define { i8, {i16, i32} } @foo_use_as_second_operand(i16 %x) nounwind {
  31. entry:
  32. %0 = insertvalue { i16, i32 } undef, i16 %x, 0
  33. %1 = insertvalue { i8, {i16, i32} } undef, { i16, i32 } %0, 1
  34. ret { i8, {i16, i32} } %1
  35. }