[x86] try to widen 'shl' as part of LEA formation
authorSanjay Patel <spatel@rotateright.com>
Wed, 17 Apr 2019 22:38:51 +0000 (22:38 +0000)
committerSanjay Patel <spatel@rotateright.com>
Wed, 17 Apr 2019 22:38:51 +0000 (22:38 +0000)
commitfb363a778fd72e1db89f8b8910582664b2d579fa
treef283e715e617469b2f29d51de21b7a91ce2b3247
parent4c177038e096dad3646fe8fc33682e6ef2f590fa
[x86] try to widen 'shl' as part of LEA formation

The test file has pairs of tests that are logically equivalent:
https://rise4fun.com/Alive/2zQ

%t4 = and i8 %t1, 8
%t5 = zext i8 %t4 to i16
%sh = shl i16 %t5, 2
%t6 = add i16 %sh, %t0
=>
%t4 = and i8 %t1, 8
%sh2 = shl i8 %t4, 2
%z5 = zext i8 %sh2 to i16
%t6 = add i16 %z5, %t0

...so if we can fold the shift op into LEA in the 1st pattern, then we
should be able to do the same in the 2nd pattern (unnecessary 'movzbl'
is a separate bug I think).

We don't want to do this any sooner though because that would conflict
with generic transforms that try to narrow the width of the shift.

Differential Revision: https://reviews.llvm.org/D60789

llvm-svn: 358622
llvm/lib/Target/X86/X86ISelDAGToDAG.cpp
llvm/test/CodeGen/X86/lea-dagdag.ll