When we optimize select basing on fact that div by 0 is undef
we should not traverse the instruction which are not guaranteed to
transfer execution to next instruction. Guard intrinsic is an example.
Details
Diff Detail
Event Timeline
test/Transforms/InstCombine/sdiv-guard.ll | ||
---|---|---|
1 | This test already passes without the patch. Please create a test that shows the diff and use utils/update_test_checks.py to generate checks for it. Also, we shouldn't need -inline to show a failure in instcombine. |
test/Transforms/InstCombine/sdiv-guard.ll | ||
---|---|---|
1 | Test actually shows the diff. Without this patch it will transform guard condition to %X != 0 which is incorrect because if X is not 0 and flag is false gaurd should be triggered. |
LGTM - see inline comments.
lib/Transforms/InstCombine/InstCombineMulDivRem.cpp | ||
---|---|---|
586 | Typo: | |
test/Transforms/InstCombine/sdiv-guard.ll | ||
1 | Ah, the assertions were just not strong enough then. I committed the baseline test here: Please remove the 'FIXME' and update/rebase the patch. |
Typo:
"If we found an instruction that we can't assume will return..."