[PATCH] D144671: [InstCombine] prevent miscompiles from select-of-div/rem transform

Juneyoung Lee via Phabricator via llvm-commits llvm-commits at lists.llvm.org
Sun Feb 26 15:28:09 PST 2023


aqjune added a comment.

> We could carve out some exceptions to this bailout. For example, the transform is actually ok with udiv/urem and a common divisor because poison in the dividend would not cause immediate UB - the divisor has to be zero, and that would be UB in the original code too. That doesn't work with signed div/rem because we can choose the poison dividend to be MinSignedValue, and that overflows when divided by -1 causing UB that doesn't exist in the original code.

This makes a lot of sense to me. Should we make this patch support this case as well?


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

https://reviews.llvm.org/D144671



More information about the llvm-commits mailing list