InstCombine: Stop two transforms dueling
authorDavid Majnemer <david.majnemer@gmail.com>
Thu, 19 Jun 2014 07:14:33 +0000 (07:14 +0000)
committerDavid Majnemer <david.majnemer@gmail.com>
Thu, 19 Jun 2014 07:14:33 +0000 (07:14 +0000)
commit6cf6c05322629a17a82aa53e3931086b0c633f87
tree4963ab082543c879a76f5b641944bc1981b917f3
parent4c5bff36ad5574af0df697192003c5ccef4a1297
InstCombine: Stop two transforms dueling

InstCombineMulDivRem has:
// Canonicalize (X+C1)*CI -> X*CI+C1*CI.

InstCombineAddSub has:
// W*X + Y*Z --> W * (X+Z)  iff W == Y

These two transforms could fight with each other if C1*CI would not fold
away to something simpler than a ConstantExpr mul.

The InstCombineMulDivRem transform only acted on ConstantInts until
r199602 when it was changed to operate on all Constants in order to
let it fire on ConstantVectors.

To fix this, make this transform more careful by checking to see if we
actually folded away C1*CI.

This fixes PR20079.

llvm-svn: 211258
llvm/lib/Transforms/InstCombine/InstCombineMulDivRem.cpp
llvm/test/Transforms/InstCombine/pr20079.ll [new file with mode: 0644]