Skip to content

Commit 71dd530

Browse files
committed
[Reassociate] Add precommit tests for Reassociate factorise nsw/nuw flag
1 parent 1e7624c commit 71dd530

File tree

1 file changed

+37
-0
lines changed

1 file changed

+37
-0
lines changed

llvm/test/Transforms/Reassociate/basictest.ll

Lines changed: 37 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -293,3 +293,40 @@ define i32 @test17(i32 %X1, i32 %X2, i32 %X3, i32 %X4) {
293293
ret i32 %E
294294
}
295295

296+
define i32 @test18(i32 %X1, i32 %X2) {
297+
; CHECK-LABEL: @test18(
298+
; CHECK-NEXT: [[REASS_ADD:%.*]] = add i32 [[X2:%.*]], [[X1:%.*]]
299+
; CHECK-NEXT: [[REASS_MUL:%.*]] = mul i32 [[REASS_ADD]], 47
300+
; CHECK-NEXT: ret i32 [[REASS_MUL]]
301+
;
302+
%B = mul nsw i32 %X1, 47
303+
%C = mul nsw i32 %X2, 47
304+
%D = add nsw i32 %B, %C
305+
ret i32 %D
306+
}
307+
308+
define i32 @test19(i32 %X1, i32 %X2) {
309+
; CHECK-LABEL: @test19(
310+
; CHECK-NEXT: [[REASS_ADD:%.*]] = add i32 [[X1:%.*]], 67
311+
; CHECK-NEXT: [[REASS_MUL:%.*]] = mul i32 [[REASS_ADD]], [[X2:%.*]]
312+
; CHECK-NEXT: ret i32 [[REASS_MUL]]
313+
;
314+
%A = add i32 %X1, 20
315+
%B = mul nsw i32 %X2, 47
316+
%C = mul nsw i32 %X2, %A
317+
%D = add nsw i32 %B, %C
318+
ret i32 %D
319+
}
320+
321+
define i32 @test20(i32 %X1, i32 %X2) {
322+
; CHECK-LABEL: @test20(
323+
; CHECK-NEXT: [[REASS_ADD:%.*]] = add i32 [[X1:%.*]], 67
324+
; CHECK-NEXT: [[REASS_MUL:%.*]] = mul i32 [[REASS_ADD]], [[X2:%.*]]
325+
; CHECK-NEXT: ret i32 [[REASS_MUL]]
326+
;
327+
%A = add i32 %X1, 20
328+
%B = mul nuw i32 %X2, 47
329+
%C = mul nsw i32 %X2, %A
330+
%D = add nsw i32 %B, %C
331+
ret i32 %D
332+
}

0 commit comments

Comments
 (0)