Issue 56672
Summary [LoopRotate][LoopVectorize] Suspected broken analyzes after LoopRotate
Labels new issue
Assignees
Reporter max-quazan
    I am not sure if this particular thing is a bug, but looks *extremely* fishy.

Link 1: https://godbolt.org/z/1bfKdadx4
Link 2: https://godbolt.org/z/4hq1931ex

Test:
```
target datalayout = "e-m:e-p270:32:32-p271:32:32-p272:64:64-i64:64-f80:128-n8:16:32:64-S128-ni:1-p2:32:8:8:32-ni:2"
target triple = "x86_64-unknown-linux-gnu"

define void @test()  {
bb:
  br label %bb4

bb1:                                              ; preds = %bb4
  br label %bb2

bb2:                                              ; preds = %bb1
  store i32 1, i32 addrspace(1)* %tmp7, align 4
  %tmp = add nuw i64 %tmp5, 1
  %tmp3 = icmp ult i64 %tmp, undef
  br i1 %tmp3, label %bb4, label %bb11

bb4:                                              ; preds = %bb2, %bb
  %tmp5 = phi i64 [ %tmp, %bb2 ], [ 16, %bb ]
  %tmp6 = phi i64 [ %tmp5, %bb2 ], [ 15, %bb ]
  %tmp7 = getelementptr inbounds i32, i32 addrspace(1)* null, i64 %tmp5
  %tmp8 = load i32, i32 addrspace(1)* %tmp7, align 4
  %tmp9 = add i32 %tmp8, -5
  store i32 %tmp9, i32 addrspace(1)* %tmp7, align 4
  br i1 false, label %bb10, label %bb1

bb10:                                             ; preds = %bb4
  unreachable

bb11:                                             ; preds = %bb2
  ret void
}
```

Two run commands:
```
opt -passes='loop(loop-rotate),loop-vectorize' -S
opt -passes='loop(loop-rotate),invalidate<loops>,loop-vectorize' -S
```

In the former case, loop does vectorize. In the later case, it doesn't. For us, the vectorization is buggy (miscompile), but I could not figure out how to reduce test to demonstrate the miscompile yet.

The suspicion is that some analysis is in broken state after loop-rotate, and LV takes wrong decision basing on it.
_______________________________________________
llvm-bugs mailing list
[email protected]
https://lists.llvm.org/cgi-bin/mailman/listinfo/llvm-bugs

Reply via email to