[PATCH] D127766: [InstCombine] Fold memcmp of constant arrays and variable size

Nikita Popov via Phabricator via llvm-commits llvm-commits at lists.llvm.org
Wed Jun 15 00:35:30 PDT 2022


nikic added inline comments.


================
Comment at: llvm/lib/Transforms/Utils/SimplifyLibCalls.cpp:1276
   ConstantInt *LenC = dyn_cast<ConstantInt>(Size);
   if (!LenC)
+    // Hande variable Size.
----------------
courbet wrote:
> [nit] It feels weird to have `if(!constant) { /*handle general case*/ } /*handle constant case*/ `. Can you rewrite it as  `if(constant) { /*handle constant case*/ } /*handle general case*/ ` ?
We can probably also always check the variable case first (because it also works fine for the all-constant case, right? The extra condition will fold afterwards) and drop the       getConstantStringInfo() handling from optimizeMemCmpConstantSize().


Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D127766



More information about the llvm-commits mailing list