xref: /llvm-project/llvm/test/Transforms/LoopInterchange/vector-gep-operand.ll (revision 456ec1c2f4e487de235c953e8f2832b97372e7b0)
1; Remove 'S' Scalar Dependencies #119345
2; Scalar dependencies are not handled correctly, so they were removed to avoid
3; miscompiles. The loop nest in this test case used to be interchanged, but it's
4; no longer triggering. XFAIL'ing this test to indicate that this test should
5; interchanged if scalar deps are handled correctly.
6;
7; XFAIL: *
8
9; RUN: opt -passes=loop-interchange -cache-line-size=64 -loop-interchange-threshold=-10 %s -pass-remarks-output=%t -disable-output
10; RUN: FileCheck -input-file %t %s
11
12; The test contains a GEP with an operand that is not SCEV-able. Make sure
13; loop-interchange does not crash.
14;
15; CHECK:       --- !Passed
16; CHECK-NEXT:  Pass:            loop-interchange
17; CHECK-NEXT:  Name:            Interchanged
18; CHECK-NEXT:  Function:        test
19; CHECK-NEXT:  Args:
20; CHECK-NEXT:    - String:          Loop interchanged with enclosing loop.
21
22define void @test(ptr noalias %src, ptr %dst) {
23entry:
24  br label %outer.header
25
26outer.header:
27  %i = phi i32 [ %i.next, %outer.latch ], [ 0, %entry ]
28  br label %inner
29
30inner:
31  %j = phi i64 [ 0, %outer.header ], [ %j.next, %inner ]
32  %src.gep = getelementptr inbounds [256 x float], ptr %src, <2 x i64> <i64 0, i64 1>, i64 %j
33  %src.0 = extractelement <2 x ptr> %src.gep, i32 0
34  %lv.0 = load float, ptr %src.0
35  %add.0 = fadd float %lv.0, 1.0
36  %dst.gep = getelementptr inbounds float, ptr %dst, i64 %j
37  store float %add.0, ptr %dst.gep
38  %j.next = add nuw nsw i64 %j, 1
39  %inner.exitcond = icmp eq i64 %j.next, 100
40  br i1 %inner.exitcond, label %outer.latch, label %inner
41
42outer.latch:
43  %i.next = add nuw nsw i32 %i, 1
44  %outer.exitcond = icmp eq i32 %i.next, 100
45  br i1 %outer.exitcond, label %exit, label %outer.header
46
47exit:
48  ret void
49}
50