From 47579b21e2043a69832a1378e85f1e545abfef08 Mon Sep 17 00:00:00 2001 From: Sanjay Patel Date: Sat, 13 Oct 2018 16:15:37 +0000 Subject: [PATCH] [InstCombine] fix complexity canonicalization with fake unary vector ops This is a preliminary step to avoid regressions when we add an actual 'fneg' instruction to IR. See D52934 and D53205. llvm-svn: 344458 --- llvm/lib/Transforms/InstCombine/InstCombineInternal.h | 4 ++-- llvm/test/Transforms/InstCombine/operand-complexity.ll | 6 +++--- 2 files changed, 5 insertions(+), 5 deletions(-) diff --git a/llvm/lib/Transforms/InstCombine/InstCombineInternal.h b/llvm/lib/Transforms/InstCombine/InstCombineInternal.h index 46c598d..3a18744 100644 --- a/llvm/lib/Transforms/InstCombine/InstCombineInternal.h +++ b/llvm/lib/Transforms/InstCombine/InstCombineInternal.h @@ -82,8 +82,8 @@ class User; /// 5 -> Other instructions static inline unsigned getComplexity(Value *V) { if (isa(V)) { - if (isa(V) || BinaryOperator::isNeg(V) || - BinaryOperator::isFNeg(V) || BinaryOperator::isNot(V)) + if (isa(V) || match(V, m_Neg(m_Value())) || + match(V, m_Not(m_Value())) || match(V, m_FNeg(m_Value()))) return 4; return 5; } diff --git a/llvm/test/Transforms/InstCombine/operand-complexity.ll b/llvm/test/Transforms/InstCombine/operand-complexity.ll index 747b0c8..20abe7b 100644 --- a/llvm/test/Transforms/InstCombine/operand-complexity.ll +++ b/llvm/test/Transforms/InstCombine/operand-complexity.ll @@ -33,7 +33,7 @@ define <2 x i8> @neg_vec_undef(<2 x i8> %x) { ; CHECK-LABEL: @neg_vec_undef( ; CHECK-NEXT: [[BO:%.*]] = udiv <2 x i8> [[X:%.*]], ; CHECK-NEXT: [[NEGX:%.*]] = sub <2 x i8> , [[X]] -; CHECK-NEXT: [[R:%.*]] = mul <2 x i8> [[NEGX]], [[BO]] +; CHECK-NEXT: [[R:%.*]] = mul <2 x i8> [[BO]], [[NEGX]] ; CHECK-NEXT: ret <2 x i8> [[R]] ; %bo = udiv <2 x i8> %x, @@ -74,7 +74,7 @@ define <2 x i8> @not_vec_undef(<2 x i8> %x) { ; CHECK-LABEL: @not_vec_undef( ; CHECK-NEXT: [[BO:%.*]] = udiv <2 x i8> [[X:%.*]], ; CHECK-NEXT: [[NOTX:%.*]] = xor <2 x i8> [[X]], -; CHECK-NEXT: [[R:%.*]] = mul <2 x i8> [[NOTX]], [[BO]] +; CHECK-NEXT: [[R:%.*]] = mul <2 x i8> [[BO]], [[NOTX]] ; CHECK-NEXT: ret <2 x i8> [[R]] ; %bo = udiv <2 x i8> %x, @@ -123,7 +123,7 @@ define <2 x float> @fneg_vec_undef(<2 x float> %x) { ; CHECK-LABEL: @fneg_vec_undef( ; CHECK-NEXT: [[BO:%.*]] = fdiv <2 x float> [[X:%.*]], ; CHECK-NEXT: [[FNEGX:%.*]] = fsub <2 x float> , [[X]] -; CHECK-NEXT: [[R:%.*]] = fmul <2 x float> [[FNEGX]], [[BO]] +; CHECK-NEXT: [[R:%.*]] = fmul <2 x float> [[BO]], [[FNEGX]] ; CHECK-NEXT: call void @use_vec(<2 x float> [[FNEGX]]) ; CHECK-NEXT: ret <2 x float> [[R]] ; -- 2.7.4