[ConstraintElimination] Skip compares with scalable vector types.
authorFlorian Hahn <flo@fhahn.com>
Wed, 2 Nov 2022 23:57:06 +0000 (23:57 +0000)
committerFlorian Hahn <flo@fhahn.com>
Wed, 2 Nov 2022 23:57:14 +0000 (23:57 +0000)
Materializing scalable vectors with boolean values is not implemented
yet. Skip those cases for now and leave a TODO.

llvm/lib/Transforms/Scalar/ConstraintElimination.cpp
llvm/test/Transforms/ConstraintElimination/geps-ptrvector.ll

index 375aa4e..a78bfbb 100644 (file)
@@ -754,6 +754,13 @@ static Constant *getScalarConstOrSplat(ConstantInt *C, Type *Ty) {
 
 static bool checkAndReplaceCondition(CmpInst *Cmp, ConstraintInfo &Info) {
   LLVM_DEBUG(dbgs() << "Checking " << *Cmp << "\n");
+
+  // TODO: Implement splat of boolean value for scalable vectors.
+  if (isa<ScalableVectorType>(Cmp->getType())) {
+    LLVM_DEBUG(dbgs() << "   skipping due to scalable vectors\n");
+    return false;
+  }
+
   CmpInst::Predicate Pred = Cmp->getPredicate();
   Value *A = Cmp->getOperand(0);
   Value *B = Cmp->getOperand(1);
index df91565..0f5a28b 100644 (file)
@@ -34,3 +34,26 @@ define <2 x i1> @test.vectorgep.ult.false(<2 x ptr> %vec) {
   %t.1 = icmp ult <2 x ptr> %gep.1, %vec
   ret <2 x i1> %t.1
 }
+
+
+define <vscale x 2 x i1> @test.scalable.vectorgep.ult.true(<vscale x 2 x ptr> %vec) {
+; CHECK-LABEL: @test.scalable.vectorgep.ult.true(
+; CHECK-NEXT:    [[GEP_1:%.*]] = getelementptr inbounds i32, <vscale x 2 x ptr> [[VEC:%.*]], i64 1
+; CHECK-NEXT:    [[T_1:%.*]] = icmp ult <vscale x 2 x ptr> [[VEC]], [[GEP_1]]
+; CHECK-NEXT:    ret <vscale x 2 x i1> [[T_1]]
+;
+  %gep.1 = getelementptr inbounds i32, <vscale x 2 x ptr> %vec, i64 1
+  %t.1 = icmp ult <vscale x 2 x ptr> %vec, %gep.1
+  ret <vscale x 2 x i1> %t.1
+}
+
+define <vscale x 2 x i1> @test.scalable.vectorgep.ult.false(<vscale x 2 x ptr> %vec) {
+; CHECK-LABEL: @test.scalable.vectorgep.ult.false(
+; CHECK-NEXT:    [[GEP_1:%.*]] = getelementptr inbounds i32, <vscale x 2 x ptr> [[VEC:%.*]], i64 1
+; CHECK-NEXT:    [[T_1:%.*]] = icmp ult <vscale x 2 x ptr> [[GEP_1]], [[VEC]]
+; CHECK-NEXT:    ret <vscale x 2 x i1> [[T_1]]
+;
+  %gep.1 = getelementptr inbounds i32, <vscale x 2 x ptr> %vec, i64 1
+  %t.1 = icmp ult <vscale x 2 x ptr> %gep.1, %vec
+  ret <vscale x 2 x i1> %t.1
+}