[DAGCombiner] fold sext into decrement
authorSanjay Patel <spatel@rotateright.com>
Fri, 29 Mar 2019 13:49:08 +0000 (13:49 +0000)
committerSanjay Patel <spatel@rotateright.com>
Fri, 29 Mar 2019 13:49:08 +0000 (13:49 +0000)
commit665a3850357c14491b9150c8c3985f29802b3891
treeb871dc1138a5bc95ef2d5d8523559f82360f442b
parent945db0bef814c64f1a8e9b1cc91138033906a0ff
[DAGCombiner] fold sext into decrement

This is a sibling to rL357178 that I noticed we'd hit if we chose
an alternate transform in D59818.

  %z = zext i8 %x to i32
  %dec = add i32 %z, -1
  %r = sext i32 %dec to i64
  =>
  %z2 = zext i8 %x to i64
  %r = add i64 %z2, -1

https://rise4fun.com/Alive/kPP

The x86 vector diffs show a slight regression, so there's a chance
that we should limit this and the previous transform to scalars.

But given that we allowed vectors before, I'm matching that behavior
here. We should change both transforms together if that's the right
thing to do.

llvm-svn: 357254
llvm/lib/CodeGen/SelectionDAG/DAGCombiner.cpp
llvm/test/CodeGen/X86/sext-i1.ll
llvm/test/CodeGen/X86/vector-sext.ll