Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Native code generation error for simplified, possibly frem related composite creation #8932

Closed
waTeim opened this issue Nov 7, 2014 · 4 comments
Labels
kind:bug Indicates an unexpected problem or unintended behavior kind:upstream The issue is with an upstream dependency, e.g. LLVM

Comments

@waTeim
Copy link
Contributor

waTeim commented Nov 7, 2014

This is a followup from the question Odd type construction behavior on Stack Overflow; although that particular problem doesn't appear to exist in 0.4, I think this is because in 0.4, mod is a function call rather than inlined.

However, the following related problem still persists in 0.4

Decl

immutable Vec3
   x::Float32
   y::Float32
   z::Float32
end

f1(a::Vec3, b::Vec3) = Vec3(a.x % b.x, a.y % b.y, a.z % b.z)

Using it

julia> a = Vec3(1,1,1)
Vec3(1.0f0,1.0f0,1.0f0)

julia> b = Vec3(2,2,2)
Vec3(2.0f0,2.0f0,2.0f0)

julia> f1(a,b)
Vec3(1.0f0,2.0f0,NaN32)

Re-decl and use

Similar to the SO example, modifying slightly "fixes" things.

julia> f2(a::Vec3, b::Vec3) = Vec3(a.x % b.x, a.y % b.y, a.z % b.z + 1)
f1 (generic function with 1 method)

julia> f2(a,b)
Vec3(1.0f0,1.0f0,2.0f0)

f3(a::Vec3, b::Vec3) = Vec3(a.x % b.x, a.y % b.y,  2)
f3 (generic function with 1 method)

julia> f3(a,b)
Vec3(1.0f0,1.0f0,2.0f0)

Code LLVM and native output

julia> code_llvm(f1,(Vec3,Vec3))
define %Vec3 @"julia_f1;62077"(%Vec3, %Vec3) {
top:
  %2 = extractvalue %Vec3 %0, 0, !dbg !1949
  %3 = extractvalue %Vec3 %1, 0, !dbg !1949
  %4 = frem float %2, %3, !dbg !1949
  %5 = insertvalue %Vec3 undef, float %4, 0, !dbg !1949
  %6 = extractvalue %Vec3 %0, 1, !dbg !1949
  %7 = extractvalue %Vec3 %1, 1, !dbg !1949
  %8 = frem float %6, %7, !dbg !1949
  %9 = insertvalue %Vec3 %5, float %8, 1, !dbg !1949
  %10 = extractvalue %Vec3 %0, 2, !dbg !1949
  %11 = extractvalue %Vec3 %1, 2, !dbg !1949
  %12 = frem float %10, %11, !dbg !1949
  %13 = insertvalue %Vec3 %9, float %12, 2, !dbg !1949, !julia_type !1951
  ret %Vec3 %13, !dbg !1949
}
julia> code_native(f1,(Vec3,Vec3))
  .section  __TEXT,__text,regular,pure_instructions
Filename: none
Source line: 1
  push  RBP
  mov   RBP, RSP
  movabs    RAX, 140735600044048
Source line: 1
  vmovaps   XMM0, XMM2
  vmovaps   XMM1, XMM5
  pop   RBP
  jmp   RAX

Platform

Platform Info:
  System: Darwin (x86_64-apple-darwin13.3.0)
  CPU: Intel(R) Core(TM) i7-4850HQ CPU @ 2.30GHz
  WORD_SIZE: 64
  BLAS: libopenblas (USE64BITINT DYNAMIC_ARCH NO_AFFINITY Haswell)
  LAPACK: libopenblas
  LIBM: libopenlibm
  LLVM: libLLVM-3.3
@JeffBezanson JeffBezanson added kind:bug Indicates an unexpected problem or unintended behavior kind:upstream The issue is with an upstream dependency, e.g. LLVM labels Nov 7, 2014
@simonster
Copy link
Member

Appears to work properly with LLVM SVN.

@tkelman
Copy link
Contributor

tkelman commented Sep 17, 2015

There are too many conflicts for me to understand how to backport 13c83db correctly. Can someone else resolve them and open a PR against release-0.4?

vtjnash added a commit that referenced this issue Sep 17, 2015
it seems that the llvm 3.3 return type legalizer may not be properly
handling large types. this is more efficient anyways.

fixes #8932, should fix #12163, probably fixes #7434

(cherry picked from commit 13c83db)
@vtjnash
Copy link
Sponsor Member

vtjnash commented Sep 17, 2015

See 889e31f, if that passes CI

vtjnash added a commit that referenced this issue Sep 17, 2015
it seems that the llvm 3.3 return type legalizer may not be properly
handling large types. this is more efficient anyways.

fixes #8932, should fix #12163, probably fixes #7434

(cherry picked from commit 13c83db)
@tkelman
Copy link
Contributor

tkelman commented Sep 18, 2015

backported in #13182

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
kind:bug Indicates an unexpected problem or unintended behavior kind:upstream The issue is with an upstream dependency, e.g. LLVM
Projects
None yet
Development

No branches or pull requests

5 participants