Files
clang-p2996/llvm/test/Transforms/SLPVectorizer/X86/reordered-top-scalars.ll
Alexey Bataev e4b9640867 [SLP]Improve bottom-to-top reordering.
Currently bottom-to-top reordering analysis counts orders of the
operands and then adds natural order counts for the operand users. It is
very conservative, this the user nodes themselves may require
reordering. Patch improves bottom-to-top analysis by checking for the
user nodes if they require/allows the reordring. If the user node must
be reordered, has reused scalars, is an alternate op vectorization node,
is a non-ordered gather node or may allow reordering because of the
reordered operands, such node is considered as the node that allows
reodring and is not counted as a node with the natural order.

Differential Revision: https://reviews.llvm.org/D120492
2022-02-28 06:48:46 -08:00

43 lines
1.9 KiB
LLVM

; NOTE: Assertions have been autogenerated by utils/update_test_checks.py
; RUN: opt -S --slp-vectorizer -mtriple=x86_64-unknown %s -slp-threshold=-5 | FileCheck %s
define i32 @test(i32* %isec) {
; CHECK-LABEL: @test(
; CHECK-NEXT: entry:
; CHECK-NEXT: [[ARRAYIDX10:%.*]] = getelementptr inbounds i32, i32* [[ISEC:%.*]], i32 0
; CHECK-NEXT: [[TMP0:%.*]] = bitcast i32* [[ARRAYIDX10]] to <2 x i32>*
; CHECK-NEXT: [[TMP1:%.*]] = load <2 x i32>, <2 x i32>* [[TMP0]], align 8
; CHECK-NEXT: [[TMP2:%.*]] = extractelement <2 x i32> [[TMP1]], i32 1
; CHECK-NEXT: [[TMP3:%.*]] = insertelement <2 x i32> poison, i32 [[TMP2]], i32 0
; CHECK-NEXT: [[TMP4:%.*]] = extractelement <2 x i32> [[TMP1]], i32 0
; CHECK-NEXT: [[TMP5:%.*]] = insertelement <2 x i32> [[TMP3]], i32 [[TMP4]], i32 1
; CHECK-NEXT: br i1 false, label [[BLOCK1:%.*]], label [[BLOCK3:%.*]]
; CHECK: block1:
; CHECK-NEXT: br i1 false, label [[BLOCK2:%.*]], label [[BLOCK3]]
; CHECK: block2:
; CHECK-NEXT: br label [[BLOCK3]]
; CHECK: block3:
; CHECK-NEXT: [[TMP6:%.*]] = phi <2 x i32> [ [[TMP1]], [[BLOCK1]] ], [ [[TMP1]], [[BLOCK2]] ], [ [[TMP5]], [[ENTRY:%.*]] ]
; CHECK-NEXT: [[TMP7:%.*]] = extractelement <2 x i32> [[TMP6]], i32 0
; CHECK-NEXT: [[TMP8:%.*]] = extractelement <2 x i32> [[TMP6]], i32 1
; CHECK-NEXT: [[TMP9:%.*]] = mul i32 [[TMP8]], [[TMP7]]
; CHECK-NEXT: ret i32 [[TMP9]]
;
entry:
%arrayidx10 = getelementptr inbounds i32, i32* %isec, i32 0
%0 = bitcast i32* %arrayidx10 to <2 x i32>*
%1 = load <2 x i32>, <2 x i32>* %0, align 8
%2 = extractelement <2 x i32> %1, i32 1
%3 = extractelement <2 x i32> %1, i32 0
br i1 false, label %block1, label %block3
block1:
br i1 false, label %block2, label %block3
block2:
br label %block3
block3:
%4 = phi i32 [ %2, %block1 ], [ %2, %block2 ], [ %3, %entry ]
%5 = phi i32 [ %3, %block1 ], [ %3, %block2 ], [ %2, %entry ]
%6 = mul i32 %4, %5
ret i32 %6
}