[flang-commits] [flang] [flang] Fold x + 0, 0 + x and x - 0 for INTEGER and UNSIGNED (PR #192479)

Valentin Clement バレンタイン クレメン via flang-commits flang-commits at lists.llvm.org
Thu Apr 16 14:46:28 PDT 2026


================
@@ -2018,6 +2018,25 @@ Expr<T> FoldOperation(FoldingContext &context, Add<T> &&x) {
       }
       return Expr<T>{Constant<T>{sum.value}};
     }
+  } else if constexpr (T::category == TypeCategory::Integer ||
+      T::category == TypeCategory::Unsigned) {
+    if (auto c{GetScalarConstantValue<T>(x.right())}) {
+      if (c->IsZero() && x.left().Rank() == 0) {
+        if (IsVariable(x.left())) {
+          return FoldOperation(context, Parentheses<T>{std::move(x.left())});
+        } else {
----------------
clementval wrote:

This look like a bot account that comment on many pull request. 


https://github.com/llvm/llvm-project/pull/192479


More information about the flang-commits mailing list