llvm.org GIT mirror llvm / dc94462
[InstSimplify] Teach fsub -0.0, (fneg X) ==> X about unary fneg Differential Revision: https://reviews.llvm.org/D62077 git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@361151 91177308-0d34-0410-b5e6-96231b3b80d8 Cameron McInally 3 months ago
2 changed file(s) with 5 addition(s) and 10 deletion(s). Raw diff Collapse all Expand all
44034403 return Op0;
44044404
44054405 // fsub -0.0, (fsub -0.0, X) ==> X
4406 // fsub -0.0, (fneg X) ==> X
44064407 Value *X;
44074408 if (match(Op0, m_NegZeroFP()) &&
4408 match(Op1, m_FSub(m_NegZeroFP(), m_Value(X))))
4409 match(Op1, m_FNeg(m_Value(X))))
44094410 return X;
44104411
44114412 // fsub 0.0, (fsub 0.0, X) ==> X if signed zeros are ignored.
5959 ; fsub -0.0, (fneg X) ==> X
6060 define float @fneg_x(float %a) {
6161 ; CHECK-LABEL: @fneg_x(
62 ; CHECK-NEXT: %t1 = fneg float %a
63 ; CHECK-NEXT: %ret = fsub float -0.000000e+00, %t1
64 ; CHECK-NEXT: ret float %ret
62 ; CHECK-NEXT: ret float [[A:%.*]]
6563 ;
6664 %t1 = fneg float %a
6765 %ret = fsub float -0.0, %t1
7977
8078 define <2 x float> @fneg_x_vec(<2 x float> %a) {
8179 ; CHECK-LABEL: @fneg_x_vec(
82 ; CHECK-NEXT: %t1 = fneg <2 x float> %a
83 ; CHECK-NEXT: %ret = fsub <2 x float> , %t1
84 ; CHECK-NEXT: ret <2 x float> %ret
80 ; CHECK-NEXT: ret <2 x float> [[A:%.*]]
8581 ;
8682 %t1 = fneg <2 x float> %a
8783 %ret = fsub <2 x float> , %t1
9995
10096 define <2 x float> @fneg_x_vec_undef_elts(<2 x float> %a) {
10197 ; CHECK-LABEL: @fneg_x_vec_undef_elts(
102 ; CHECK-NEXT: %t1 = fneg <2 x float> %a
103 ; CHECK-NEXT: %ret = fsub <2 x float> , %t1
104 ; CHECK-NEXT: ret <2 x float> %ret
98 ; CHECK-NEXT: ret <2 x float> [[A:%.*]]
10599 ;
106100 %t1 = fneg <2 x float> %a
107101 %ret = fsub <2 x float> , %t1