Deal with different sizes between the itofp and fptoi with
trunc or sext/zext, depend on D129756.
Fixes https://github.com/llvm/llvm-project/issues/55505.
Details
Diff Detail
- Repository
- rG LLVM Github Monorepo
Event Timeline
llvm/lib/Transforms/Utils/SimplifyIndVar.cpp | ||
---|---|---|
696 | Why do we need an early inc range now? We're adding a new user of the IVOperand, not the UseInst, right? | |
706–724 | I don't think the IVOperand is necessarily a phi node. Can you add a test where the itofp is on the postinc IV (i.e. the add)? | |
llvm/test/Transforms/IndVarSimplify/floating-point-small-iv.ll | ||
135 | I don't understand these tests. We don't want an existing sext user, but rather a wider type on the fptosi. So sitofp i16 and then fptosi i32. |
Address the comment and add new test sitofp_fptosi_range_zext_postinc with postinc IV
llvm/lib/Transforms/Utils/SimplifyIndVar.cpp | ||
---|---|---|
696 | I thought using make_early_inc_range would increase the robustness of the code referring to 85b4b21c8bb, I'll delete it as it is surely unnecessary. | |
706–724 | I'm kind of curious, besides phi nodes, what other types of inductive variables can be expressed? Sure, IVOperand does not need to be a phi node at this point. PS: the new added case sitofp_fptosi_range_zext_postinc with postinc IV | |
llvm/test/Transforms/IndVarSimplify/floating-point-small-iv.ll | ||
135 | Done, thanks for guiding me on how to build the right test cases. |
llvm/lib/Transforms/Utils/SimplifyIndVar.cpp | ||
---|---|---|
713 | 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. | |
llvm/test/Transforms/IndVarSimplify/floating-point-small-iv.ll | ||
145 | Should be fptoui | |
180 | Same here |
llvm/test/Transforms/IndVarSimplify/floating-point-small-iv.ll | ||
---|---|---|
181 | This isn't quite what I had in mind. By "postinc IV" I mean that %inc.int gets passed to sitofp, rather than %iv.int. I think your current code may result in a wrong insertion point for this case. |
sorry, I upload with an old version, and now it is ok.
llvm/lib/Transforms/Utils/SimplifyIndVar.cpp | ||
---|---|---|
713 | Done, thanks @nikic very much! | |
llvm/test/Transforms/IndVarSimplify/floating-point-small-iv.ll | ||
181 | Now, I just update code to fix the crash for the case with "postinc IV", and I'll try to improve it next patch as I need some time to get the right insertion point. |
llvm/test/Transforms/IndVarSimplify/floating-point-small-iv.ll | ||
---|---|---|
181 | Shouldn't the insertion point simply be CI? |
Why do we need an early inc range now? We're adding a new user of the IVOperand, not the UseInst, right?