From: Craig Topper Date: Thu, 14 Mar 2019 16:53:24 +0000 (+0000) Subject: [X86] Fix the pattern changes from r356121 so that the ROR*r1/ROR*m1 pattern use... X-Git-Tag: llvmorg-9.0.0-rc1~10013 X-Git-Url: http://review.tizen.org/git/?a=commitdiff_plain;h=c747ac3f936adbccdcb7ee64a64961b33344b5ec;p=platform%2Fupstream%2Fllvm.git [X86] Fix the pattern changes from r356121 so that the ROR*r1/ROR*m1 pattern use the rotr opcode. These instructions used to use rotl with a bitwidth-1 immediate. I changed the immediate to 1, but failed to change the opcode. Thankfully this seems to have not caused a functional issue because we now had two rotl by 1 patterns, but the correct ones were earlier and took priority. So we just missed some optimization. llvm-svn: 356164 --- diff --git a/llvm/lib/Target/X86/X86InstrShiftRotate.td b/llvm/lib/Target/X86/X86InstrShiftRotate.td index c80880397444..5c4507440eda 100644 --- a/llvm/lib/Target/X86/X86InstrShiftRotate.td +++ b/llvm/lib/Target/X86/X86InstrShiftRotate.td @@ -585,16 +585,16 @@ def ROR64ri : RIi8<0xC1, MRM1r, (outs GR64:$dst), // Rotate by 1 def ROR8r1 : I<0xD0, MRM1r, (outs GR8 :$dst), (ins GR8 :$src1), "ror{b}\t$dst", - [(set GR8:$dst, (rotl GR8:$src1, (i8 1)))]>; + [(set GR8:$dst, (rotr GR8:$src1, (i8 1)))]>; def ROR16r1 : I<0xD1, MRM1r, (outs GR16:$dst), (ins GR16:$src1), "ror{w}\t$dst", - [(set GR16:$dst, (rotl GR16:$src1, (i8 1)))]>, OpSize16; + [(set GR16:$dst, (rotr GR16:$src1, (i8 1)))]>, OpSize16; def ROR32r1 : I<0xD1, MRM1r, (outs GR32:$dst), (ins GR32:$src1), "ror{l}\t$dst", - [(set GR32:$dst, (rotl GR32:$src1, (i8 1)))]>, OpSize32; + [(set GR32:$dst, (rotr GR32:$src1, (i8 1)))]>, OpSize32; def ROR64r1 : RI<0xD1, MRM1r, (outs GR64:$dst), (ins GR64:$src1), "ror{q}\t$dst", - [(set GR64:$dst, (rotl GR64:$src1, (i8 1)))]>; + [(set GR64:$dst, (rotr GR64:$src1, (i8 1)))]>; } // Constraints = "$src = $dst", SchedRW let Uses = [CL], SchedRW = [WriteRotateCLLd, WriteRMW] in { @@ -633,18 +633,18 @@ def ROR64mi : RIi8<0xC1, MRM1m, (outs), (ins i64mem:$dst, u8imm:$src), // Rotate by 1 def ROR8m1 : I<0xD0, MRM1m, (outs), (ins i8mem :$dst), "ror{b}\t$dst", - [(store (rotl (loadi8 addr:$dst), (i8 1)), addr:$dst)]>; + [(store (rotr (loadi8 addr:$dst), (i8 1)), addr:$dst)]>; def ROR16m1 : I<0xD1, MRM1m, (outs), (ins i16mem:$dst), "ror{w}\t$dst", - [(store (rotl (loadi16 addr:$dst), (i8 1)), addr:$dst)]>, + [(store (rotr (loadi16 addr:$dst), (i8 1)), addr:$dst)]>, OpSize16; def ROR32m1 : I<0xD1, MRM1m, (outs), (ins i32mem:$dst), "ror{l}\t$dst", - [(store (rotl (loadi32 addr:$dst), (i8 1)), addr:$dst)]>, + [(store (rotr (loadi32 addr:$dst), (i8 1)), addr:$dst)]>, OpSize32; def ROR64m1 : RI<0xD1, MRM1m, (outs), (ins i64mem:$dst), "ror{q}\t$dst", - [(store (rotl (loadi64 addr:$dst), (i8 1)), addr:$dst)]>, + [(store (rotr (loadi64 addr:$dst), (i8 1)), addr:$dst)]>, Requires<[In64BitMode]>; } // SchedRW diff --git a/llvm/test/CodeGen/X86/funnel-shift-rot.ll b/llvm/test/CodeGen/X86/funnel-shift-rot.ll index 29e1b3e065bb..b5e17ab80208 100644 --- a/llvm/test/CodeGen/X86/funnel-shift-rot.ll +++ b/llvm/test/CodeGen/X86/funnel-shift-rot.ll @@ -205,13 +205,13 @@ define i8 @rotr_i8_const_shift1(i8 %x) nounwind { ; X32-SSE2-LABEL: rotr_i8_const_shift1: ; X32-SSE2: # %bb.0: ; X32-SSE2-NEXT: movb {{[0-9]+}}(%esp), %al -; X32-SSE2-NEXT: rorb $1, %al +; X32-SSE2-NEXT: rorb %al ; X32-SSE2-NEXT: retl ; ; X64-AVX2-LABEL: rotr_i8_const_shift1: ; X64-AVX2: # %bb.0: ; X64-AVX2-NEXT: movl %edi, %eax -; X64-AVX2-NEXT: rorb $1, %al +; X64-AVX2-NEXT: rorb %al ; X64-AVX2-NEXT: # kill: def $al killed $al killed $eax ; X64-AVX2-NEXT: retq %f = call i8 @llvm.fshr.i8(i8 %x, i8 %x, i8 1) diff --git a/llvm/test/CodeGen/X86/rot32.ll b/llvm/test/CodeGen/X86/rot32.ll index d6c5ae221396..29dd679ae9df 100644 --- a/llvm/test/CodeGen/X86/rot32.ll +++ b/llvm/test/CodeGen/X86/rot32.ll @@ -514,7 +514,7 @@ define i32 @fshr1(i32 %x) nounwind { ; X86-LABEL: fshr1: ; X86: # %bb.0: ; X86-NEXT: movl {{[0-9]+}}(%esp), %eax -; X86-NEXT: rorl $1, %eax +; X86-NEXT: rorl %eax ; X86-NEXT: retl ; ; SHLD-LABEL: fshr1: @@ -531,7 +531,7 @@ define i32 @fshr1(i32 %x) nounwind { ; X64-LABEL: fshr1: ; X64: # %bb.0: ; X64-NEXT: movl %edi, %eax -; X64-NEXT: rorl $1, %eax +; X64-NEXT: rorl %eax ; X64-NEXT: retq ; ; SHLD64-LABEL: fshr1: diff --git a/llvm/test/CodeGen/X86/rot64.ll b/llvm/test/CodeGen/X86/rot64.ll index 43ece70ad369..fdc7e9ab21af 100644 --- a/llvm/test/CodeGen/X86/rot64.ll +++ b/llvm/test/CodeGen/X86/rot64.ll @@ -303,7 +303,7 @@ define i64 @fshr1(i64 %x) nounwind { ; X64-LABEL: fshr1: ; X64: # %bb.0: ; X64-NEXT: movq %rdi, %rax -; X64-NEXT: rorq $1, %rax +; X64-NEXT: rorq %rax ; X64-NEXT: retq ; ; SHLD-LABEL: fshr1: