[PATCH] D129958: [IndVars] Eliminate redundant type cast with different sizes
Nikita Popov via Phabricator via llvm-commits
llvm-commits at lists.llvm.org
Mon Aug 8 02:30:12 PDT 2022
nikic added inline comments.
================
Comment at: llvm/lib/Transforms/Utils/SimplifyIndVar.cpp:713
+ Conv = Builder.CreateTrunc(IVOperand, CI->getType(), Name + ".trunc");
+ } else if (Opcode == CastInst::FPToSI) {
+ Conv = Builder.CreateSExt(IVOperand, CI->getType(), Name + ".sext");
----------------
I believe we only need sext if both fptosi and sitofp are used. If one of them is unsigned, then we can use zext. This would match InstCombine logic.
In any case, we should have a test for the uitofp+fptosi combination.
================
Comment at: llvm/test/Transforms/IndVarSimplify/floating-point-small-iv.ll:145
+
+define void @sitofp_fptosi_range_zext() {
+;
----------------
Should be fptoui
================
Comment at: llvm/test/Transforms/IndVarSimplify/floating-point-small-iv.ll:180
+
+define void @sitofp_fptosi_range_zext_postinc() {
+;
----------------
Same here
CHANGES SINCE LAST ACTION
https://reviews.llvm.org/D129958/new/
https://reviews.llvm.org/D129958
More information about the llvm-commits
mailing list