Remove a instcombine transform that (no longer?) makes sense:
authorEvan Cheng <evan.cheng@apple.com>
Tue, 26 Jun 2012 22:03:13 +0000 (22:03 +0000)
committerEvan Cheng <evan.cheng@apple.com>
Tue, 26 Jun 2012 22:03:13 +0000 (22:03 +0000)
commitbbbe41384650142ce57ec469c2342952ed13b69d
treed6ee0b0bd63d293e8a49c9eebc680612196319a0
parent4750c1d804a793edc1f00d4f8b9777352bb0a761
Remove a instcombine transform that (no longer?) makes sense:
    // C - zext(bool) -> bool ? C - 1 : C
    if (ZExtInst *ZI = dyn_cast<ZExtInst>(Op1))
      if (ZI->getSrcTy()->isIntegerTy(1))
        return SelectInst::Create(ZI->getOperand(0), SubOne(C), C);

This ends up forming sext i1 instructions that codegen to terrible code. e.g.
int blah(_Bool x, _Bool y) {
  return (x - y) + 1;
}
=>
        movzbl  %dil, %eax
        movzbl  %sil, %ecx
        shll    $31, %ecx
        sarl    $31, %ecx
        leal    1(%rax,%rcx), %eax
        ret

Without the rule, llvm now generates:
        movzbl  %sil, %ecx
        movzbl  %dil, %eax
        incl    %eax
        subl    %ecx, %eax
        ret

It also helps with ARM (and pretty much any target that doesn't have a sext i1 :-).

The transformation was done as part of Eli's r75531. He has given the ok to
remove it.

rdar://11748024

git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@159230 91177308-0d34-0410-b5e6-96231b3b80d8
lib/Transforms/InstCombine/InstCombineAddSub.cpp
test/Transforms/InstCombine/mul.ll
test/Transforms/InstCombine/zext-bool-add-sub.ll