[llvm] r295626 - [X86] Use memory form of shift right by 1 when the rotl immediate is one less than the operation size.
Craig Topper via llvm-commits
llvm-commits at lists.llvm.org
Sun Feb 19 16:37:24 PST 2017
Author: ctopper
Date: Sun Feb 19 18:37:23 2017
New Revision: 295626
URL: http://llvm.org/viewvc/llvm-project?rev=295626&view=rev
Log:
[X86] Use memory form of shift right by 1 when the rotl immediate is one less than the operation size.
An earlier commit already did this for the register form.
Modified:
llvm/trunk/lib/Target/X86/X86InstrShiftRotate.td
llvm/trunk/test/CodeGen/X86/rotate.ll
Modified: llvm/trunk/lib/Target/X86/X86InstrShiftRotate.td
URL: http://llvm.org/viewvc/llvm-project/llvm/trunk/lib/Target/X86/X86InstrShiftRotate.td?rev=295626&r1=295625&r2=295626&view=diff
==============================================================================
--- llvm/trunk/lib/Target/X86/X86InstrShiftRotate.td (original)
+++ llvm/trunk/lib/Target/X86/X86InstrShiftRotate.td Sun Feb 19 18:37:23 2017
@@ -662,19 +662,19 @@ def ROR64mi : RIi8<0xC1, MRM1m, (outs),
// Rotate by 1
def ROR8m1 : I<0xD0, MRM1m, (outs), (ins i8mem :$dst),
"ror{b}\t$dst",
- [(store (rotr (loadi8 addr:$dst), (i8 1)), addr:$dst)],
+ [(store (rotl (loadi8 addr:$dst), (i8 7)), addr:$dst)],
IIC_SR>;
def ROR16m1 : I<0xD1, MRM1m, (outs), (ins i16mem:$dst),
"ror{w}\t$dst",
- [(store (rotr (loadi16 addr:$dst), (i8 1)), addr:$dst)],
+ [(store (rotl (loadi16 addr:$dst), (i8 15)), addr:$dst)],
IIC_SR>, OpSize16;
def ROR32m1 : I<0xD1, MRM1m, (outs), (ins i32mem:$dst),
"ror{l}\t$dst",
- [(store (rotr (loadi32 addr:$dst), (i8 1)), addr:$dst)],
+ [(store (rotl (loadi32 addr:$dst), (i8 31)), addr:$dst)],
IIC_SR>, OpSize32;
def ROR64m1 : RI<0xD1, MRM1m, (outs), (ins i64mem:$dst),
"ror{q}\t$dst",
- [(store (rotr (loadi64 addr:$dst), (i8 1)), addr:$dst)],
+ [(store (rotl (loadi64 addr:$dst), (i8 63)), addr:$dst)],
IIC_SR>;
} // SchedRW
Modified: llvm/trunk/test/CodeGen/X86/rotate.ll
URL: http://llvm.org/viewvc/llvm-project/llvm/trunk/test/CodeGen/X86/rotate.ll?rev=295626&r1=295625&r2=295626&view=diff
==============================================================================
--- llvm/trunk/test/CodeGen/X86/rotate.ll (original)
+++ llvm/trunk/test/CodeGen/X86/rotate.ll Sun Feb 19 18:37:23 2017
@@ -558,7 +558,7 @@ define void @rotr1_64_mem(i64* %Aptr) no
; 64-LABEL: rotr1_64_mem:
; 64: # BB#0:
-; 64-NEXT: rolq $63, (%rdi)
+; 64-NEXT: rorq (%rdi)
; 64-NEXT: retq
%A = load i64, i64 *%Aptr
%B = shl i64 %A, 63
@@ -572,12 +572,12 @@ define void @rotr1_32_mem(i32* %Aptr) no
; 32-LABEL: rotr1_32_mem:
; 32: # BB#0:
; 32-NEXT: movl 4(%esp), %eax
-; 32-NEXT: roll $31, (%eax)
+; 32-NEXT: rorl (%eax)
; 32-NEXT: retl
;
; 64-LABEL: rotr1_32_mem:
; 64: # BB#0:
-; 64-NEXT: roll $31, (%rdi)
+; 64-NEXT: rorl (%rdi)
; 64-NEXT: retq
%A = load i32, i32 *%Aptr
%B = shl i32 %A, 31
@@ -591,12 +591,12 @@ define void @rotr1_16_mem(i16* %Aptr) no
; 32-LABEL: rotr1_16_mem:
; 32: # BB#0:
; 32-NEXT: movl 4(%esp), %eax
-; 32-NEXT: rolw $15, (%eax)
+; 32-NEXT: rorw (%eax)
; 32-NEXT: retl
;
; 64-LABEL: rotr1_16_mem:
; 64: # BB#0:
-; 64-NEXT: rolw $15, (%rdi)
+; 64-NEXT: rorw (%rdi)
; 64-NEXT: retq
%A = load i16, i16 *%Aptr
%B = shl i16 %A, 15
@@ -610,12 +610,12 @@ define void @rotr1_8_mem(i8* %Aptr) noun
; 32-LABEL: rotr1_8_mem:
; 32: # BB#0:
; 32-NEXT: movl 4(%esp), %eax
-; 32-NEXT: rolb $7, (%eax)
+; 32-NEXT: rorb (%eax)
; 32-NEXT: retl
;
; 64-LABEL: rotr1_8_mem:
; 64: # BB#0:
-; 64-NEXT: rolb $7, (%rdi)
+; 64-NEXT: rorb (%rdi)
; 64-NEXT: retq
%A = load i8, i8 *%Aptr
%B = shl i8 %A, 7
More information about the llvm-commits
mailing list