subtest.ll 704 B

1234567891011121314151617181920212223242526
  1. ; RUN: opt < %s -reassociate -instcombine -S | FileCheck %s
  2. ; With sub reassociation, constant folding can eliminate the 12 and -12 constants.
  3. define i32 @test1(i32 %A, i32 %B) {
  4. ; CHECK-LABEL: @test1
  5. ; CHECK-NEXT: %Z = sub i32 %A, %B
  6. ; CHECK-NEXT: ret i32 %Z
  7. %X = add i32 -12, %A
  8. %Y = sub i32 %X, %B
  9. %Z = add i32 %Y, 12
  10. ret i32 %Z
  11. }
  12. ; PR2047
  13. ; With sub reassociation, constant folding can eliminate the uses of %a.
  14. define i32 @test2(i32 %a, i32 %b, i32 %c) nounwind {
  15. ; CHECK-LABEL: @test2
  16. ; CHECK-NEXT: %sum = add i32 %c, %b
  17. ; CHECK-NEXT: %tmp7 = sub i32 0, %sum
  18. ; CHECK-NEXT: ret i32 %tmp7
  19. %tmp3 = sub i32 %a, %b
  20. %tmp5 = sub i32 %tmp3, %c
  21. %tmp7 = sub i32 %tmp5, %a
  22. ret i32 %tmp7
  23. }