Skip to content

Commit 936f5da

Browse files
authored
[LLVMCPU] Populate fp4 expansion patterns on CPUs (#21413)
This allows fp4 code, including uses of scaling_extf and scaling_truncf, to run (via software implementation of conversions into/out of the type) on CPU backends. It also moves the bfloat expansion patterns into an earlier pattern set, so that they're no longer actively in conflict with arith-to-llvm.
1 parent 4b83186 commit 936f5da

File tree

2 files changed

+7
-2
lines changed

2 files changed

+7
-2
lines changed

compiler/src/iree/compiler/Codegen/LLVMCPU/ConvertToLLVM.cpp

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1049,7 +1049,6 @@ void ConvertToLLVMPass::runOnOperation() {
10491049
populateFinalizeMemRefToLLVMConversionPatterns(typeConverter, patterns);
10501050
populateFuncToLLVMConversionPatterns(typeConverter, patterns);
10511051
arith::populateArithToLLVMConversionPatterns(typeConverter, patterns);
1052-
arith::populateExpandBFloat16Patterns(patterns);
10531052
index::populateIndexToLLVMConversionPatterns(typeConverter, patterns);
10541053
populateVectorToSCFConversionPatterns(patterns);
10551054
// Some n-D vectors are generated by EmulateNarrowType pass, so we need to

compiler/src/iree/compiler/Codegen/LLVMCPU/Passes.cpp

Lines changed: 7 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -772,7 +772,13 @@ static void addLowerToLLVMPasses(OpPassManager &modulePassManager,
772772
// (HAL, IREE, Linalg, CF) -> LLVM
773773
.addPass(memref::createFoldMemRefAliasOpsPass)
774774
.addPass(affine::createAffineExpandIndexOpsPass)
775-
.addPass(arith::createArithExpandOpsPass)
775+
.addPass([&]() {
776+
arith::ArithExpandOpsPassOptions options;
777+
options.includeBf16 = true;
778+
options.includeF4E2M1 = true;
779+
options.includeF8E8M0 = true;
780+
return arith::createArithExpandOpsPass(options);
781+
})
776782
.addPass(createEmulateNarrowTypePass)
777783
.addPass(createCanonicalizerPass)
778784
.addPass(createCSEPass)

0 commit comments

Comments
 (0)