mirror of
https://github.com/RPCS3/llvm-mirror.git
synced 2024-11-23 19:23:23 +01:00
[PatternMatch] enhance m_One() to ignore undef elements in vectors
llvm-svn: 325437
This commit is contained in:
parent
6c084ce8ca
commit
c62291f0e6
@ -182,17 +182,6 @@ struct match_nan {
|
||||
/// Match an arbitrary NaN constant. This includes quiet and signalling nans.
|
||||
inline match_nan m_NaN() { return match_nan(); }
|
||||
|
||||
struct match_one {
|
||||
template <typename ITy> bool match(ITy *V) {
|
||||
if (const auto *C = dyn_cast<Constant>(V))
|
||||
return C->isOneValue();
|
||||
return false;
|
||||
}
|
||||
};
|
||||
|
||||
/// \brief Match an integer 1 or a vector with all elements equal to 1.
|
||||
inline match_one m_One() { return match_one(); }
|
||||
|
||||
struct match_all_ones {
|
||||
template <typename ITy> bool match(ITy *V) {
|
||||
if (const auto *C = dyn_cast<Constant>(V))
|
||||
@ -283,8 +272,8 @@ template <int64_t Val> inline constantint_match<Val> m_ConstantInt() {
|
||||
return constantint_match<Val>();
|
||||
}
|
||||
|
||||
/// \brief This helper class is used to match scalar and vector constants that
|
||||
/// satisfy a specified predicate.
|
||||
/// This helper class is used to match scalar and vector constants that satisfy
|
||||
/// a specified predicate. For vector constants, undefined elements are ignored.
|
||||
template <typename Predicate> struct cst_pred_ty : public Predicate {
|
||||
template <typename ITy> bool match(ITy *V) {
|
||||
if (const auto *CI = dyn_cast<ConstantInt>(V))
|
||||
@ -339,6 +328,13 @@ template <typename Predicate> struct api_pred_ty : public Predicate {
|
||||
}
|
||||
};
|
||||
|
||||
struct is_one {
|
||||
bool isValue(const APInt &C) { return C.isOneValue(); }
|
||||
};
|
||||
|
||||
/// Match an integer 1 or a vector with all elements equal to 1.
|
||||
inline cst_pred_ty<is_one> m_One() { return cst_pred_ty<is_one>(); }
|
||||
|
||||
struct is_negative {
|
||||
bool isValue(const APInt &C) { return C.isNegative(); }
|
||||
};
|
||||
|
@ -74,7 +74,7 @@ define <2 x i1> @trueval_is_true_vec(<2 x i1> %C, <2 x i1> %X) {
|
||||
|
||||
define <2 x i1> @trueval_is_true_vec_undef_elt(<2 x i1> %C, <2 x i1> %X) {
|
||||
; CHECK-LABEL: @trueval_is_true_vec_undef_elt(
|
||||
; CHECK-NEXT: [[R:%.*]] = select <2 x i1> [[C:%.*]], <2 x i1> <i1 undef, i1 true>, <2 x i1> [[X:%.*]]
|
||||
; CHECK-NEXT: [[R:%.*]] = or <2 x i1> [[C:%.*]], [[X:%.*]]
|
||||
; CHECK-NEXT: ret <2 x i1> [[R]]
|
||||
;
|
||||
%R = select <2 x i1> %C, <2 x i1> <i1 undef, i1 true>, <2 x i1> %X
|
||||
|
@ -39,8 +39,9 @@ define <4 x i32> @test_v4i32_one(<4 x i32> %a0) {
|
||||
|
||||
define <4 x i32> @test_v4i32_one_undef(<4 x i32> %a0) {
|
||||
; CHECK-LABEL: @test_v4i32_one_undef(
|
||||
; CHECK-NEXT: [[TMP1:%.*]] = urem <4 x i32> <i32 1, i32 1, i32 1, i32 undef>, [[A0:%.*]]
|
||||
; CHECK-NEXT: ret <4 x i32> [[TMP1]]
|
||||
; CHECK-NEXT: [[TMP1:%.*]] = icmp ne <4 x i32> [[A0:%.*]], <i32 1, i32 1, i32 1, i32 undef>
|
||||
; CHECK-NEXT: [[TMP2:%.*]] = zext <4 x i1> [[TMP1]] to <4 x i32>
|
||||
; CHECK-NEXT: ret <4 x i32> [[TMP2]]
|
||||
;
|
||||
%1 = urem <4 x i32> <i32 1, i32 1, i32 1, i32 undef>, %a0
|
||||
ret <4 x i32> %1
|
||||
|
@ -14,8 +14,7 @@ define <2 x i1> @eq_t(<2 x i1> %a) {
|
||||
|
||||
define <2 x i1> @eq_t_undef_elt(<2 x i1> %a) {
|
||||
; CHECK-LABEL: @eq_t_undef_elt(
|
||||
; CHECK-NEXT: [[R:%.*]] = icmp eq <2 x i1> [[A:%.*]], <i1 undef, i1 true>
|
||||
; CHECK-NEXT: ret <2 x i1> [[R]]
|
||||
; CHECK-NEXT: ret <2 x i1> [[A:%.*]]
|
||||
;
|
||||
%r = icmp eq <2 x i1> %a, <i1 undef, i1 true>
|
||||
ret <2 x i1> %r
|
||||
@ -57,8 +56,7 @@ define <2 x i1> @ugt_t(<2 x i1> %a) {
|
||||
|
||||
define <2 x i1> @ugt_t_undef_elt(<2 x i1> %a) {
|
||||
; CHECK-LABEL: @ugt_t_undef_elt(
|
||||
; CHECK-NEXT: [[R:%.*]] = icmp ugt <2 x i1> [[A:%.*]], <i1 true, i1 undef>
|
||||
; CHECK-NEXT: ret <2 x i1> [[R]]
|
||||
; CHECK-NEXT: ret <2 x i1> zeroinitializer
|
||||
;
|
||||
%r = icmp ugt <2 x i1> %a, <i1 true, i1 undef>
|
||||
ret <2 x i1> %r
|
||||
@ -165,8 +163,7 @@ define <2 x i1> @sge_t(<2 x i1> %a) {
|
||||
|
||||
define <2 x i1> @sge_t_undef_elt(<2 x i1> %a) {
|
||||
; CHECK-LABEL: @sge_t_undef_elt(
|
||||
; CHECK-NEXT: [[R:%.*]] = icmp sge <2 x i1> [[A:%.*]], <i1 true, i1 undef>
|
||||
; CHECK-NEXT: ret <2 x i1> [[R]]
|
||||
; CHECK-NEXT: ret <2 x i1> <i1 true, i1 true>
|
||||
;
|
||||
%r = icmp sge <2 x i1> %a, <i1 true, i1 undef>
|
||||
ret <2 x i1> %r
|
||||
|
Loading…
Reference in New Issue
Block a user