-
Notifications
You must be signed in to change notification settings - Fork 14.3k
[flang] Don't blow up when combining mixed COMPLEX operations #66235
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Conversation
@llvm/pr-subscribers-flang-semantics ChangesExpression processing applies some straightforward rewriting of mixed complex/real and complex/integer operations to avoid having to promote the real/integer operand to complex and then perform a complex operation; for example, (a,b)+x becomes (a+x,b) rather than (a,b)+(x,0). But this can blow up the expression representation when the complex operand cannot be duplicated cheaply. So apply this technique only to complex operands that are appropriate to duplicate.Fixes #65142.Patch is 20.59 KiB, truncated to 20.00 KiB below, full version: https://github.com/llvm/llvm-project/pull/66235.diff 3 Files Affected:
<pre> Expr<SomeType> Parenthesize(Expr<SomeType> &&); -Expr<SomeReal> GetComplexPart(
-template <int KIND>
template <typename A> constexpr bool IsNumericCategoryExpr() {
// Mixed REAL+INTEGER operations. REAL**INTEGER is a special case that +template <int KIND>
std::optional<Expr<SomeComplex>> ConstructComplex( -Expr<SomeReal> GetComplexPart(const Expr<SomeComplex> &z, bool isImaginary) {
-}
-Expr<SomeReal> GetComplexPart(Expr<SomeComplex> &&z, bool isImaginary) {
-}
// Convert REAL to COMPLEX of the same kind. Preserving the real operand kind
// Mixed COMPLEX operations with the COMPLEX operand on the right.
+// Promotes REAL(rk) and COMPLEX(zk) operands COMPLEX(max(rk,zk))
} // N.B. When a "typeless" BOZ literal constant appears as one (not both!) of
@@ -433,7 +525,6 @@ std::optional<Expr<SomeType>> NumericOperation(
@@ -481,17 +572,14 @@ std::optional<Expr<SomeType>> Negation(
@@ -643,8 +731,7 @@ std::optional<Expr<SomeType>> ConvertToType(
@@ -1100,7 +1187,7 @@ static std::optional<Expr<SomeType>> DataConstantConversionHelper(
diff --git a/flang/test/Evaluate/bug65142.f90 b/flang/test/Evaluate/bug65142.f90 |
Expression processing applies some straightforward rewriting of mixed complex/real and complex/integer operations to avoid having to promote the real/integer operand to complex and then perform a complex operation; for example, (a,b)+x becomes (a+x,b) rather than (a,b)+(x,0). But this can blow up the expression representation when the complex operand cannot be duplicated cheaply. So apply this technique only to complex operands that are appropriate to duplicate. Fixes llvm#65142. Pull request: llvm#66235
…6235) Expression processing applies some straightforward rewriting of mixed complex/real and complex/integer operations to avoid having to promote the real/integer operand to complex and then perform a complex operation; for example, (a,b)+x becomes (a+x,b) rather than (a,b)+(x,0). But this can blow up the expression representation when the complex operand cannot be duplicated cheaply. So apply this technique only to complex operands that are appropriate to duplicate. Fixes llvm#65142.
Expression processing applies some straightforward rewriting of mixed complex/real and complex/integer operations to avoid having to promote the real/integer operand to complex and then perform a complex operation; for example, (a,b)+x becomes (a+x,b) rather than (a,b)+(x,0). But this can blow up the expression representation when the complex operand cannot be duplicated cheaply. So apply this technique only to complex operands that are appropriate to duplicate.
Fixes #65142.