1 ; NOTE: Assertions have been autogenerated by utils/update_test_checks.py
2 ; RUN: opt -S -reassociate < %s | FileCheck %s
5 ; Reassociate should clear optional flags like nsw when reassociating.
7 define i64 @test0(i64 %a, i64 %b, i64 %c) {
10 ; CHECK-NEXT: [[Y:%.*]] = add i64 [[B:%.*]], [[A:%.*]]
11 ; CHECK-NEXT: [[Z:%.*]] = add i64 [[Y]], [[C:%.*]]
12 ; CHECK-NEXT: ret i64 [[Z]]
14 %y = add nsw i64 %c, %b
19 define i64 @test1(i64 %a, i64 %b, i64 %c) {
21 ; CHECK-LABEL: @test1(
22 ; CHECK-NEXT: [[Y:%.*]] = add i64 [[B:%.*]], [[A:%.*]]
23 ; CHECK-NEXT: [[Z:%.*]] = add i64 [[Y]], [[C:%.*]]
24 ; CHECK-NEXT: ret i64 [[Z]]
27 %z = add nsw i64 %y, %a
32 define i32 @test2(i32 %x, i32 %y) {
34 ; CHECK-LABEL: @test2(
35 ; CHECK-NEXT: [[S:%.*]] = add nsw i32 [[Y:%.*]], [[X:%.*]]
36 ; CHECK-NEXT: ret i32 [[S]]
38 %s = add nsw i32 %x, %y