Skip to content

Commit b0cd7b2

Browse files
committed
[SCCP] Limit use of range info for binops to integers for now.
This fixes a crash when building the test suite.
1 parent 998118c commit b0cd7b2

File tree

2 files changed

+21
-0
lines changed

2 files changed

+21
-0
lines changed

llvm/lib/Transforms/Scalar/SCCP.cpp

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -965,6 +965,10 @@ void SCCPSolver::visitBinaryOperator(Instruction &I) {
965965
return (void)markConstant(IV, &I, C);
966966
}
967967

968+
// Only use ranges for binary operators on integers.
969+
if (!I.getType()->isIntegerTy())
970+
return markOverdefined(&I);
971+
968972
// Operands are either constant ranges, notconstant, overdefined or one of the
969973
// operands is a constant.
970974
ConstantRange A = ConstantRange::getFull(I.getType()->getScalarSizeInBits());

llvm/test/Transforms/SCCP/ip-ranges-casts.ll

Lines changed: 17 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -294,3 +294,20 @@ define i1 @int_range_to_double_cast(i32 %a) {
294294
%tmp11 = fcmp olt double %tmp4, %tmp10
295295
ret i1 %tmp11
296296
}
297+
298+
; Make sure we do not use ranges to propagate info from vectors.
299+
define i16 @vector_binop_and_cast() {
300+
; CHECK-LABEL: define i16 @vector_binop_and_cast(
301+
; CHECK-NEXT: entry:
302+
; 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
303+
; CHECK-NEXT: %rem = srem <8 x i16> <i16 2, i16 2, i16 2, i16 2, i16 2, i16 2, i16 2, i16 2>, %vecinit7
304+
; CHECK-NEXT: %0 = bitcast <8 x i16> %rem to i128
305+
; CHECK-NEXT: %1 = trunc i128 %0 to i16
306+
; CHECK-NEXT: ret i16 %1
307+
entry:
308+
%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
309+
%rem = srem <8 x i16> <i16 2, i16 2, i16 2, i16 2, i16 2, i16 2, i16 2, i16 2>, %vecinit7
310+
%0 = bitcast <8 x i16> %rem to i128
311+
%1 = trunc i128 %0 to i16
312+
ret i16 %1
313+
}

0 commit comments

Comments
 (0)