; NOTE: Assertions have been autogenerated by utils/update_test_checks.py UTC_ARGS: --version 4 ; RUN: opt -S -passes=instcombine < %s | FileCheck %s define <4 x i1> @hadd_and_eq_v4i32(<4 x i32> %x, <4 x i32> %y) { ; CHECK-LABEL: define <4 x i1> @hadd_and_eq_v4i32( ; CHECK-SAME: <4 x i32> [[X:%.*]], <4 x i32> [[Y:%.*]]) { ; CHECK-NEXT: entry: ; CHECK-NEXT: ret <4 x i1> zeroinitializer ; entry: %and1 = and <4 x i32> %x, %and2 = and <4 x i32> %y, %hadd = tail call <4 x i32> @llvm.x86.ssse3.phadd.d.128(<4 x i32> %and1, <4 x i32> %and2) %andr = and <4 x i32> %hadd, %ret = icmp eq <4 x i32> %andr, ret <4 x i1> %ret } define <8 x i1> @hadd_and_eq_v8i16(<8 x i16> %x, <8 x i16> %y) { ; CHECK-LABEL: define <8 x i1> @hadd_and_eq_v8i16( ; CHECK-SAME: <8 x i16> [[X:%.*]], <8 x i16> [[Y:%.*]]) { ; CHECK-NEXT: entry: ; CHECK-NEXT: ret <8 x i1> ; entry: %and1 = and <8 x i16> %x, %and2 = and <8 x i16> %y, %hadd = tail call <8 x i16> @llvm.x86.ssse3.phadd.w.128(<8 x i16> %and1, <8 x i16> %and2) %andr = and <8 x i16> %hadd, %ret = icmp eq <8 x i16> %andr, ret <8 x i1> %ret } define <8 x i1> @hadd_and_eq_v8i16_sat(<8 x i16> %x, <8 x i16> %y) { ; CHECK-LABEL: define <8 x i1> @hadd_and_eq_v8i16_sat( ; CHECK-SAME: <8 x i16> [[X:%.*]], <8 x i16> [[Y:%.*]]) { ; CHECK-NEXT: entry: ; CHECK-NEXT: ret <8 x i1> ; entry: %and1 = and <8 x i16> %x, %and2 = and <8 x i16> %y, %hadd = tail call <8 x i16> @llvm.x86.ssse3.phadd.sw.128(<8 x i16> %and1, <8 x i16> %and2) %andr = and <8 x i16> %hadd, %ret = icmp eq <8 x i16> %andr, ret <8 x i1> %ret } define <8 x i1> @hadd_and_eq_v8i32(<8 x i32> %x, <8 x i32> %y) { ; CHECK-LABEL: define <8 x i1> @hadd_and_eq_v8i32( ; CHECK-SAME: <8 x i32> [[X:%.*]], <8 x i32> [[Y:%.*]]) { ; CHECK-NEXT: entry: ; CHECK-NEXT: ret <8 x i1> zeroinitializer ; entry: %and1 = and <8 x i32> %x, %and2 = and <8 x i32> %y, %hadd = tail call <8 x i32> @llvm.x86.avx2.phadd.d(<8 x i32> %and1, <8 x i32> %and2) %andr = and <8 x i32> %hadd, %ret = icmp eq <8 x i32> %andr, ret <8 x i1> %ret } define <16 x i1> @hadd_and_eq_v16i16(<16 x i16> %x, <16 x i16> %y) { ; CHECK-LABEL: define <16 x i1> @hadd_and_eq_v16i16( ; CHECK-SAME: <16 x i16> [[X:%.*]], <16 x i16> [[Y:%.*]]) { ; CHECK-NEXT: entry: ; CHECK-NEXT: ret <16 x i1> ; entry: %and1 = and <16 x i16> %x, %and2 = and <16 x i16> %y, %hadd = tail call <16 x i16> @llvm.x86.avx2.phadd.w(<16 x i16> %and1, <16 x i16> %and2) %andr = and <16 x i16> %hadd, %ret = icmp eq <16 x i16> %andr, ret <16 x i1> %ret } define <16 x i1> @hadd_and_eq_v16i16_sat(<16 x i16> %x, <16 x i16> %y) { ; CHECK-LABEL: define <16 x i1> @hadd_and_eq_v16i16_sat( ; CHECK-SAME: <16 x i16> [[X:%.*]], <16 x i16> [[Y:%.*]]) { ; CHECK-NEXT: entry: ; CHECK-NEXT: ret <16 x i1> ; entry: %and1 = and <16 x i16> %x, %and2 = and <16 x i16> %y, %hadd = tail call <16 x i16> @llvm.x86.avx2.phadd.sw(<16 x i16> %and1, <16 x i16> %and2) %andr = and <16 x i16> %hadd, %ret = icmp eq <16 x i16> %andr, ret <16 x i1> %ret } define <4 x i1> @hsub_trunc_eq_v4i32(<4 x i32> %x, <4 x i32> %y) { ; CHECK-LABEL: define <4 x i1> @hsub_trunc_eq_v4i32( ; CHECK-SAME: <4 x i32> [[X:%.*]], <4 x i32> [[Y:%.*]]) { ; CHECK-NEXT: entry: ; CHECK-NEXT: ret <4 x i1> zeroinitializer ; entry: %or1 = or <4 x i32> %x, %or2 = or <4 x i32> %y, %hsub = tail call <4 x i32> @llvm.x86.ssse3.phsub.d.128(<4 x i32> %or1, <4 x i32> %or2) %conv = trunc <4 x i32> %hsub to <4 x i16> %ret = icmp eq <4 x i16> %conv, ret <4 x i1> %ret } define <8 x i1> @hsub_trunc_eq_v8i16(<8 x i16> %x, <8 x i16> %y) { ; CHECK-LABEL: define <8 x i1> @hsub_trunc_eq_v8i16( ; CHECK-SAME: <8 x i16> [[X:%.*]], <8 x i16> [[Y:%.*]]) { ; CHECK-NEXT: entry: ; CHECK-NEXT: ret <8 x i1> ; entry: %or1 = or <8 x i16> %x, %or2 = or <8 x i16> %y, %hsub = tail call <8 x i16> @llvm.x86.ssse3.phsub.w.128(<8 x i16> %or1, <8 x i16> %or2) %conv = trunc <8 x i16> %hsub to <8 x i8> %ret = icmp eq <8 x i8> %conv, ret <8 x i1> %ret } define <8 x i1> @hsub_and_eq_v8i16_sat(<8 x i16> %x, <8 x i16> %y) { ; CHECK-LABEL: define <8 x i1> @hsub_and_eq_v8i16_sat( ; CHECK-SAME: <8 x i16> [[X:%.*]], <8 x i16> [[Y:%.*]]) { ; CHECK-NEXT: entry: ; CHECK-NEXT: ret <8 x i1> splat (i1 true) ; entry: %or1 = or <8 x i16> %x, %or2 = or <8 x i16> %y, %and1 = and <8 x i16> %or1, %and2 = and <8 x i16> %or2, %hsub = tail call <8 x i16> @llvm.x86.ssse3.phsub.sw.128(<8 x i16> %and1, <8 x i16> %and2) %ret = icmp sle <8 x i16> %hsub, ret <8 x i1> %ret } define <8 x i1> @hsub_trunc_eq_v8i32(<8 x i32> %x, <8 x i32> %y) { ; CHECK-LABEL: define <8 x i1> @hsub_trunc_eq_v8i32( ; CHECK-SAME: <8 x i32> [[X:%.*]], <8 x i32> [[Y:%.*]]) { ; CHECK-NEXT: entry: ; CHECK-NEXT: ret <8 x i1> zeroinitializer ; entry: %or1 = or <8 x i32> %x, %or2 = or <8 x i32> %y, %hsub = tail call <8 x i32> @llvm.x86.avx2.phsub.d(<8 x i32> %or1, <8 x i32> %or2) %conv = trunc <8 x i32> %hsub to <8 x i16> %ret = icmp eq <8 x i16> %conv, ret <8 x i1> %ret } define <16 x i1> @hsub_trunc_eq_v16i16(<16 x i16> %x, <16 x i16> %y) { ; CHECK-LABEL: define <16 x i1> @hsub_trunc_eq_v16i16( ; CHECK-SAME: <16 x i16> [[X:%.*]], <16 x i16> [[Y:%.*]]) { ; CHECK-NEXT: entry: ; CHECK-NEXT: ret <16 x i1> ; entry: %or1 = or <16 x i16> %x, %or2 = or <16 x i16> %y, %hsub = tail call <16 x i16> @llvm.x86.avx2.phsub.w(<16 x i16> %or1, <16 x i16> %or2) %conv = trunc <16 x i16> %hsub to <16 x i8> %ret = icmp eq <16 x i8> %conv, ret <16 x i1> %ret } define <16 x i1> @hsub_and_eq_v16i16_sat(<16 x i16> %x, <16 x i16> %y) { ; CHECK-LABEL: define <16 x i1> @hsub_and_eq_v16i16_sat( ; CHECK-SAME: <16 x i16> [[X:%.*]], <16 x i16> [[Y:%.*]]) { ; CHECK-NEXT: entry: ; CHECK-NEXT: ret <16 x i1> splat (i1 true) ; entry: %or1 = or <16 x i16> %x, %or2 = or <16 x i16> %y, %and1 = and <16 x i16> %or1, %and2 = and <16 x i16> %or2, %hsub = tail call <16 x i16> @llvm.x86.avx2.phsub.sw(<16 x i16> %and1, <16 x i16> %and2) %ret = icmp sle <16 x i16> %hsub, ret <16 x i1> %ret } define <4 x i1> @hadd_shuffle_2st_v4i32(<4 x i32> %x, <4 x i32> %y) { ; CHECK-LABEL: define <4 x i1> @hadd_shuffle_2st_v4i32( ; CHECK-SAME: <4 x i32> [[X:%.*]], <4 x i32> [[Y:%.*]]) { ; CHECK-NEXT: entry: ; CHECK-NEXT: ret <4 x i1> splat (i1 true) ; entry: %and1 = and <4 x i32> %x, %and2 = and <4 x i32> %y, %hadd = tail call <4 x i32> @llvm.x86.ssse3.phadd.d.128(<4 x i32> %and1, <4 x i32> %and2) %shuf = shufflevector <4 x i32> %hadd, <4x i32> zeroinitializer, <4 x i32> %ret = icmp ne <4 x i32> %shuf, ret <4 x i1> %ret } define <4 x i1> @hadd_shuffle_4th_v4i32(<4 x i32> %x, <4 x i32> %y) { ; CHECK-LABEL: define <4 x i1> @hadd_shuffle_4th_v4i32( ; CHECK-SAME: <4 x i32> [[X:%.*]], <4 x i32> [[Y:%.*]]) { ; CHECK-NEXT: entry: ; CHECK-NEXT: ret <4 x i1> splat (i1 true) ; entry: %and1 = and <4 x i32> %x, %and2 = and <4 x i32> %y, %hadd = tail call <4 x i32> @llvm.x86.ssse3.phadd.d.128(<4 x i32> %and1, <4 x i32> %and2) %shuf = shufflevector <4 x i32> %hadd, <4x i32> zeroinitializer, <4 x i32> %ret = icmp ne <4 x i32> %shuf, ret <4 x i1> %ret } define <4 x i1> @hadd_shuffle_2st_negative_v4i32(<4 x i32> %x, <4 x i32> %y) { ; CHECK-LABEL: define <4 x i1> @hadd_shuffle_2st_negative_v4i32( ; CHECK-SAME: <4 x i32> [[X:%.*]], <4 x i32> [[Y:%.*]]) { ; CHECK-NEXT: entry: ; CHECK-NEXT: [[TMP0:%.*]] = and <4 x i32> [[X]], ; CHECK-NEXT: [[TMP1:%.*]] = and <4 x i32> [[Y]], splat (i32 3) ; CHECK-NEXT: [[TMP2:%.*]] = tail call <4 x i32> @llvm.x86.ssse3.phadd.d.128(<4 x i32> [[TMP0]], <4 x i32> [[TMP1]]) ; CHECK-NEXT: [[TMP3:%.*]] = shufflevector <4 x i32> [[TMP2]], <4 x i32> , <4 x i32> ; CHECK-NEXT: [[RET:%.*]] = icmp ne <4 x i32> [[TMP3]], splat (i32 8) ; CHECK-NEXT: ret <4 x i1> [[RET]] ; entry: %and1 = and <4 x i32> %x, %and2 = and <4 x i32> %y, %hadd = tail call <4 x i32> @llvm.x86.ssse3.phadd.d.128(<4 x i32> %and1, <4 x i32> %and2) %shuf = shufflevector <4 x i32> %hadd, <4x i32> zeroinitializer, <4 x i32> %ret = icmp ne <4 x i32> %shuf, ret <4 x i1> %ret } define <4 x i1> @hadd_shuffle_4th_negative_v4i32(<4 x i32> %x, <4 x i32> %y) { ; CHECK-LABEL: define <4 x i1> @hadd_shuffle_4th_negative_v4i32( ; CHECK-SAME: <4 x i32> [[X:%.*]], <4 x i32> [[Y:%.*]]) { ; CHECK-NEXT: entry: ; CHECK-NEXT: [[TMP0:%.*]] = and <4 x i32> [[X]], splat (i32 3) ; CHECK-NEXT: [[TMP1:%.*]] = and <4 x i32> [[Y]], ; CHECK-NEXT: [[TMP2:%.*]] = tail call <4 x i32> @llvm.x86.ssse3.phadd.d.128(<4 x i32> [[TMP0]], <4 x i32> [[TMP1]]) ; CHECK-NEXT: [[TMP3:%.*]] = shufflevector <4 x i32> , <4 x i32> [[TMP2]], <4 x i32> ; CHECK-NEXT: [[RET:%.*]] = icmp ne <4 x i32> [[TMP3]], splat (i32 8) ; CHECK-NEXT: ret <4 x i1> [[RET]] ; entry: %and1 = and <4 x i32> %x, %and2 = and <4 x i32> %y, %hadd = tail call <4 x i32> @llvm.x86.ssse3.phadd.d.128(<4 x i32> %and1, <4 x i32> %and2) %shuf = shufflevector <4 x i32> %hadd, <4x i32> zeroinitializer, <4 x i32> %ret = icmp ne <4 x i32> %shuf, ret <4 x i1> %ret }