[PATCH] D39230: [IndVarSimplify] Do not expand unsafe expressions in IndVarSimplify
Sanjoy Das via Phabricator via llvm-commits
llvm-commits at lists.llvm.org
Tue Oct 24 09:38:12 PDT 2017
sanjoy requested changes to this revision.
sanjoy added inline comments.
This revision now requires changes to proceed.
================
Comment at: lib/Transforms/Scalar/IndVarSimplify.cpp:1589
+ // have division by value which is potentially zero.
+ if (!isSafeToExpand(AddRec, *SE))
+ return nullptr;
----------------
Hm, I'm not sold on this. If `AR` is expandable (which we know since we got it from a PHI in the IR, right?) `sext(AR)` and `zext(AR)` should also be expandable.
================
Comment at: test/Transforms/IndVarSimplify/2017-10-24_unsafe_division.ll:39
+ %iv.trunc = trunc i64 %iv to i32
+ %unsafe = udiv i32 224, %iv.trunc
+ br label %inner_loop
----------------
I'm not sure if I understand this test case - if `%iv.trunc` is `0` then doesn't the function already divide by `0` (and thus have UB, making any transformation correct by definition)?
https://reviews.llvm.org/D39230
More information about the llvm-commits
mailing list