[SCCP] Limit use of range info for binops to integers for now.
authorFlorian Hahn <flo@fhahn.com>
Tue, 31 Mar 2020 16:08:09 +0000 (17:08 +0100)
committerFlorian Hahn <flo@fhahn.com>
Tue, 31 Mar 2020 16:08:09 +0000 (17:08 +0100)
This fixes a crash when building the test suite.

llvm/lib/Transforms/Scalar/SCCP.cpp
llvm/test/Transforms/SCCP/ip-ranges-casts.ll

index f1e97ce..eba3a11 100644 (file)
@@ -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());
index 6a4e576..c7a53c1 100644 (file)
@@ -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
+}