[PATCH] D129358: [IndVars] Eliminate redundant type cast between unsigned integer and float

Allen zhong via Phabricator via llvm-commits llvm-commits at lists.llvm.org
Tue Jul 12 08:05:42 PDT 2022


Allen added inline comments.


================
Comment at: llvm/lib/Transforms/Utils/SimplifyIndVar.cpp:694
+      CastInst::CastOps Opcode = CI->getOpcode();
+      if (Opcode != CastInst::FPToSI && Opcode != CastInst::FPToUI)
+        continue;
----------------
nikic wrote:
> For fptoui, shouldn't we also check that it's non-negative? Wouldn't your current code optimize an IV that does `-100` to `100` for example?
thanks @nikic very much, and I verified that the gcc also transform with negative value, see detail in https://godbolt.org/z/1hxebdYfr


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

https://reviews.llvm.org/D129358



More information about the llvm-commits mailing list