diff --git a/WORKSPACE.bazel b/WORKSPACE.bazel index 69ec464bad6..7e1dd60ea7c 100644 --- a/WORKSPACE.bazel +++ b/WORKSPACE.bazel @@ -17,9 +17,9 @@ workspace(name = "stablehlo") load("@bazel_tools//tools/build_defs/repo:http.bzl", "http_archive") -LLVM_COMMIT = "dd7d81ea49bf39e1d69bbb84bd3f31bd95519369" +LLVM_COMMIT = "84658fb82b67fc22ecba1560d0cddd09f9104178" -LLVM_SHA256 = "fbd43ef20f4209b0619e209e48c431f76008917714a8c5336063e1ff51d8d084" +LLVM_SHA256 = "b4a50d36a8ab0284f7022f61bbf07a2fb3ea25c6bb2cc422d2418c23b61366da" http_archive( name = "llvm-raw", diff --git a/build_tools/llvm_version.txt b/build_tools/llvm_version.txt index a742a8cd21b..8a1b137263f 100644 --- a/build_tools/llvm_version.txt +++ b/build_tools/llvm_version.txt @@ -1 +1 @@ -dd7d81ea49bf39e1d69bbb84bd3f31bd95519369 +84658fb82b67fc22ecba1560d0cddd09f9104178 diff --git a/stablehlo/conversions/linalg/transforms/TypeConversion.cpp b/stablehlo/conversions/linalg/transforms/TypeConversion.cpp index a77097c7557..12f32fa172d 100644 --- a/stablehlo/conversions/linalg/transforms/TypeConversion.cpp +++ b/stablehlo/conversions/linalg/transforms/TypeConversion.cpp @@ -66,17 +66,25 @@ std::optional materializeCastToIllegal(OpBuilder &builder, Type type, ->getResult(0); } -std::optional scalarToTensor(OpBuilder &builder, Type /*type*/, +std::optional scalarToTensor(OpBuilder &builder, Type type, ValueRange inputs, Location loc) { assert(inputs.size() == 1); - if (llvm::isa(inputs.front().getType())) { + if (mlir::isa(inputs.front().getType())) { return std::nullopt; } - return builder - .create( - loc, RankedTensorType::get({}, inputs.front().getType()), - inputs.front()) - .getResult(); + Value result = + builder + .create( + loc, RankedTensorType::get({}, inputs.front().getType()), + inputs.front()) + .getResult(); + // Convert to a signed integer if necessary. + Type elementType = mlir::getElementTypeOrSelf(type); + if (elementType.isInteger() && !elementType.isSignlessInteger()) { + result = builder.create(loc, type, result) + ->getResult(0); + } + return result; } } // namespace diff --git a/stablehlo/tests/vhlo/stablehlo_legalize_to_vhlo.0_18_0.mlir.bc b/stablehlo/tests/vhlo/stablehlo_legalize_to_vhlo.0_18_0.mlir.bc index 689795f4666..8ad245638fa 100644 Binary files a/stablehlo/tests/vhlo/stablehlo_legalize_to_vhlo.0_18_0.mlir.bc and b/stablehlo/tests/vhlo/stablehlo_legalize_to_vhlo.0_18_0.mlir.bc differ diff --git a/stablehlo/tests/vhlo/stablehlo_legalize_to_vhlo.0_19_0.mlir.bc b/stablehlo/tests/vhlo/stablehlo_legalize_to_vhlo.0_19_0.mlir.bc index 8c6ee28cf6e..dc37b3c3e31 100644 Binary files a/stablehlo/tests/vhlo/stablehlo_legalize_to_vhlo.0_19_0.mlir.bc and b/stablehlo/tests/vhlo/stablehlo_legalize_to_vhlo.0_19_0.mlir.bc differ diff --git a/stablehlo/tests/vhlo/stablehlo_legalize_to_vhlo.0_20_0.mlir.bc b/stablehlo/tests/vhlo/stablehlo_legalize_to_vhlo.0_20_0.mlir.bc index d51236cafec..29e8f33a83d 100644 Binary files a/stablehlo/tests/vhlo/stablehlo_legalize_to_vhlo.0_20_0.mlir.bc and b/stablehlo/tests/vhlo/stablehlo_legalize_to_vhlo.0_20_0.mlir.bc differ diff --git a/stablehlo/tests/vhlo/stablehlo_legalize_to_vhlo.1_0_0.mlir.bc b/stablehlo/tests/vhlo/stablehlo_legalize_to_vhlo.1_0_0.mlir.bc index 1dee15ac30a..361278084ca 100644 Binary files a/stablehlo/tests/vhlo/stablehlo_legalize_to_vhlo.1_0_0.mlir.bc and b/stablehlo/tests/vhlo/stablehlo_legalize_to_vhlo.1_0_0.mlir.bc differ diff --git a/stablehlo/tests/vhlo/stablehlo_legalize_to_vhlo.1_1_0.mlir.bc b/stablehlo/tests/vhlo/stablehlo_legalize_to_vhlo.1_1_0.mlir.bc index 037d3424eb8..e7645b604af 100644 Binary files a/stablehlo/tests/vhlo/stablehlo_legalize_to_vhlo.1_1_0.mlir.bc and b/stablehlo/tests/vhlo/stablehlo_legalize_to_vhlo.1_1_0.mlir.bc differ diff --git a/stablehlo/tests/vhlo/stablehlo_legalize_to_vhlo.1_2_0.mlir.bc b/stablehlo/tests/vhlo/stablehlo_legalize_to_vhlo.1_2_0.mlir.bc index 14d46adb929..65050e9dd21 100644 Binary files a/stablehlo/tests/vhlo/stablehlo_legalize_to_vhlo.1_2_0.mlir.bc and b/stablehlo/tests/vhlo/stablehlo_legalize_to_vhlo.1_2_0.mlir.bc differ diff --git a/stablehlo/tests/vhlo/stablehlo_legalize_to_vhlo.1_3_0.mlir.bc b/stablehlo/tests/vhlo/stablehlo_legalize_to_vhlo.1_3_0.mlir.bc index dce39194d4a..5044c515901 100644 Binary files a/stablehlo/tests/vhlo/stablehlo_legalize_to_vhlo.1_3_0.mlir.bc and b/stablehlo/tests/vhlo/stablehlo_legalize_to_vhlo.1_3_0.mlir.bc differ diff --git a/stablehlo/tests/vhlo/stablehlo_legalize_to_vhlo.1_4_0.mlir.bc b/stablehlo/tests/vhlo/stablehlo_legalize_to_vhlo.1_4_0.mlir.bc index ac1894894e9..fa842c041e3 100644 Binary files a/stablehlo/tests/vhlo/stablehlo_legalize_to_vhlo.1_4_0.mlir.bc and b/stablehlo/tests/vhlo/stablehlo_legalize_to_vhlo.1_4_0.mlir.bc differ diff --git a/stablehlo/transforms/StablehloLegalizeQuantToInt.cpp b/stablehlo/transforms/StablehloLegalizeQuantToInt.cpp index 9589b814693..6faacf5f772 100644 --- a/stablehlo/transforms/StablehloLegalizeQuantToInt.cpp +++ b/stablehlo/transforms/StablehloLegalizeQuantToInt.cpp @@ -1270,12 +1270,13 @@ class ConvertGenericOp : public ConversionPattern { OperationState state(op->getLoc(), op->getName().getStringRef(), operands, newResultTypes, op->getAttrs(), op->getSuccessors()); for (Region ®ion : op->getRegions()) { - Region &newRegion = *state.addRegion(); - rewriter.inlineRegionBefore(region, newRegion, newRegion.begin()); - if (failed( - rewriter.convertRegionTypes(&newRegion, *getTypeConverter()))) { + auto newRegion = std::make_unique(op); + rewriter.inlineRegionBefore(region, *newRegion, newRegion->begin()); + if (failed(rewriter.convertRegionTypes(newRegion.get(), + *getTypeConverter()))) { return failure(); } + state.addRegion(std::move(newRegion)); } Operation *newOp = rewriter.create(state); rewriter.replaceOp(op, newOp);