On Feb 3, 2009, at 2:35 PMPST, Mike Stump wrote:> On Feb 3, 2009, at 2:28 PM, Kasra wrote: >> I was looking around the LLVM instruction set and I failed to find >> ROL and ROR instructions. Is there any plans on adding these >> instructions to LLVM? > > Not sure what you mean:He's referring to the LLVM IR, I think, and it's true that doesn't have rotates. The LLVM back ends do know about rotate instructions on targets that have them, though, and the llvm optimizers are pretty smart about recognizing the usual ways to express rotate with shift/ and/or, as below.> $ cat t.c > unsigned int rol(unsigned int i) { > return i << 1 | i >> 31; > } > mrs $ clang -S t.c -O2 > mrs $ cat t.s > > > .text > .align 4,0x90 > .globl _rol > _rol: > movl 4(%esp), %eax > roll %eax > ret > > ? > _______________________________________________ > LLVM Developers mailing list > LLVMdev at cs.uiuc.edu http://llvm.cs.uiuc.edu > http://lists.cs.uiuc.edu/mailman/listinfo/llvmdev
On Tue, Feb 3, 2009 at 2:45 PM, Dale Johannesen <dalej at apple.com> wrote:> > On Feb 3, 2009, at 2:35 PMPST, Mike Stump wrote: > >> On Feb 3, 2009, at 2:28 PM, Kasra wrote: >>> I was looking around the LLVM instruction set and I failed to find >>> ROL and ROR instructions. Is there any plans on adding these >>> instructions to LLVM? >> >> Not sure what you mean: > > He's referring to the LLVM IR, I think, and it's true that doesn't > have rotates. The LLVM back ends do know about rotate instructions on > targets that have them, though, and the llvm optimizers are pretty > smart about recognizing the usual ways to express rotate with shift/ > and/or, as below. >Look in the DAGCombiner.cpp file to see which patterns it translates into ROTL and ROTR instructions. -bw
--- On Tue, 2/3/09, Bill Wendling <isanbard at gmail.com> wrote:> From: Bill Wendling <isanbard at gmail.com> > Subject: Re: [LLVMdev] rol/ror llvm instruction set > To: "LLVM Developers Mailing List" <llvmdev at cs.uiuc.edu> > Cc: kasra_n500 at yahoo.com > Date: Tuesday, February 3, 2009, 2:52 PM > On Tue, Feb 3, 2009 at 2:45 PM, Dale Johannesen > <dalej at apple.com> wrote: > > > > On Feb 3, 2009, at 2:35 PMPST, Mike Stump wrote: > > > >> On Feb 3, 2009, at 2:28 PM, Kasra wrote: > >>> I was looking around the LLVM instruction set > and I failed to find > >>> ROL and ROR instructions. Is there any plans > on adding these > >>> instructions to LLVM? > >> > >> Not sure what you mean: > > > > He's referring to the LLVM IR, I think, and > it's true that doesn't > > have rotates. The LLVM back ends do know about rotate > instructions on > > targets that have them, though, and the llvm > optimizers are pretty > > smart about recognizing the usual ways to express > rotate with shift/ > > and/or, as below. > > > Look in the DAGCombiner.cpp file to see which patterns it > translates > into ROTL and ROTR instructions. > > -bwI guess the backends could know about the instructions. But I am not convinced why it is beneficial not to have ROR and ROL instructions within llvm.> Look in the DAGCombiner.cpp file to see which patterns it > translates > into ROTL and ROTR instructions.Right, I sure will do. -- Kasra