llvm.org GIT mirror llvm / db8da46
[X86] Enable 8-bit SHL to convert to LEA Differential Revision: https://reviews.llvm.org/D58870 git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@355425 91177308-0d34-0410-b5e6-96231b3b80d8 Craig Topper 7 months ago
4 changed file(s) with 13 addition(s) and 9 deletion(s). Raw diff Collapse all Expand all
754754 BuildMI(*MFI, MBBI, MI.getDebugLoc(), get(Opcode), OutRegLEA);
755755 switch (MIOpc) {
756756 default: llvm_unreachable("Unreachable!");
757 case X86::SHL8ri:
757758 case X86::SHL16ri: {
758759 unsigned ShAmt = MI.getOperand(2).getImm();
759760 MIB.addReg(0).addImm(1ULL << ShAmt)
917918
918919 break;
919920 }
921 case X86::SHL8ri:
922 Is8BitOp = true;
923 LLVM_FALLTHROUGH;
920924 case X86::SHL16ri: {
921925 assert(MI.getNumOperands() >= 3 && "Unknown shift instruction!");
922926 unsigned ShAmt = getTruncatedShiftCount(MI, 2);
2929 [(set GR64:$dst, (shl GR64:$src1, CL))]>;
3030 } // Uses = [CL], SchedRW
3131
32 let isConvertibleToThreeAddress = 1 in { // Can transform into LEA.
3233 def SHL8ri : Ii8<0xC0, MRM4r, (outs GR8 :$dst), (ins GR8 :$src1, u8imm:$src2),
3334 "shl{b}\t{$src2, $dst|$dst, $src2}",
3435 [(set GR8:$dst, (shl GR8:$src1, (i8 imm:$src2)))]>;
3536
36 let isConvertibleToThreeAddress = 1 in { // Can transform into LEA.
3737 def SHL16ri : Ii8<0xC1, MRM4r, (outs GR16:$dst), (ins GR16:$src1, u8imm:$src2),
3838 "shl{w}\t{$src2, $dst|$dst, $src2}",
3939 [(set GR16:$dst, (shl GR16:$src1, (i8 imm:$src2)))]>,
156156 define i8 @shl_imm1_i8(i8 %a) {
157157 ; CHECK-LABEL: shl_imm1_i8:
158158 ; CHECK: ## %bb.0:
159 ; CHECK-NEXT: movl %edi, %eax
160 ; CHECK-NEXT: shlb $1, %al
159 ; CHECK-NEXT: ## kill: def $edi killed $edi def $rdi
160 ; CHECK-NEXT: leal (,%rdi,2), %eax
161161 ; CHECK-NEXT: ## kill: def $al killed $al killed $eax
162162 ; CHECK-NEXT: retq
163163 %c = shl i8 %a, 1
3535 define i8 @test_mul_by_4(i8 %x) {
3636 ; X64-LABEL: test_mul_by_4:
3737 ; X64: # %bb.0:
38 ; X64-NEXT: movl %edi, %eax
39 ; X64-NEXT: shlb $2, %al
38 ; X64-NEXT: # kill: def $edi killed $edi def $rdi
39 ; X64-NEXT: leal (,%rdi,4), %eax
4040 ; X64-NEXT: # kill: def $al killed $al killed $eax
4141 ; X64-NEXT: retq
4242 %m = mul i8 %x, 4
8181 define i8 @test_mul_by_8(i8 %x) {
8282 ; X64-LABEL: test_mul_by_8:
8383 ; X64: # %bb.0:
84 ; X64-NEXT: movl %edi, %eax
85 ; X64-NEXT: shlb $3, %al
84 ; X64-NEXT: # kill: def $edi killed $edi def $rdi
85 ; X64-NEXT: leal (,%rdi,8), %eax
8686 ; X64-NEXT: # kill: def $al killed $al killed $eax
8787 ; X64-NEXT: retq
8888 %m = mul i8 %x, 8
448448 define i8 @test_mul_by_520(i8 %x) {
449449 ; X64-LABEL: test_mul_by_520:
450450 ; X64: # %bb.0:
451 ; X64-NEXT: movl %edi, %eax
452 ; X64-NEXT: shlb $3, %al
451 ; X64-NEXT: # kill: def $edi killed $edi def $rdi
452 ; X64-NEXT: leal (,%rdi,8), %eax
453453 ; X64-NEXT: # kill: def $al killed $al killed $eax
454454 ; X64-NEXT: retq
455455 %m = mul i8 %x, 520