[Reassociate] Use test cases that can actually be optimized to verify optional
[oota-llvm.git] / test / Transforms / Reassociate / optional-flags.ll
1 ; RUN: opt -S -reassociate -dce < %s | FileCheck %s
2 ; rdar://8944681
3
4 ; Reassociate should clear optional flags like nsw when reassociating.
5
6 ; CHECK-LABEL: @test0(
7 ; CHECK: %z = add i64 %b, 2
8 define i64 @test0(i64 %a, i64 %b) {
9   %x = add nsw i64 %a, 2
10   %y = add nsw i64 %x, %b
11   %z = sub nsw i64 %y, %a
12   ret i64 %z
13 }
14
15 ; CHECK-LABEL: @test1(
16 ; CHECK: %y = mul i64 %a, 6
17 ; CHECK: %z = sub nsw i64 %y, %a
18 define i64 @test1(i64 %a, i64 %b) {
19   %x = add nsw i64 %a, %a
20   %y = mul nsw i64 %x, 3
21   %z = sub nsw i64 %y, %a
22   ret i64 %z
23 }
24
25 ; PR9215
26 ; CHECK: %s = add nsw i32 %x, %y
27 define i32 @test2(i32 %x, i32 %y) {
28   %s = add nsw i32 %x, %y
29   ret i32 %s
30 }