Index: lib/Target/X86/X86InstrShiftRotate.td =================================================================== --- lib/Target/X86/X86InstrShiftRotate.td +++ lib/Target/X86/X86InstrShiftRotate.td @@ -609,19 +609,19 @@ // Rotate by 1 def ROR8r1 : I<0xD0, MRM1r, (outs GR8 :$dst), (ins GR8 :$src1), "ror{b}\t$dst", - [(set GR8:$dst, (rotr GR8:$src1, (i8 1)))], + [(set GR8:$dst, (rotl GR8:$src1, (i8 7)))], IIC_SR>; def ROR16r1 : I<0xD1, MRM1r, (outs GR16:$dst), (ins GR16:$src1), "ror{w}\t$dst", - [(set GR16:$dst, (rotr GR16:$src1, (i8 1)))], + [(set GR16:$dst, (rotl GR16:$src1, (i8 15)))], IIC_SR>, OpSize16; def ROR32r1 : I<0xD1, MRM1r, (outs GR32:$dst), (ins GR32:$src1), "ror{l}\t$dst", - [(set GR32:$dst, (rotr GR32:$src1, (i8 1)))], + [(set GR32:$dst, (rotl GR32:$src1, (i8 31)))], IIC_SR>, OpSize32; def ROR64r1 : RI<0xD1, MRM1r, (outs GR64:$dst), (ins GR64:$src1), "ror{q}\t$dst", - [(set GR64:$dst, (rotr GR64:$src1, (i8 1)))], + [(set GR64:$dst, (rotl GR64:$src1, (i8 63)))], IIC_SR>; } // Constraints = "$src = $dst", SchedRW Index: test/CodeGen/X86/rotate.ll =================================================================== --- test/CodeGen/X86/rotate.ll +++ test/CodeGen/X86/rotate.ll @@ -207,7 +207,7 @@ ; ; 64-LABEL: rotr1_64: ; 64: # BB#0: -; 64-NEXT: rolq $63, %rdi +; 64-NEXT: rorq %rdi ; 64-NEXT: movq %rdi, %rax ; 64-NEXT: retq %B = shl i64 %A, 63 @@ -320,12 +320,12 @@ ; 32-LABEL: rotr1_32: ; 32: # BB#0: ; 32-NEXT: movl {{[0-9]+}}(%esp), %eax -; 32-NEXT: roll $31, %eax +; 32-NEXT: rorl %eax ; 32-NEXT: retl ; ; 64-LABEL: rotr1_32: ; 64: # BB#0: -; 64-NEXT: roll $31, %edi +; 64-NEXT: rorl %edi ; 64-NEXT: movl %edi, %eax ; 64-NEXT: retq %B = shl i32 %A, 31 @@ -438,12 +438,12 @@ ; 32-LABEL: rotr1_16: ; 32: # BB#0: ; 32-NEXT: movzwl {{[0-9]+}}(%esp), %eax -; 32-NEXT: rolw $15, %ax +; 32-NEXT: rorw %ax ; 32-NEXT: retl ; ; 64-LABEL: rotr1_16: ; 64: # BB#0: -; 64-NEXT: rolw $15, %di +; 64-NEXT: rorw %di ; 64-NEXT: movl %edi, %eax ; 64-NEXT: retq %B = lshr i16 %A, 1 @@ -552,12 +552,12 @@ ; 32-LABEL: rotr1_8: ; 32: # BB#0: ; 32-NEXT: movb {{[0-9]+}}(%esp), %al -; 32-NEXT: rolb $7, %al +; 32-NEXT: rorb %al ; 32-NEXT: retl ; ; 64-LABEL: rotr1_8: ; 64: # BB#0: -; 64-NEXT: rolb $7, %dil +; 64-NEXT: rorb %dil ; 64-NEXT: movl %edi, %eax ; 64-NEXT: retq %B = lshr i8 %A, 1