[PATCH] D52934: [FPEnv] PatternMatcher support for checking FNEG ignoring signed zeros
Sanjay Patel via Phabricator via llvm-commits
llvm-commits at lists.llvm.org
Sun Oct 7 07:39:03 PDT 2018
spatel added inline comments.
================
Comment at: include/llvm/IR/PatternMatch.h:672
+inline BinaryOp_match<cstfp_pred_ty<is_any_zero_fp>, RHS, Instruction::FSub>
+m_ISZFNeg(const RHS &X) {
+ return m_FSub(m_AnyZeroFP(), X);
----------------
Let's use the existing LLVM vocabulary for "ignore signed zero":
"m_FNegNSZ"
================
Comment at: lib/Analysis/InstructionSimplify.cpp:4510-4512
// We can ignore signed zeros because +-0.0/+-0.0 is NaN and ignored.
- if ((BinaryOperator::isFNeg(Op0, /*IgnoreZeroSign=*/true) &&
- BinaryOperator::getFNegArgument(Op0) == Op1) ||
- (BinaryOperator::isFNeg(Op1, /*IgnoreZeroSign=*/true) &&
- BinaryOperator::getFNegArgument(Op1) == Op0))
+ if ((match(Op0, m_ISZFNeg(m_Value(X))) && X == Op1) ||
+ (match(Op1, m_ISZFNeg(m_Value(X))) && X == Op0))
----------------
Yes, this works like you're hoping. We use this code pattern all over instsimplify/instcombine.
But we have a matcher API that will shorten this:
```
if (match(Op0, m_FNegNSZ(m_Specific(Op1) ||
match(Op1, m_FNegNSZ(m_Specific(Op0))))
```
https://reviews.llvm.org/D52934
More information about the llvm-commits
mailing list