[instcombine] Fold overflow check using umulo to comparison
authorPhilip Reames <listmail@philipreames.com>
Fri, 25 Jun 2021 17:24:10 +0000 (10:24 -0700)
committerPhilip Reames <listmail@philipreames.com>
Fri, 25 Jun 2021 17:25:45 +0000 (10:25 -0700)
commit2cd23eb2438238b1297ff7b4368d673c449ff24f
tree244d6705ac75317062c05da5ebb250b95a1afbae
parent9eaf0d120d3255c43789213c499513ba1be9dde7
[instcombine] Fold overflow check using umulo to comparison

If we have a umul.with.overflow where the multiply result is not used and one of the operands is a constant, we can perform the overflow check cheaper with a comparison then by performing the multiply and extracting the overflow flag.

(Noticed when looking at the conditions SCEV emits for overflow checks.)

Differential Revision: https://reviews.llvm.org/D104665
llvm/lib/Transforms/InstCombine/InstructionCombining.cpp
llvm/test/Transforms/InstCombine/umulo.ll