Issue 63294
Summary [NVPTX] Possible Infinite Loop introduced by `[NVPTX] Allow using v4i32 for memcpy lowering.`
Labels new issue
Assignees
Reporter justinfargnoli
    I believe that I've found an infinite loop introduced by [[NVPTX] Allow using v4i32 for memcpy lowering.](https://github.com/llvm/llvm-project/commit/c16b7e54ac5b). 

Pinging @Artem-B the author of that commit. 

The following input causes `llc` to timeout in [Compiler Explorer](https://godbolt.org/):
```
define <5 x i32> @and3_i32v(<5 x i32> %a, <5 x i32> %b) #0 {
  %cmp0 = icmp eq <5 x i32> %a, <i32 1, i32 2, i32 3, i32 4, i32 5>
  %cmp1 = icmp eq <5 x i32> %b, <i32 2, i32 3, i32 4, i32 5, i32 6>
  %sel = select <5 x i1> %cmp1, <5 x i32> %a, <5 x i32> %b
  %sel2 = select <5 x i1> %cmp0, <5 x i32> %sel, <5 x i32> %b
  ret <5 x i32> %sel2
} 
```
I was also able to observe the infinite loop on my local (modified) fork of LLVM. 

This seems to be the code that's causing the infinite loop ([link to the source code](https://github.com/llvm/llvm-project/blob/cdcbef1b14582f5b5b296bec750f60a1629ecc32/llvm/lib/CodeGen/SelectionDAG/SelectionDAGBuilder.cpp#L3410)):
```
 // We care about the legality of the operation after it has been type
 // legalized.
    while (TLI.getTypeAction(Ctx, VT) != TargetLoweringBase::TypeLegal)
      VT = TLI.getTypeToTransformTo(Ctx, VT);
```

When debugging the code I saw that `getTypeToTransformTo` would always set `VT` to `MVT::v4i32` because of "[NVPTX] Allow using v4i32 for memcpy lowering.". Yet, `getTypeAction(Ctx, MVT::v4i32)` returns `TypeSplitVector`, not `TypeLegal`. Thus, causing an infinite loop. 

CC @jholewinski NVPTX code owner. 
_______________________________________________
llvm-bugs mailing list
[email protected]
https://lists.llvm.org/cgi-bin/mailman/listinfo/llvm-bugs

Reply via email to