[PATCH] D125774: [InstCombine] fold float trunc into exact itofp for small constants

Eli Friedman via Phabricator via llvm-commits llvm-commits at lists.llvm.org
Fri Jun 10 12:12:40 PDT 2022


efriedma added inline comments.


================
Comment at: llvm/lib/Analysis/ValueTracking.cpp:1532
+            // Try to evaluate the value range of the integer.
+            ICmpInst *CmpInst = dyn_cast<ICmpInst>(BO->use_begin()->getUser());
+            if (CmpInst && dyn_cast<ConstantInt>(CmpInst->getOperand(1)) &&
----------------
I'm very confused by this code.

You're taking the binary operator, checking if the first use in the use list is an icmp, then... assuming the result of the icmp somehow constraints the result of the add?

If you need some sort of reasoning about control flow, maybe look at LazyValueInfo?


================
Comment at: llvm/test/Transforms/InstCombine/sitofp.ll:228
 ;
   %m = and i25 %A, 65535
   %B = uitofp i25 %m to float
----------------
We probably want a few more testcases like this to verify the exact boundary conditions.


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

https://reviews.llvm.org/D125774



More information about the llvm-commits mailing list