Skip to content

Commit 4f8597f

Browse files
authored
[LoopInterchange] Add test for floating point math flags (#149090)
Adding a test where both `ninf` and `reassoc` flags are present on the instruction. We don't know yet if it is legal to interchange. Prima facie, it does not look like it should be legal but more analysis is needed.
1 parent 3de11b7 commit 4f8597f

File tree

1 file changed

+38
-0
lines changed

1 file changed

+38
-0
lines changed

llvm/test/Transforms/LoopInterchange/reductions-non-wrapped-operations.ll

Lines changed: 38 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -411,6 +411,44 @@ exit:
411411
ret void
412412
}
413413

414+
; FIXME: Is it really legal to interchange the loops when
415+
; both reassoc and ninf are set?
416+
; Check that the interchange is legal if the floating-point addition is marked
417+
; as reassoc.
418+
;
419+
; CHECK: --- !Pass
420+
; CHECK-NEXT: Pass: loop-interchange
421+
; CHECK-NEXT: Name: Interchanged
422+
; CHECK-NEXT: Function: reduction_reassoc_ninf_fadd
423+
define void @reduction_reassoc_ninf_fadd(ptr %A) {
424+
entry:
425+
br label %for.i.header
426+
427+
for.i.header:
428+
%i = phi i32 [ 0, %entry ], [ %i.inc, %for.i.latch ]
429+
%sum.i = phi float [ 0.0, %entry ], [ %sum.i.lcssa, %for.i.latch ]
430+
br label %for.j
431+
432+
for.j:
433+
%j = phi i32 [ 0, %for.i.header ], [ %j.inc, %for.j ]
434+
%sum.j = phi float [ %sum.i, %for.i.header ], [ %sum.j.next, %for.j ]
435+
%idx = getelementptr inbounds [2 x [2 x i32]], ptr %A, i32 0, i32 %j, i32 %i
436+
%a = load float, ptr %idx, align 4
437+
%sum.j.next = fadd reassoc ninf float %sum.j, %a
438+
%j.inc = add i32 %j, 1
439+
%cmp.j = icmp slt i32 %j.inc, 2
440+
br i1 %cmp.j, label %for.j, label %for.i.latch
441+
442+
for.i.latch:
443+
%sum.i.lcssa = phi float [ %sum.j.next, %for.j ]
444+
%i.inc = add i32 %i, 1
445+
%cmp.i = icmp slt i32 %i.inc, 2
446+
br i1 %cmp.i, label %for.i.header, label %exit
447+
448+
exit:
449+
ret void
450+
}
451+
414452
; Check that the loops aren't exchanged if there is a reduction of
415453
; non-reassociative floating-point multiplication.
416454
;

0 commit comments

Comments
 (0)