llvm/llvm/test/Transforms/PhaseOrdering/X86/pr67803.ll

; NOTE: Assertions have been autogenerated by utils/update_test_checks.py
; RUN: opt < %s -O3 -S -mtriple=x86_64-- -mcpu=x86-64-v2 | FileCheck %s
; RUN: opt < %s -O3 -S -mtriple=x86_64-- -mcpu=x86-64-v3 | FileCheck %s
; RUN: opt < %s -O3 -S -mtriple=x86_64-- -mcpu=x86-64-v4 | FileCheck %s

define <4 x i64> @PR67803(<4 x i64> %x, <4 x i64> %y, <4 x i64> %a, <4 x i64> %b) {
; CHECK-LABEL: @PR67803(
; CHECK-NEXT:  entry:
; CHECK-NEXT:    [[TMP0:%.*]] = bitcast <4 x i64> [[X:%.*]] to <8 x i32>
; CHECK-NEXT:    [[TMP1:%.*]] = bitcast <4 x i64> [[Y:%.*]] to <8 x i32>
; CHECK-NEXT:    [[TMP2:%.*]] = icmp sgt <8 x i32> [[TMP0]], [[TMP1]]
; CHECK-NEXT:    [[TMP3:%.*]] = bitcast <4 x i64> [[A:%.*]] to <32 x i8>
; CHECK-NEXT:    [[TMP4:%.*]] = shufflevector <32 x i8> [[TMP3]], <32 x i8> poison, <16 x i32> <i32 0, i32 1, i32 2, i32 3, i32 4, i32 5, i32 6, i32 7, i32 8, i32 9, i32 10, i32 11, i32 12, i32 13, i32 14, i32 15>
; CHECK-NEXT:    [[TMP5:%.*]] = bitcast <4 x i64> [[B:%.*]] to <32 x i8>
; CHECK-NEXT:    [[TMP6:%.*]] = shufflevector <32 x i8> [[TMP5]], <32 x i8> poison, <16 x i32> <i32 0, i32 1, i32 2, i32 3, i32 4, i32 5, i32 6, i32 7, i32 8, i32 9, i32 10, i32 11, i32 12, i32 13, i32 14, i32 15>
; CHECK-NEXT:    [[TMP7:%.*]] = shufflevector <8 x i1> [[TMP2]], <8 x i1> poison, <4 x i32> <i32 0, i32 1, i32 2, i32 3>
; CHECK-NEXT:    [[TMP8:%.*]] = bitcast <16 x i8> [[TMP4]] to <4 x i32>
; CHECK-NEXT:    [[TMP9:%.*]] = bitcast <16 x i8> [[TMP6]] to <4 x i32>
; CHECK-NEXT:    [[TMP10:%.*]] = select <4 x i1> [[TMP7]], <4 x i32> [[TMP9]], <4 x i32> [[TMP8]]
; CHECK-NEXT:    [[TMP11:%.*]] = bitcast <4 x i32> [[TMP10]] to <16 x i8>
; CHECK-NEXT:    [[TMP12:%.*]] = bitcast <4 x i64> [[A]] to <32 x i8>
; CHECK-NEXT:    [[TMP13:%.*]] = shufflevector <32 x i8> [[TMP12]], <32 x i8> poison, <16 x i32> <i32 16, i32 17, i32 18, i32 19, i32 20, i32 21, i32 22, i32 23, i32 24, i32 25, i32 26, i32 27, i32 28, i32 29, i32 30, i32 31>
; CHECK-NEXT:    [[TMP14:%.*]] = bitcast <4 x i64> [[B]] to <32 x i8>
; CHECK-NEXT:    [[TMP15:%.*]] = shufflevector <32 x i8> [[TMP14]], <32 x i8> poison, <16 x i32> <i32 16, i32 17, i32 18, i32 19, i32 20, i32 21, i32 22, i32 23, i32 24, i32 25, i32 26, i32 27, i32 28, i32 29, i32 30, i32 31>
; CHECK-NEXT:    [[TMP16:%.*]] = shufflevector <8 x i1> [[TMP2]], <8 x i1> poison, <4 x i32> <i32 4, i32 5, i32 6, i32 7>
; CHECK-NEXT:    [[TMP17:%.*]] = bitcast <16 x i8> [[TMP13]] to <4 x i32>
; CHECK-NEXT:    [[TMP18:%.*]] = bitcast <16 x i8> [[TMP15]] to <4 x i32>
; CHECK-NEXT:    [[TMP19:%.*]] = select <4 x i1> [[TMP16]], <4 x i32> [[TMP18]], <4 x i32> [[TMP17]]
; CHECK-NEXT:    [[TMP20:%.*]] = bitcast <4 x i32> [[TMP19]] to <16 x i8>
; CHECK-NEXT:    [[TMP21:%.*]] = shufflevector <16 x i8> [[TMP11]], <16 x i8> [[TMP20]], <32 x i32> <i32 0, i32 1, i32 2, i32 3, i32 4, i32 5, i32 6, i32 7, i32 8, i32 9, i32 10, i32 11, i32 12, i32 13, i32 14, i32 15, i32 16, i32 17, i32 18, i32 19, i32 20, i32 21, i32 22, i32 23, i32 24, i32 25, i32 26, i32 27, i32 28, i32 29, i32 30, i32 31>
; CHECK-NEXT:    [[SHUFFLE_I23:%.*]] = bitcast <32 x i8> [[TMP21]] to <4 x i64>
; CHECK-NEXT:    ret <4 x i64> [[SHUFFLE_I23]]
;
entry:
  %0 = bitcast <4 x i64> %x to <8 x i32>
  %extract = shufflevector <8 x i32> %0, <8 x i32> poison, <4 x i32> <i32 0, i32 1, i32 2, i32 3>
  %1 = bitcast <4 x i32> %extract to <2 x i64>
  %2 = bitcast <4 x i64> %y to <8 x i32>
  %extract1 = shufflevector <8 x i32> %2, <8 x i32> poison, <4 x i32> <i32 0, i32 1, i32 2, i32 3>
  %3 = bitcast <4 x i32> %extract1 to <2 x i64>
  %cmp.i21 = icmp sgt <4 x i32> %extract, %extract1
  %sext.i22 = sext <4 x i1> %cmp.i21 to <4 x i32>
  %4 = bitcast <4 x i32> %sext.i22 to <2 x i64>
  %extract2 = shufflevector <8 x i32> %0, <8 x i32> poison, <4 x i32> <i32 4, i32 5, i32 6, i32 7>
  %5 = bitcast <4 x i32> %extract2 to <2 x i64>
  %extract3 = shufflevector <8 x i32> %2, <8 x i32> poison, <4 x i32> <i32 4, i32 5, i32 6, i32 7>
  %6 = bitcast <4 x i32> %extract3 to <2 x i64>
  %cmp.i = icmp sgt <4 x i32> %extract2, %extract3
  %sext.i = sext <4 x i1> %cmp.i to <4 x i32>
  %7 = bitcast <4 x i32> %sext.i to <2 x i64>
  %shuffle.i = shufflevector <2 x i64> %4, <2 x i64> %7, <4 x i32> <i32 0, i32 1, i32 2, i32 3>
  %8 = bitcast <4 x i64> %a to <8 x i32>
  %extract6 = shufflevector <8 x i32> %8, <8 x i32> poison, <4 x i32> <i32 0, i32 1, i32 2, i32 3>
  %9 = bitcast <4 x i32> %extract6 to <2 x i64>
  %10 = bitcast <4 x i64> %b to <8 x i32>
  %extract7 = shufflevector <8 x i32> %10, <8 x i32> poison, <4 x i32> <i32 0, i32 1, i32 2, i32 3>
  %11 = bitcast <4 x i32> %extract7 to <2 x i64>
  %12 = bitcast <4 x i64> %shuffle.i to <8 x i32>
  %extract8 = shufflevector <8 x i32> %12, <8 x i32> poison, <4 x i32> <i32 0, i32 1, i32 2, i32 3>
  %13 = bitcast <4 x i32> %extract8 to <2 x i64>
  %14 = bitcast <2 x i64> %9 to <16 x i8>
  %15 = bitcast <2 x i64> %11 to <16 x i8>
  %16 = bitcast <2 x i64> %13 to <16 x i8>
  %17 = call <16 x i8> @llvm.x86.sse41.pblendvb(<16 x i8> %14, <16 x i8> %15, <16 x i8> %16)
  %18 = bitcast <16 x i8> %17 to <2 x i64>
  %extract10 = shufflevector <8 x i32> %8, <8 x i32> poison, <4 x i32> <i32 4, i32 5, i32 6, i32 7>
  %19 = bitcast <4 x i32> %extract10 to <2 x i64>
  %extract11 = shufflevector <8 x i32> %10, <8 x i32> poison, <4 x i32> <i32 4, i32 5, i32 6, i32 7>
  %20 = bitcast <4 x i32> %extract11 to <2 x i64>
  %extract12 = shufflevector <8 x i32> %12, <8 x i32> poison, <4 x i32> <i32 4, i32 5, i32 6, i32 7>
  %21 = bitcast <4 x i32> %extract12 to <2 x i64>
  %22 = bitcast <2 x i64> %19 to <16 x i8>
  %23 = bitcast <2 x i64> %20 to <16 x i8>
  %24 = bitcast <2 x i64> %21 to <16 x i8>
  %25 = call <16 x i8> @llvm.x86.sse41.pblendvb(<16 x i8> %22, <16 x i8> %23, <16 x i8> %24)
  %26 = bitcast <16 x i8> %25 to <2 x i64>
  %shuffle.i23 = shufflevector <2 x i64> %18, <2 x i64> %26, <4 x i32> <i32 0, i32 1, i32 2, i32 3>
  ret <4 x i64> %shuffle.i23
}