llvm-project/llvm/test/Transforms/SLPVectorizer/X86/user-node-with-same-last-instr.ll
Alexey Bataev fb86b3d96b [SLP]Change the insertion point for outside-block-used nodes and prevec phi operand gathers
Need to set the insertion point for (non-schedulable) vector node after
the last instruction in the node to avoid def-use breakage. But it also
causes miscompilation with gather/buildvector operands of the phi nodes,
used in the same phi only in the block.
These nodes supposed to be inserted at the end of the block and after
changing the insertion point for the non-schedulable vec block, it also
may break def-use dependencies. Need to prevector such nodes, to emit
them as early as possible, so the vectorized nodes are inserted before
these nodes.

Fixes #139728

Recommit after revert 60fb92179291e848eb7b04913bdc818d081db296

Reviewers: hiraditya, HanKuanChen, RKSimon

Reviewed By: RKSimon

Pull Request: https://github.com/llvm/llvm-project/pull/139917
2025-05-18 12:59:36 -07:00

50 lines
1.9 KiB
LLVM

; NOTE: Assertions have been autogenerated by utils/update_test_checks.py UTC_ARGS: --version 5
; RUN: opt -S --passes=slp-vectorizer -mtriple=x86_64-unknown-linux-gnu -slp-threshold=-99999 < %s | FileCheck %s
define void @wombat(i32 %arg) {
; CHECK-LABEL: define void @wombat(
; CHECK-SAME: i32 [[ARG:%.*]]) {
; CHECK-NEXT: [[BB:.*:]]
; CHECK-NEXT: br label %[[BB1:.*]]
; CHECK: [[BB1]]:
; CHECK-NEXT: br i1 false, label %[[BB2:.*]], label %[[BB5:.*]]
; CHECK: [[BB2]]:
; CHECK-NEXT: [[TMP0:%.*]] = phi <2 x i32> [ [[TMP4:%.*]], %[[BB4:.*]] ], [ zeroinitializer, %[[BB1]] ]
; CHECK-NEXT: [[TMP1:%.*]] = insertelement <2 x i32> <i32 poison, i32 1>, i32 [[ARG]], i32 0
; CHECK-NEXT: [[TMP5:%.*]] = insertelement <2 x i32> <i32 poison, i32 0>, i32 [[ARG]], i32 0
; CHECK-NEXT: [[TMP2:%.*]] = sub <2 x i32> [[TMP0]], [[TMP1]]
; CHECK-NEXT: [[TMP3:%.*]] = or <2 x i32> [[TMP0]], [[TMP1]]
; CHECK-NEXT: [[TMP4]] = shufflevector <2 x i32> [[TMP2]], <2 x i32> [[TMP3]], <2 x i32> <i32 0, i32 3>
; CHECK-NEXT: [[TMP6:%.*]] = sub <2 x i32> [[TMP0]], [[TMP5]]
; CHECK-NEXT: [[TMP7:%.*]] = and <2 x i32> [[TMP0]], [[TMP5]]
; CHECK-NEXT: [[TMP8:%.*]] = shufflevector <2 x i32> [[TMP6]], <2 x i32> [[TMP7]], <2 x i32> <i32 0, i32 3>
; CHECK-NEXT: br label %[[BB4]]
; CHECK: [[BB4]]:
; CHECK-NEXT: br i1 false, label %[[BB2]], label %[[BB5]]
; CHECK: [[BB5]]:
; CHECK-NEXT: [[TMP9:%.*]] = phi <2 x i32> [ zeroinitializer, %[[BB1]] ], [ [[TMP8]], %[[BB4]] ]
; CHECK-NEXT: ret void
;
bb:
br label %bb1
bb1:
br i1 false, label %bb2, label %bb5
bb2:
%phi = phi i32 [ %or, %bb4 ], [ 0, %bb1 ]
%phi3 = phi i32 [ %sub, %bb4 ], [ 0, %bb1 ]
%or = or i32 %phi, 1
%and = and i32 0, %phi
%sub = sub i32 %phi3, %arg
br label %bb4
bb4:
br i1 false, label %bb2, label %bb5
bb5:
%phi6 = phi i32 [ 0, %bb1 ], [ %and, %bb4 ]
%phi7 = phi i32 [ 0, %bb1 ], [ %sub, %bb4 ]
ret void
}