Skip to content

Commit

Permalink
Skip out of SimplifyDemandedBits for BITCAST of f16 to i16
Browse files Browse the repository at this point in the history
Mirrors the existing exit path for f128, avoiding a crash later on.

Differential Revision: https://reviews.llvm.org/D49524

llvm-svn: 337506
  • Loading branch information
stephentyrone committed Jul 19, 2018
1 parent df81b97 commit 8995c5f
Showing 2 changed files with 11 additions and 0 deletions.
1 change: 1 addition & 0 deletions llvm/lib/CodeGen/SelectionDAG/TargetLowering.cpp
Original file line number Diff line number Diff line change
@@ -1187,6 +1187,7 @@ bool TargetLowering::SimplifyDemandedBits(SDValue Op,
bool OpVTLegal = isOperationLegalOrCustom(ISD::FGETSIGN, VT);
bool i32Legal = isOperationLegalOrCustom(ISD::FGETSIGN, MVT::i32);
if ((OpVTLegal || i32Legal) && VT.isSimple() &&
Op.getOperand(0).getValueType() != MVT::f16 &&
Op.getOperand(0).getValueType() != MVT::f128) {
// Cannot eliminate/lower SHL for f128 yet.
EVT Ty = OpVTLegal ? VT : MVT::i32;
10 changes: 10 additions & 0 deletions llvm/test/CodeGen/X86/pr38038.ll
Original file line number Diff line number Diff line change
@@ -0,0 +1,10 @@
; RUN: llc < %s
; PR38038

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
}

0 comments on commit 8995c5f

Please sign in to comment.