Issue 180340
Summary [LV] VPWidenRecipe triggers: "Cannot create binary operator ..."
Labels bug, vectorizers, crash-on-valid
Assignees
Reporter sjoerdmeijer
    This IR:

```
target datalayout = "e-m:e-p270:32:32-p271:32:32-p272:64:64-i8:8:32-i16:16:32-i64:64-i128:128-n32:64-S128-Fn32"
target triple = "aarch64-unknown-linux-gnu"

define i64 @_Z1dv() #0 {
entry:
 br label %for.cond1.preheader

for.cond1.preheader: ; preds = %for.cond1.preheader, %entry
  %a.promoted.pre = phi i64 [ 0, %entry ], [ %sub.4, %for.cond1.preheader ]
  %e.044 = phi i32 [ 0, %entry ], [ %add26, %for.cond1.preheader ]
  %0 = load i32, ptr null, align 4
 %conv10 = sext i32 %0 to i64
  %sub.2 = add i64 %conv10, %a.promoted.pre
 %1 = shl i64 %conv10, 0
  %sub.4 = sub i64 %sub.2, %1
  %add26 = add i32 %e.044, 1
  %cmp = icmp ult i32 %e.044, 78
  br i1 %cmp, label %for.cond1.preheader, label %for.cond.cleanup

for.cond.cleanup: ; preds = %for.cond1.preheader
  ret i64 %sub.4
}

attributes #0 = { "target-cpu"="grace" }
```

Triggers this assert:

```
opt: /root/llvm-project/llvm/lib/IR/Instructions.cpp:2707: static llvm::BinaryOperator* llvm::BinaryOperator::Create(llvm::Instruction::BinaryOps,
llvm::Value*, llvm::Value*, const llvm::Twine&, llvm::InsertPosition): Assertion `S1->getType() == S2->getType() && "Cannot create binary
operator with two operands of differing type!"' failed.
```

Stack trace:

```
Stack dump:
0.	Program arguments: /opt/compiler-explorer/clang-assertions-trunk/bin/opt -o /app/output.s -S -S -passes=loop-vectorize <source>
1.	Running pass "function(loop-vectorize<no-interleave-forced-only;no-vectorize-forced-only;>)" on module "<source>"
2.	Running pass "loop-vectorize<no-interleave-forced-only;no-vectorize-forced-only;>" on function "_Z1dv"
 #0 0x0000000005b3a5f8 llvm::sys::PrintStackTrace(llvm::raw_ostream&, int) (/opt/compiler-explorer/clang-assertions-trunk/bin/opt+0x5b3a5f8)
 #1 0x0000000005b374d4 SignalHandler(int, siginfo_t*, void*) Signals.cpp:0:0
 #2 0x00007abb36c42520 (/lib/x86_64-linux-gnu/libc.so.6+0x42520)
 #3 0x00007abb36c969fc pthread_kill (/lib/x86_64-linux-gnu/libc.so.6+0x969fc)
 #4 0x00007abb36c42476 gsignal (/lib/x86_64-linux-gnu/libc.so.6+0x42476)
 #5 0x00007abb36c287f3 abort (/lib/x86_64-linux-gnu/libc.so.6+0x287f3)
 #6 0x00007abb36c2871b (/lib/x86_64-linux-gnu/libc.so.6+0x2871b)
 #7 0x00007abb36c39e96 (/lib/x86_64-linux-gnu/libc.so.6+0x39e96)
 #8 0x0000000005808d43 (/opt/compiler-explorer/clang-assertions-trunk/bin/opt+0x5808d43)
 #9 0x0000000005813eaf (/opt/compiler-explorer/clang-assertions-trunk/bin/opt+0x5813eaf)
#10 0x00000000057f4893 llvm::IRBuilderBase::CreateNAryOp(unsigned int, llvm::ArrayRef<llvm::Value*>, llvm::Twine const&, llvm::MDNode*) (/opt/compiler-explorer/clang-assertions-trunk/bin/opt+0x57f4893)
#11 0x0000000003993db2 llvm::VPWidenRecipe::execute(llvm::VPTransformState&) (/opt/compiler-explorer/clang-assertions-trunk/bin/opt+0x3993db2)
#12 0x00000000039307e3 llvm::VPBasicBlock::executeRecipes(llvm::VPTransformState*, llvm::BasicBlock*) (/opt/compiler-explorer/clang-assertions-trunk/bin/opt+0x39307e3)
#13 0x0000000003947445 llvm::VPBasicBlock::execute(llvm::VPTransformState*) (/opt/compiler-explorer/clang-assertions-trunk/bin/opt+0x3947445)
#14 0x000000000394c93a llvm::VPlan::execute(llvm::VPTransformState*) (/opt/compiler-explorer/clang-assertions-trunk/bin/opt+0x394c93a)
```

Compile with `opt -S -passes=loop-vectorize bug.ll`, see also: https://godbolt.org/z/6597hvdeP


_______________________________________________
llvm-bugs mailing list
[email protected]
https://lists.llvm.org/cgi-bin/mailman/listinfo/llvm-bugs

Reply via email to