[flang-commits] [PATCH] D136901: [flang] Speed up folding of LEN_TRIM()

Peter Klausler via Phabricator via flang-commits flang-commits at lists.llvm.org
Sat Oct 29 14:08:14 PDT 2022


This revision was automatically updated to reflect the committed changes.
Closed by commit rG39f6d8334522: [flang] Speed up folding of LEN_TRIM() (authored by klausler).

Repository:
  rG LLVM Github Monorepo

CHANGES SINCE LAST ACTION
  https://reviews.llvm.org/D136901/new/

https://reviews.llvm.org/D136901

Files:
  flang/lib/Evaluate/character.h


Index: flang/lib/Evaluate/character.h
===================================================================
--- flang/lib/Evaluate/character.h
+++ flang/lib/Evaluate/character.h
@@ -94,7 +94,13 @@
   }
 
   static ConstantSubscript LEN_TRIM(const Character &str) {
-    return VERIFY(str, Character{' '}, true);
+    auto j{str.length()};
+    for (; j >= 1; --j) {
+      if (str[j - 1] != ' ') {
+        break;
+      }
+    }
+    return static_cast<ConstantSubscript>(j);
   }
 
   static Character REPEAT(const Character &str, ConstantSubscript ncopies) {


-------------- next part --------------
A non-text attachment was scrubbed...
Name: D136901.471784.patch
Type: text/x-patch
Size: 560 bytes
Desc: not available
URL: <http://lists.llvm.org/pipermail/flang-commits/attachments/20221029/9d61a60a/attachment.bin>


More information about the flang-commits mailing list