Skip to content

Commit

Permalink
[SCCP] Limit use of range info for binops to integers for now.
Browse files Browse the repository at this point in the history
This fixes a crash when building the test suite.
  • Loading branch information
fhahn committed Mar 31, 2020
1 parent 998118c commit b0cd7b2
Show file tree
Hide file tree
Showing 2 changed files with 21 additions and 0 deletions.
4 changes: 4 additions & 0 deletions llvm/lib/Transforms/Scalar/SCCP.cpp
Expand Up @@ -965,6 +965,10 @@ void SCCPSolver::visitBinaryOperator(Instruction &I) {
return (void)markConstant(IV, &I, C);
}

// Only use ranges for binary operators on integers.
if (!I.getType()->isIntegerTy())
return markOverdefined(&I);

// Operands are either constant ranges, notconstant, overdefined or one of the
// operands is a constant.
ConstantRange A = ConstantRange::getFull(I.getType()->getScalarSizeInBits());
Expand Down
17 changes: 17 additions & 0 deletions llvm/test/Transforms/SCCP/ip-ranges-casts.ll
Expand Up @@ -294,3 +294,20 @@ define i1 @int_range_to_double_cast(i32 %a) {
%tmp11 = fcmp olt double %tmp4, %tmp10
ret i1 %tmp11
}

; Make sure we do not use ranges to propagate info from vectors.
define i16 @vector_binop_and_cast() {
; CHECK-LABEL: define i16 @vector_binop_and_cast(
; CHECK-NEXT: entry:
; CHECK-NEXT: %vecinit7 = insertelement <8 x i16> <i16 undef, i16 1, i16 2, i16 3, i16 4, i16 5, i16 6, i16 7>, i16 undef, i32 0
; CHECK-NEXT: %rem = srem <8 x i16> <i16 2, i16 2, i16 2, i16 2, i16 2, i16 2, i16 2, i16 2>, %vecinit7
; CHECK-NEXT: %0 = bitcast <8 x i16> %rem to i128
; CHECK-NEXT: %1 = trunc i128 %0 to i16
; CHECK-NEXT: ret i16 %1
entry:
%vecinit7 = insertelement <8 x i16> <i16 undef, i16 1, i16 2, i16 3, i16 4, i16 5, i16 6, i16 7>, i16 undef, i32 0
%rem = srem <8 x i16> <i16 2, i16 2, i16 2, i16 2, i16 2, i16 2, i16 2, i16 2>, %vecinit7
%0 = bitcast <8 x i16> %rem to i128
%1 = trunc i128 %0 to i16
ret i16 %1
}

0 comments on commit b0cd7b2

Please sign in to comment.