]> granicus.if.org Git - llvm/commit
[DAGCombiner] fold select-of-constants to shift
authorSanjay Patel <spatel@rotateright.com>
Thu, 10 Oct 2019 17:52:02 +0000 (17:52 +0000)
committerSanjay Patel <spatel@rotateright.com>
Thu, 10 Oct 2019 17:52:02 +0000 (17:52 +0000)
commit885227718e1f65b4cfa464365b45fb1dbe71776e
tree7dddcbe84fecf649a557268b499fbeb7f9bee6a9
parent83c1b78b175b0fb13c0d2eaaad5dd9244534b672
[DAGCombiner] fold select-of-constants to shift

This reverses the scalar canonicalization proposed in D63382.

Pre: isPowerOf2(C1)
%r = select i1 %cond, i32 C1, i32 0
=>
%z = zext i1 %cond to i32
%r = shl i32 %z, log2(C1)

https://rise4fun.com/Alive/Z50

x86 already tries to fold this pattern, but it isn't done
uniformly, so we still see a diff. AArch64 probably should
enable the TLI hook to benefit too, but that's a follow-on.

git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@374397 91177308-0d34-0410-b5e6-96231b3b80d8
lib/CodeGen/SelectionDAG/DAGCombiner.cpp
test/CodeGen/X86/selectcc-to-shiftand.ll