Skip to content

[LV] Assert "OpType must match" in VPIRFlags::intersectFlags #164171

@sjoerdmeijer

Description

@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 void @_Z1hiPA2_bPA2_c(ptr %arrayidx6, ptr %arrayidx20) {
entry:
  br label %for.body

for.cond.cleanup.loopexit:                        ; preds = %for.body
  ret void

for.body:                                         ; preds = %for.body, %entry
  %indvars.iv1 = phi i64 [ 0, %entry ], [ %indvars.iv.next, %for.body ]
  %0 = load i8, ptr %arrayidx6, align 1
  %loadedv = zext i8 %0 to i32
  %conv9 = trunc i32 %loadedv to i16
  store i16 %conv9, ptr null, align 2
  %1 = zext i8 %0 to i16
  store i16 %1, ptr %arrayidx20, align 2
  %indvars.iv.next = add i64 %indvars.iv1, 2
  %tobool.not = icmp eq i64 %indvars.iv.next, 0
  br i1 %tobool.not, label %for.cond.cleanup.loopexit, label %for.body
}

Compiled with opt --passes=loop-vectorize -S will triggers this assert:

opt: /root/llvm-project/llvm/lib/Transforms/Vectorize/VPlanRecipes.cpp:404: void llvm::VPIRFlags::intersectFlags(const llvm::VPIRFlags&): Assertion `OpType == Other.OpType && "OpType must match"' failed.
PLEASE submit a bug report to https://github.com/llvm/llvm-project/issues/ and include the crash backtrace and instructions to reproduce the bug.
Stack dump:
0.	Program arguments: /opt/compiler-explorer/clang-assertions-trunk/bin/opt -o /app/output.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 "_Z1hiPA2_bPA2_c"
 #0 0x0000000005944c48 llvm::sys::PrintStackTrace(llvm::raw_ostream&, int) (/opt/compiler-explorer/clang-assertions-trunk/bin/opt+0x5944c48)
 #1 0x0000000005941af4 SignalHandler(int, siginfo_t*, void*) Signals.cpp:0:0
 #2 0x0000718d16242520 (/lib/x86_64-linux-gnu/libc.so.6+0x42520)
 #3 0x0000718d162969fc pthread_kill (/lib/x86_64-linux-gnu/libc.so.6+0x969fc)
 #4 0x0000718d16242476 gsignal (/lib/x86_64-linux-gnu/libc.so.6+0x42476)
 #5 0x0000718d162287f3 abort (/lib/x86_64-linux-gnu/libc.so.6+0x287f3)
 #6 0x0000718d1622871b (/lib/x86_64-linux-gnu/libc.so.6+0x2871b)
 #7 0x0000718d16239e96 (/lib/x86_64-linux-gnu/libc.so.6+0x39e96)
 #8 0x00000000038376c4 (/opt/compiler-explorer/clang-assertions-trunk/bin/opt+0x38376c4)
 #9 0x0000000003888c73 llvm::VPlanTransforms::cse(llvm::VPlan&) (/opt/compiler-explorer/clang-assertions-trunk/bin/opt+0x3888c73)
#10 0x000000000367d30e llvm::LoopVectorizationPlanner::executePlan(llvm::ElementCount, unsigned int, llvm::VPlan&, llvm::InnerLoopVectorizer&, llvm::DominatorTree*, bool) (/opt/compiler-explorer/clang-assertions-trunk/bin/opt+0x367d30e)

See also: https://godbolt.org/z/nxzGcccff

Can be triggered from source-code:

#include <algorithm>
short a;
extern short b[];
int c;
void h(int d, bool e[][2], char f[][2]) {
#pragma clang loop vectorize_predicate(enable)
  for (int g(d); g; g += 2) {
    a = f[g][g] - e[g][g] - c;
    b[g] = std::max(d ? (unsigned long long)e[g][g] : 0, (unsigned long long)0);
  }
}

Metadata

Metadata

Assignees

No one assigned

    Type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions