llvm is generating invalid instructions (problem with autovectorization?)

I have some code* that is causing llvm to throw a fit. In particular, I get (compiling with GHC 7.8 and llvm 3.4): /tmp/ghc1685_0/ghc1685_5.bc:150324:0: Error: no such instruction: `sarxq %rax,%rbx,%r14' Similar errors get repeated several thousand times, and it's always a sarxq instruction. Now, my code doesn't use any of the simd primops, so the sarxq must be coming from llvm's autovectorization. Is it possible that somehow GHC's output bytecode could be responsible, or is the problem more likely with llvm proper? Is there any way I can force GHC to pass flags to llvm so I can experiment with different settings? Another clue that the cause might be in llvm's autovectorization is that when I compile with llvm 3.0 (which does not support autovectorization), there are no error messages. * I suspect my code is far too complicated for it to shed any light on this question, but it's available at: https://github.com/mikeizbicki/HLearn/tree/dev-7.8/src/examples/hlearn-allkn... If need be, I can create a minimal sample of code that causes the error, but I don't want to go through the trouble if it's not needed.

Perhaps your installed version of binutils does not support the sarxq instruction? You can ask GHC to pass flags to llc and friends: http://www.haskell.org/ghc/docs/7.8.2/html/users_guide/options-phases.html#f... Best, Geoff On 05/21/2014 06:50 PM, Mike Izbicki wrote:
I have some code* that is causing llvm to throw a fit. In particular, I get (compiling with GHC 7.8 and llvm 3.4):
/tmp/ghc1685_0/ghc1685_5.bc:150324:0: Error: no such instruction: `sarxq %rax,%rbx,%r14'
Similar errors get repeated several thousand times, and it's always a sarxq instruction. Now, my code doesn't use any of the simd primops, so the sarxq must be coming from llvm's autovectorization. Is it possible that somehow GHC's output bytecode could be responsible, or is the problem more likely with llvm proper? Is there any way I can force GHC to pass flags to llvm so I can experiment with different settings?
Another clue that the cause might be in llvm's autovectorization is that when I compile with llvm 3.0 (which does not support autovectorization), there are no error messages.
* I suspect my code is far too complicated for it to shed any light on this question, but it's available at: https://github.com/mikeizbicki/HLearn/tree/dev-7.8/src/examples/hlearn-allkn... If need be, I can create a minimal sample of code that causes the error, but I don't want to go through the trouble if it's not needed.

Is this on a Mac that is using gcc4.2? The older GCC assembler stuff
doesn't understand simd.
On Wednesday, May 21, 2014, Geoffrey Mainland
Perhaps your installed version of binutils does not support the sarxq instruction?
You can ask GHC to pass flags to llc and friends:
http://www.haskell.org/ghc/docs/7.8.2/html/users_guide/options-phases.html#f...
Best, Geoff
On 05/21/2014 06:50 PM, Mike Izbicki wrote:
I have some code* that is causing llvm to throw a fit. In particular, I get (compiling with GHC 7.8 and llvm 3.4):
/tmp/ghc1685_0/ghc1685_5.bc:150324:0: Error: no such instruction: `sarxq %rax,%rbx,%r14'
Similar errors get repeated several thousand times, and it's always a sarxq instruction. Now, my code doesn't use any of the simd primops, so the sarxq must be coming from llvm's autovectorization. Is it possible that somehow GHC's output bytecode could be responsible, or is the problem more likely with llvm proper? Is there any way I can force GHC to pass flags to llvm so I can experiment with different settings?
Another clue that the cause might be in llvm's autovectorization is that when I compile with llvm 3.0 (which does not support autovectorization), there are no error messages.
* I suspect my code is far too complicated for it to shed any light on this question, but it's available at:
https://github.com/mikeizbicki/HLearn/tree/dev-7.8/src/examples/hlearn-allkn...
If need be, I can create a minimal sample of code that causes the error, but I don't want to go through the trouble if it's not needed.
_______________________________________________ Haskell-Cafe mailing list Haskell-Cafe@haskell.org javascript:; http://www.haskell.org/mailman/listinfo/haskell-cafe

Geoffrey: After a quick google of binutils, it's not obvious to me what role it plays in the compilation process or how I would find out if it supports sarxq? Carter: It's on linux (centos); gcc version is 4.4.7. Why is gcc even getting involved in this process? I didn't think ghc used it at all anymore. On Wed, May 21, 2014 at 6:57 PM, Carter Schonwald < carter.schonwald@gmail.com> wrote:
Is this on a Mac that is using gcc4.2? The older GCC assembler stuff doesn't understand simd.
On Wednesday, May 21, 2014, Geoffrey Mainland
wrote: Perhaps your installed version of binutils does not support the sarxq instruction?
You can ask GHC to pass flags to llc and friends:
http://www.haskell.org/ghc/docs/7.8.2/html/users_guide/options-phases.html#f...
Best, Geoff
On 05/21/2014 06:50 PM, Mike Izbicki wrote:
I have some code* that is causing llvm to throw a fit. In particular, I get (compiling with GHC 7.8 and llvm 3.4):
/tmp/ghc1685_0/ghc1685_5.bc:150324:0: Error: no such instruction: `sarxq %rax,%rbx,%r14'
Similar errors get repeated several thousand times, and it's always a sarxq instruction. Now, my code doesn't use any of the simd primops, so the sarxq must be coming from llvm's autovectorization. Is it possible that somehow GHC's output bytecode could be responsible, or is the problem more likely with llvm proper? Is there any way I can force GHC to pass flags to llvm so I can experiment with different settings?
Another clue that the cause might be in llvm's autovectorization is that when I compile with llvm 3.0 (which does not support autovectorization), there are no error messages.
* I suspect my code is far too complicated for it to shed any light on this question, but it's available at:
https://github.com/mikeizbicki/HLearn/tree/dev-7.8/src/examples/hlearn-allkn...
If need be, I can create a minimal sample of code that causes the error, but I don't want to go through the trouble if it's not needed.
_______________________________________________ Haskell-Cafe mailing list Haskell-Cafe@haskell.org http://www.haskell.org/mailman/listinfo/haskell-cafe

On Wed, May 21, 2014 at 10:06 PM, Mike Izbicki
Geoffrey: After a quick google of binutils, it's not obvious to me what role it plays in the compilation process or how I would find out if it supports sarxq?
The assembler comes from binutils on Linux. Carter: It's on linux (centos); gcc version is 4.4.7. Why is gcc even
getting involved in this process? I didn't think ghc used it at all anymore.
I think that was slightly confused; on OS X, the assembler is provided by Apple in the same package (Xcode command line tools) as gcc, although it's not part of gcc as such. (Apple doesn't use binutils, as its Mach-O object support tends to be out of date or broken.) I don't *think* gcc is involved with building stuff with -llvm. -- brandon s allbery kf8nh sine nomine associates allbery.b@gmail.com ballbery@sinenomine.net unix, openafs, kerberos, infrastructure, xmonad http://sinenomine.net

Thanks everyone. Installing the latest version of binutils fixed the
problem.
On Wed, May 21, 2014 at 7:30 PM, Brandon Allbery
On Wed, May 21, 2014 at 10:06 PM, Mike Izbicki
wrote: Geoffrey: After a quick google of binutils, it's not obvious to me what role it plays in the compilation process or how I would find out if it supports sarxq?
The assembler comes from binutils on Linux.
Carter: It's on linux (centos); gcc version is 4.4.7. Why is gcc even
getting involved in this process? I didn't think ghc used it at all anymore.
I think that was slightly confused; on OS X, the assembler is provided by Apple in the same package (Xcode command line tools) as gcc, although it's not part of gcc as such. (Apple doesn't use binutils, as its Mach-O object support tends to be out of date or broken.) I don't *think* gcc is involved with building stuff with -llvm.
-- brandon s allbery kf8nh sine nomine associates allbery.b@gmail.com ballbery@sinenomine.net unix, openafs, kerberos, infrastructure, xmonad http://sinenomine.net

On Wed, May 21, 2014 at 10:06 PM, Mike Izbicki
Geoffrey: After a quick google of binutils, it's not obvious to me what role it plays in the compilation process or how I would find out if it supports sarxq?
The assembler comes from binutils on Linux. Carter: It's on linux (centos); gcc version is 4.4.7. Why is gcc even
getting involved in this process? I didn't think ghc used it at all anymore.
I think that was slightly confused; on OS X, the assembler is provided by Apple in the same package (Xcode command line tools) as gcc, although it's not part of gcc as such. (Apple doesn't use binutils, as its Mach-O object support tends to be out of date or broken.) I don't *think* gcc is involved with building stuff with -llvm. -- brandon s allbery kf8nh sine nomine associates allbery.b@gmail.com ballbery@sinenomine.net unix, openafs, kerberos, infrastructure, xmonad http://sinenomine.net
participants (4)
-
Brandon Allbery
-
Carter Schonwald
-
Geoffrey Mainland
-
Mike Izbicki