----- Original Message -----> From: "Tim Northover" <t.p.northover at gmail.com> > To: "Sanjay Patel" <spatel at rotateright.com> > Cc: "LLVM Developers Mailing List" <llvmdev at cs.uiuc.edu> > Sent: Friday, May 23, 2014 2:22:55 PM > Subject: Re: [LLVMdev] clang -O2 versus opt -O2 | llc | clang > > Hi Sanjay, > > > I'm investigating a miscompilation bug ( > > http://llvm.org/bugs/show_bug.cgi?id=19823 ), but I've run into a > > problem: > > the output of the program is different when I compile the IR with > > clang > > compared to opt | llc | clang. Any clues on how to resolve this > > difference? > > From the bug, it looks like there might be a problem with loop > unrolling. Running "opt -loop-unroll -unroll-runtime" on its own > performs the dodgy transformation and changes the output. > > I've not tracked down quite how Clang sets that extra > "-unroll-runtime" option (I'd be interested to know myself, actually, > having failed).It doesn't, but the backend can by overriding TTI::getUnrollingPreferences or setting LoopMicroOpBufferSize in the processor scheduling model. -Hal> > Cheers. > > Tim. > _______________________________________________ > LLVM Developers mailing list > LLVMdev at cs.uiuc.edu http://llvm.cs.uiuc.edu > http://lists.cs.uiuc.edu/mailman/listinfo/llvmdev >-- Hal Finkel Assistant Computational Scientist Leadership Computing Facility Argonne National Laboratory
>> I've not tracked down quite how Clang sets that extra >> "-unroll-runtime" option (I'd be interested to know myself, actually, >> having failed). > > It doesn't, but the backend can by overriding TTI::getUnrollingPreferences > or setting LoopMicroOpBufferSize in the processor scheduling model.I don't think that explains what I'm seeing either: only PPC and R600 seem to mention that function. All code I'm compiling is x86_64. Cheers. Tim. (Incidentally, "opt -loop-unroll -unroll-runtime" may need an already optimised .ll file. I'm attaching my copy here in case it helps anyone). -------------- next part -------------- A non-text attachment was scrubbed... Name: tmp1.ll Type: application/octet-stream Size: 1219 bytes Desc: not available URL: <http://lists.llvm.org/pipermail/llvm-dev/attachments/20140523/e7b7d665/attachment.obj>
----- Original Message -----> From: "Tim Northover" <t.p.northover at gmail.com> > To: "Hal Finkel" <hfinkel at anl.gov> > Cc: "LLVM Developers Mailing List" <llvmdev at cs.uiuc.edu>, "Sanjay Patel" <spatel at rotateright.com> > Sent: Friday, May 23, 2014 2:49:16 PM > Subject: Re: [LLVMdev] clang -O2 versus opt -O2 | llc | clang > > >> I've not tracked down quite how Clang sets that extra > >> "-unroll-runtime" option (I'd be interested to know myself, > >> actually, > >> having failed). > > > > It doesn't, but the backend can by overriding > > TTI::getUnrollingPreferences > > or setting LoopMicroOpBufferSize in the processor scheduling model. > > I don't think that explains what I'm seeing either: only PPC and R600 > seem to mention that function. All code I'm compiling is x86_64.You missed my "or" :-) -- The x86_64 processor models (for Haswell, Sandy Bridge, etc.) do set LoopMicroOpBufferSize and will runtime unroll small loops. -Hal> > Cheers. > > Tim. > > (Incidentally, "opt -loop-unroll -unroll-runtime" may need an already > optimised .ll file. I'm attaching my copy here in case it helps > anyone). >-- Hal Finkel Assistant Computational Scientist Leadership Computing Facility Argonne National Laboratory