[llvm] Revert "[SLP]Support revectorization of the previously vectorized scalars" (PR #134604)

Alexey Bataev via llvm-commits llvm-commits at lists.llvm.org
Mon Apr 7 09:30:42 PDT 2025


alexey-bataev wrote:

> Another crash:
> 
> ```
> 0.      Program arguments: ./clang-bad --target=aarch64-unknown-linux-gnu -c -o /dev/null -O2 reduced.ll
> 1.      Optimizer
> 2.      Running pass "function<eager-inv>(float2int,lower-constant-intrinsics,loop(loop-rotate<header-duplication;no-prepare-for-lto>,loop-deletion),loop-distribute,inject-tli-mappings,loop-vectorize<no-interleave-forced-only;no-vectorize-forced-only;>,infer-alignment,loop-load-elim,instcombine<max-iterations=1;no-verify-fixpoint>,simplifycfg<bonus-inst-threshold=1;forward-switch-cond;switch-range-to-icmp;switch-to-lookup;no-keep-loops;hoist-common-insts;no-hoist-loads-stores-with-cond-faulting;sink-common-insts;speculate-blocks;simplify-cond-branch;no-speculate-unpredictables>,slp-vectorizer,vector-combine,instcombine<max-iterations=1;no-verify-fixpoint>,loop-unroll<O2>,transform-warning,sroa<preserve-cfg>,infer-alignment,instcombine<max-iterations=1;no-verify-fixpoint>,loop-mssa(licm<allowspeculation>),alignment-from-assumptions,loop-sink,instsimplify,div-rem-pairs,tailcallelim,simplifycfg<bonus-inst-threshold=1;no-forward-switch-cond;switch-range-to-icmp;no-switch-to-lookup;keep-loops;no-hoist-common-insts;hoist-loads-stores-with-cond-faulting;no-sink-common-insts;speculate-blocks;simplify-cond-branch;speculate-unpredictables>)" on module "reduced.ll"
> 3.      Running pass "slp-vectorizer" on function "f"
> ```
> 
> Test:
> 
> ```
> 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"
> 
> ; Function Attrs: nocallback nofree nosync nounwind speculatable willreturn memory(none)
> declare i64 @llvm.objectsize.i64.p0(ptr, i1 immarg, i1 immarg, i1 immarg) #0
> 
> define void @f(ptr %0, i32 %1, i32 %.240, i8 %.2, i64 %2, i1 %.not59, i1 %.not60, ptr %3, ptr %4, i8 %5) {
>   %7 = alloca [3 x i32], align 4
>   br label %8
> 
> 8:                                                ; preds = %9, %6
>   br label %9
> 
> 9:                                                ; preds = %47, %34, %23, %8
>   %.2402 = phi i32 [ %.240, %8 ], [ 0, %47 ], [ 0, %34 ], [ 0, %23 ]
>   %10 = icmp slt i32 %.2402, %1
>   br i1 %10, label %11, label %8
> 
> 11:                                               ; preds = %20, %9
>   %.041 = phi i32 [ %21, %20 ], [ 0, %9 ]
>   %.24 = phi i8 [ %.3, %20 ], [ 0, %9 ]
>   %12 = icmp slt i32 %.041, 4
>   br i1 %12, label %13, label %22
> 
> 13:                                               ; preds = %11
>   br i1 %.not59, label %20, label %14
> 
> 14:                                               ; preds = %13
>   %15 = zext i8 %5 to i32
>   %16 = zext i8 %.2 to i32
>   %17 = trunc i32 %.041 to i8
>   store i32 %16, ptr %7, align 4
>   %18 = getelementptr i8, ptr %7, i64 4
>   store i32 %16, ptr %18, align 4
>   %19 = getelementptr i8, ptr %7, i64 8
>   store i32 %15, ptr %19, align 4
>   br label %20
> 
> 20:                                               ; preds = %14, %13
>   %.3 = phi i8 [ %17, %14 ], [ %.2, %13 ]
>   %21 = add i32 %.041, 1
>   br label %11
> 
> 22:                                               ; preds = %11
>   switch i8 %.24, label %56 [
>     i8 0, label %23
>     i8 2, label %34
>     i8 3, label %44
>   ]
> 
> 23:                                               ; preds = %25, %22
>   %.042 = phi i32 [ %33, %25 ], [ 0, %22 ]
>   %24 = icmp slt i32 %.042, 3
>   br i1 %24, label %25, label %9
> 
> 25:                                               ; preds = %23
>   %26 = sext i32 %.042 to i64
>   %27 = getelementptr [3 x i32], ptr %7, i64 0, i64 %26
>   %28 = call i64 @llvm.objectsize.i64.p0(ptr %27, i1 false, i1 false, i1 false)
>   %29 = icmp ne i64 %28, 0
>   call void @llvm.assume(i1 %29)
>   %30 = load i32, ptr %27, align 4
>   %31 = mul i32 %30, 3
>   %32 = getelementptr [3 x i32], ptr %3, i64 0, i64 %26
>   store i32 %31, ptr %32, align 4
>   %33 = add i32 %.042, 1
>   br label %23
> 
> 34:                                               ; preds = %40, %22
>   %.143 = phi i32 [ %43, %40 ], [ 0, %22 ]
>   %35 = icmp slt i32 %.143, 3
>   br i1 %35, label %36, label %9
> 
> 36:                                               ; preds = %34
>   %37 = sext i32 %.143 to i64
>   %38 = or i64 %2, %37
>   %.not = icmp eq i64 %38, 0
>   br i1 %.not, label %39, label %40
> 
> 39:                                               ; preds = %36
>   store volatile i64 0, ptr null, align 8
>   unreachable
> 
> 40:                                               ; preds = %36
>   %41 = getelementptr [3 x i32], ptr %7, i64 0, i64 %37
>   %42 = load i32, ptr %41, align 4
>   store i32 %42, ptr %0, align 4
>   %43 = add i32 %.143, 1
>   br label %34
> 
> 44:                                               ; preds = %45, %22
>   br i1 %.not60, label %45, label %47
> 
> 45:                                               ; preds = %44
>   %46 = load i32, ptr %7, align 4
>   store i32 %46, ptr %0, align 4
>   br label %44
> 
> 47:                                               ; preds = %49, %44
>   %.345 = phi i32 [ %55, %49 ], [ 0, %44 ]
>   %48 = icmp slt i32 %.345, 3
>   br i1 %48, label %49, label %9
> 
> 49:                                               ; preds = %47
>   %50 = sext i32 %.345 to i64
>   %51 = getelementptr [3 x i32], ptr %7, i64 0, i64 %50
>   %52 = load i32, ptr %51, align 4
>   %53 = shl i32 %52, 1
>   %54 = getelementptr [3 x i32], ptr %4, i64 0, i64 %50
>   store i32 %53, ptr %54, align 4
>   %55 = add i32 %.345, 1
>   br label %47
> 
> 56:                                               ; preds = %22
>   unreachable
> }
> 
> ; Function Attrs: nocallback nofree nosync nounwind willreturn memory(inaccessiblemem: write)
> declare void @llvm.assume(i1 noundef) #1
> 
> attributes #0 = { nocallback nofree nosync nounwind speculatable willreturn memory(none) }
> attributes #1 = { nocallback nofree nosync nounwind willreturn memory(inaccessiblemem: write) }
> ```

Looks like also fixed by f413772b318c2da4dfc488df81cb3c458606301f

https://github.com/llvm/llvm-project/pull/134604


More information about the llvm-commits mailing list