https://gcc.gnu.org/bugzilla/show_bug.cgi?id=118673
Bug ID: 118673 Summary: [14/15 regression] LLVM's libMLIR miscompiled since r14-1705-g2764335bd336f2 Product: gcc Version: 15.0 Status: UNCONFIRMED Keywords: wrong-code Severity: normal Priority: P3 Component: c++ Assignee: unassigned at gcc dot gnu.org Reporter: sjames at gcc dot gnu.org Target Milestone: --- Created attachment 60293 --> https://gcc.gnu.org/bugzilla/attachment.cgi?id=60293&action=edit IntegerDotProductOps.cpp.ii.gz Originally reported in LLVM over at https://github.com/llvm/llvm-project/issues/124410. I don't have a standalone runtime testcase though. The relevant snippet is: ``` template <typename IntegerDotProductOpTy> static SmallVector<ArrayRef<spirv::Capability>, 1> getIntegerDotProductCapabilities(Operation *op) { // Requires the the DotProduct capability and capabilities that depend on // exact op types. static const auto dotProductCap = spirv::Capability::DotProduct; static const auto dotProductInput4x8BitPackedCap = spirv::Capability::DotProductInput4x8BitPacked; static const auto dotProductInput4x8BitCap = spirv::Capability::DotProductInput4x8Bit; static const auto dotProductInputAllCap = spirv::Capability::DotProductInputAll; SmallVector<ArrayRef<spirv::Capability>, 1> capabilities = {dotProductCap}; Type factorTy = op->getOperand(0).getType(); StringAttr packedVectorFormatAttrName = IntegerDotProductOpTy::getFormatAttrName(op->getName()); if (auto intTy = llvm::dyn_cast<IntegerType>(factorTy)) { auto formatAttr = llvm::cast<spirv::PackedVectorFormatAttr>( op->getAttr(packedVectorFormatAttrName)); if (formatAttr.getValue() == spirv::PackedVectorFormat::PackedVectorFormat4x8Bit) capabilities.push_back(dotProductInput4x8BitPackedCap); return capabilities; } auto vecTy = llvm::cast<VectorType>(factorTy); if (vecTy.getElementTypeBitWidth() == 8) { capabilities.push_back(dotProductInput4x8BitCap); return capabilities; } capabilities.push_back(dotProductInputAllCap); return capabilities; } SmallVector<ArrayRef<spirv::Capability>, 1> UDotAccSatOp::getCapabilities() { return getIntegerDotProductCapabilities<UDotAccSatOp>(*this); } ``` Before/after r14-1705-g2764335bd336f2, the only difference (with some prints added) is: ``` │ Disassembly of section .text._ZN4mlir5spirvL30getIntegerDotProductExtensionsEv: │ │ 0000000000000000 <mlir::spirv::getIntegerDotProductExtensions()>: │ mlir::spirv::getIntegerDotProductExtensions(): │ - lea 0x10(%rdi),%rdx │ - lea 0x0(%rip),%rcx │ - R_X86_64_PC32 .rodata._ZZN4mlir5spirvL30getIntegerDotProductExtensionsEvE9extension-0x4 │ + lea -0xc(%rsp),%rdx │ + lea 0x10(%rdi),%rcx │ mov %rdi,%rax │ movabs $0x100000001,%rsi │ - mov %rdx,(%rdi) │ - mov %rcx,0x10(%rdi) │ + mov %rcx,(%rdi) │ + mov %rdx,0x10(%rdi) │ movq $0x1,0x18(%rdi) │ mov ``` The file was built with: ``` $ g++ -DGTEST_HAS_RTTI=0 -D_GNU_SOURCE -D__STDC_CONSTANT_MACROS -D__STDC_FORMAT_MACROS -D__STDC_LIMIT_MACROS -I/home/sam/llvm/llvm-project/build-bad-after/tools/mlir/lib/Dialect/SPIRV/IR -I/home/sam/llvm/llvm-project/mlir/lib/Dialect/SPIRV/IR -I/home/sam/llvm/llvm-project/build-bad-after/tools/mlir/include -I/home/sam/llvm/llvm-project/mlir/include -I/home/sam/llvm/llvm-project/build-bad-after/include -I/home/sam/llvm/llvm-project/llvm/include -fPIC -fno-semantic-interposition -fvisibility-inlines-hidden -Werror=date-time -fno-lifetime-dse -Wall -Wextra -Wno-unused-parameter -Wwrite-strings -Wcast-qual -Wno-missing-field-initializers -pedantic -Wno-long-long -Wimplicit-fallthrough -Wno-maybe-uninitialized -Wno-nonnull -Wno-class-memaccess -Wno-redundant-move -Wno-pessimizing-move -Wno-noexcept-type -Wdelete-non-virtual-dtor -Wsuggest-override -Wno-comment -Wno-misleading-indentation -Wctad-maybe-unsupported -ffunction-sections -fdata-sections -Wundef -Os -DNDEBUG -std=c++17 -fno-exceptions -funwind-tables -fno-rtti -MD -MT tools/mlir/lib/Dialect/SPIRV/IR/CMakeFiles/obj.MLIRSPIRVDialect.dir/IntegerDotProductOps.cpp.o -MF CMakeFiles/obj.MLIRSPIRVDialect.dir/IntegerDotProductOps.cpp.o.d -o CMakeFiles/obj.MLIRSPIRVDialect.dir/IntegerDotProductOps.cpp.o -c /home/sam/llvm/llvm-project/mlir/lib/Dialect/SPIRV/IR/IntegerDotProductOps.cpp -save-temps ```