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

[SR-7763] Optimization forms illegal shift node #50302

Closed
stephentyrone opened this issue May 24, 2018 · 8 comments
Closed

[SR-7763] Optimization forms illegal shift node #50302

stephentyrone opened this issue May 24, 2018 · 8 comments
Labels
bug A deviation from expected or documented behavior. Also: expected but undesirable behavior. compiler The Swift compiler in itself crash Bug: A crash, i.e., an abnormal termination of software optimized only Flag: An issue whose reproduction requires optimized compilation

Comments

@stephentyrone
Copy link
Member

Previous ID SR-7763
Radar rdar://problem/40555524
Original Reporter @stephentyrone
Type Bug
Status Resolved
Resolution Done
Additional Detail from JIRA
Votes 0
Component/s Compiler
Labels Bug, CompilerCrash, OptimizedOnly
Assignee None
Priority Medium

md5: 05528d753c6ad92bed689b3bfc2003e9

Issue Description:

https://godbolt.org/g/94XBpN

import Swift

public struct Float16 {
  public var _value: Builtin.FPIEEE16
  
  public var bitPattern: UInt16 {
    return UInt16(Builtin.bitcast_FPIEEE16_Int16(_value))
  }
  
  public var sign: FloatingPointSign {
    return FloatingPointSign(rawValue: Int(bitPattern >> 15))!
  }
}

Compiling with -parse-stdlib -O fails in LLVM:

llvm/lib/CodeGen/SelectionDAG/SelectionDAG.cpp:4168: llvm::SDValue llvm::SelectionDAG::getNode(unsigned int, const llvm::SDLoc &, llvm::EVT, llvm::SDValue, llvm::SDValue, const llvm::SDNodeFlags): Assertion `VT == N1.getValueType() && "Shift operators return type must be the same as their first arg"' failed.

I haven't had time to investigate this much, so I'm not sure where in the process the bad node is getting formed.

@stephentyrone
Copy link
Member Author

Does not occur with optimization turned off. Present in both shipping 4.x and ToT.

@belkadan
Copy link
Contributor

cc aschwaighofer@apple.com (JIRA User)

@belkadan
Copy link
Contributor

@swift-ci create

@aschwaighofer
Copy link
Member

LLVM bug

$ cat c.ll
define i8 @crash(half)  {
entry:
  %1 = bitcast half %0 to i16
  %.lobit = lshr i16 %1, 15
  %2 = trunc i16 %.lobit to i8
  ret i8 %2
}

$ build01/llvm-macosx-x86_64/bin/llc c.ll
Assertion failed: (VT == N1.getValueType() && "Shift operators return type must be the same as their first arg"), function getNode, file /Users/arnold/Github/llvm/lib/CodeGen/SelectionDAG/SelectionDAG.cpp, line 4351.

@stephentyrone
Copy link
Member Author

@belkadan
Copy link
Contributor

belkadan commented Apr 4, 2019

The Apple LLVM folks fixed this for Swift 5.

@stephentyrone
Copy link
Member Author

@belkadan I wasn't aware I was one of the "LLVM folks" now =)

@belkadan
Copy link
Contributor

belkadan commented Apr 4, 2019

Oops, I didn't see that it was your fix rather than Ahmed's. But I suppose that makes you an LLVM folks anyway!

@swift-ci swift-ci transferred this issue from apple/swift-issues Apr 25, 2022
@AnthonyLatsis AnthonyLatsis added the crash Bug: A crash, i.e., an abnormal termination of software label Dec 12, 2022
This issue was closed.
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
bug A deviation from expected or documented behavior. Also: expected but undesirable behavior. compiler The Swift compiler in itself crash Bug: A crash, i.e., an abnormal termination of software optimized only Flag: An issue whose reproduction requires optimized compilation
Projects
None yet
Development

No branches or pull requests

4 participants