Fix reassociate to clear optional flags, such as nsw.
[oota-llvm.git] / test / Transforms / Reassociate / optional-flags.ll
1 ; RUN: opt -S -reassociate < %s | FileCheck %s
2 ; rdar://8944681
3
4 ; Reassociate should clear optional flags like nsw when reassociating.
5
6 ; CHECK: @test0
7 ; CHECK: %y = add i64 %b, %a
8 ; CHECK: %z = add i64 %y, %c
9 define i64 @test0(i64 %a, i64 %b, i64 %c) {
10   %y = add nsw i64 %c, %b
11   %z = add i64 %y, %a
12   ret i64 %z
13 }
14
15 ; CHECK: @test1
16 ; CHECK: %y = add i64 %b, %a
17 ; CHECK: %z = add i64 %y, %c
18 define i64 @test1(i64 %a, i64 %b, i64 %c) {
19   %y = add i64 %c, %b
20   %z = add nsw i64 %y, %a
21   ret i64 %z
22 }