llvm.org GIT mirror llvm / 9b20dc3
[InstSimplify] Add unary fneg to `fsub 0.0, (fneg X) ==> X` transform Differential Revision: https://reviews.llvm.org/D62013 git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@361047 91177308-0d34-0410-b5e6-96231b3b80d8 Cameron McInally 4 months ago
2 changed file(s) with 5 addition(s) and 7 deletion(s). Raw diff Collapse all Expand all
43994399 return X;
44004400
44014401 // fsub 0.0, (fsub 0.0, X) ==> X if signed zeros are ignored.
4402 // fsub 0.0, (fneg X) ==> X if signed zeros are ignored.
44024403 if (FMF.noSignedZeros() && match(Op0, m_AnyZeroFP()) &&
4403 match(Op1, m_FSub(m_AnyZeroFP(), m_Value(X))))
4404 (match(Op1, m_FSub(m_AnyZeroFP(), m_Value(X))) ||
4405 match(Op1, m_FNeg(m_Value(X)))))
44044406 return X;
44054407
44064408 // fsub nnan x, x ==> 0.0
218218 ; fsub nsz 0.0, (fneg X) ==> X
219219 define float @fneg_x(float %a) {
220220 ; CHECK-LABEL: @fneg_x(
221 ; CHECK-NEXT: [[T1:%.*]] = fneg float [[A:%.*]]
222 ; CHECK-NEXT: [[RET:%.*]] = fsub nsz float 0.000000e+00, [[T1]]
223 ; CHECK-NEXT: ret float [[RET]]
221 ; CHECK-NEXT: ret float [[A:%.*]]
224222 ;
225223 %t1 = fneg float %a
226224 %ret = fsub nsz float 0.0, %t1
238236
239237 define <2 x float> @fneg_x_vec_undef1(<2 x float> %a) {
240238 ; CHECK-LABEL: @fneg_x_vec_undef1(
241 ; CHECK-NEXT: [[T1:%.*]] = fneg <2 x float> [[A:%.*]]
242 ; CHECK-NEXT: [[RET:%.*]] = fsub nsz <2 x float> , [[T1]]
243 ; CHECK-NEXT: ret <2 x float> [[RET]]
239 ; CHECK-NEXT: ret <2 x float> [[A:%.*]]
244240 ;
245241 %t1 = fneg <2 x float> %a
246242 %ret = fsub nsz <2 x float> , %t1