Skip to content

Revert "[WebAssembly] Constant fold wasm.dot" #152382

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Merged
merged 1 commit into from
Aug 6, 2025

Conversation

alazarev
Copy link
Contributor

@alazarev alazarev commented Aug 6, 2025

Reverts #149619

It breaks ubsan bot:
https://lab.llvm.org/buildbot/#/builders/25/builds/10523

Earlier today the failure was hidden by another breakage that is fixed now.

@llvmbot llvmbot added llvm:instcombine Covers the InstCombine, InstSimplify and AggressiveInstCombine passes llvm:analysis Includes value tracking, cost tables and constant folding llvm:transforms labels Aug 6, 2025
@llvmbot
Copy link
Member

llvmbot commented Aug 6, 2025

@llvm/pr-subscribers-llvm-analysis

@llvm/pr-subscribers-llvm-transforms

Author: Andrew Lazarev (alazarev)

Changes

Reverts llvm/llvm-project#149619

It breaks ubsan bot:
https://lab.llvm.org/buildbot/#/builders/25/builds/10523

Earlier today the failure was hidden by another breakage that is fixed now.


Full diff: https://github.com/llvm/llvm-project/pull/152382.diff

2 Files Affected:

  • (modified) llvm/lib/Analysis/ConstantFolding.cpp (-25)
  • (removed) llvm/test/Transforms/InstSimplify/ConstProp/WebAssembly/dot.ll (-56)
diff --git a/llvm/lib/Analysis/ConstantFolding.cpp b/llvm/lib/Analysis/ConstantFolding.cpp
index 4969528a1b29b..dd98b62baca33 100644
--- a/llvm/lib/Analysis/ConstantFolding.cpp
+++ b/llvm/lib/Analysis/ConstantFolding.cpp
@@ -1659,7 +1659,6 @@ bool llvm::canConstantFoldCallTo(const CallBase *Call, const Function *F) {
   case Intrinsic::aarch64_sve_convert_from_svbool:
   case Intrinsic::wasm_alltrue:
   case Intrinsic::wasm_anytrue:
-  case Intrinsic::wasm_dot:
   // WebAssembly float semantics are always known
   case Intrinsic::wasm_trunc_signed:
   case Intrinsic::wasm_trunc_unsigned:
@@ -3990,30 +3989,6 @@ static Constant *ConstantFoldFixedVectorCall(
     }
     return ConstantVector::get(Result);
   }
-  case Intrinsic::wasm_dot: {
-    unsigned NumElements =
-        cast<FixedVectorType>(Operands[0]->getType())->getNumElements();
-
-    assert(NumElements == 8 && Result.size() == 4 &&
-           "wasm dot takes i16x8 and produces i32x4");
-    assert(Ty->isIntegerTy());
-    int32_t MulVector[8];
-
-    for (unsigned I = 0; I < NumElements; ++I) {
-      ConstantInt *Elt0 =
-          cast<ConstantInt>(Operands[0]->getAggregateElement(I));
-      ConstantInt *Elt1 =
-          cast<ConstantInt>(Operands[1]->getAggregateElement(I));
-
-      MulVector[I] = Elt0->getSExtValue() * Elt1->getSExtValue();
-    }
-    for (unsigned I = 0; I < Result.size(); I++) {
-      int32_t IAdd = MulVector[I * 2] + MulVector[I * 2 + 1];
-      Result[I] = ConstantInt::get(Ty, IAdd);
-    }
-
-    return ConstantVector::get(Result);
-  }
   default:
     break;
   }
diff --git a/llvm/test/Transforms/InstSimplify/ConstProp/WebAssembly/dot.ll b/llvm/test/Transforms/InstSimplify/ConstProp/WebAssembly/dot.ll
deleted file mode 100644
index b537b7bccf861..0000000000000
--- a/llvm/test/Transforms/InstSimplify/ConstProp/WebAssembly/dot.ll
+++ /dev/null
@@ -1,56 +0,0 @@
-; NOTE: Assertions have been autogenerated by utils/update_test_checks.py UTC_ARGS: --version 5
-
-; RUN: opt -passes=instsimplify -S < %s | FileCheck %s
-
-; Test that intrinsics wasm dot call are constant folded
-
-target triple = "wasm32-unknown-unknown"
-
-
-define <4 x i32> @dot_zero() {
-; CHECK-LABEL: define <4 x i32> @dot_zero() {
-; CHECK-NEXT:    ret <4 x i32> zeroinitializer
-;
-  %res = tail call <4 x i32> @llvm.wasm.dot(<8 x i16> zeroinitializer, <8 x i16> zeroinitializer)
-  ret <4 x i32> %res
-}
-
-; a               =   1    2    3    4    5    6    7    8
-; b               =   1    2    3    4    5    6    7    8
-; k1|k2 = a * b   =   1    4    9   16   25   36   49   64
-; k1 + k2         =   (1+4) |  (9 + 16) | (25 + 36)  | (49 + 64)
-; result          =    5    |   25    |   61    |   113
-define <4 x i32> @dot_nonzero() {
-; CHECK-LABEL: define <4 x i32> @dot_nonzero() {
-; CHECK-NEXT:    ret <4 x i32> <i32 5, i32 25, i32 61, i32 113>
-;
-  %res = tail call <4 x i32> @llvm.wasm.dot(<8 x i16> <i16 1, i16 2, i16 3, i16 4, i16 5, i16 6, i16 7, i16 8>, <8 x i16> <i16 1, i16 2, i16 3, i16 4, i16 5, i16 6, i16 7, i16 8>)
-  ret <4 x i32> %res
-}
-
-define <4 x i32> @dot_doubly_negative() {
-; CHECK-LABEL: define <4 x i32> @dot_doubly_negative() {
-; CHECK-NEXT:    ret <4 x i32> splat (i32 2)
-;
-  %res = tail call <4 x i32> @llvm.wasm.dot(<8 x i16> <i16 -1, i16 -1, i16 -1, i16 -1, i16 -1, i16 -1, i16 -1, i16 -1>, <8 x i16> <i16 -1, i16 -1, i16 -1, i16 -1, i16 -1, i16 -1, i16 -1, i16 -1>)
-  ret <4 x i32> %res
-}
-
-; Tests that i16 max signed values fit in i32
-define <4 x i32> @dot_follow_modulo_spec_1() {
-; CHECK-LABEL: define <4 x i32> @dot_follow_modulo_spec_1() {
-; CHECK-NEXT:    ret <4 x i32> <i32 2147352578, i32 0, i32 0, i32 0>
-;
-  %res = tail call <4 x i32> @llvm.wasm.dot(<8 x i16> <i16 32767, i16 32767, i16 0, i16 0, i16 0, i16 0, i16 0, i16 0>, <8 x i16> <i16 32767, i16 32767, i16 0, i16 0, i16 0, i16 0, i16 0, i16 0>)
-  ret <4 x i32> %res
-}
-
-; Tests that i16 min signed values fit in i32
-define <4 x i32> @dot_follow_modulo_spec_2() {
-; CHECK-LABEL: define <4 x i32> @dot_follow_modulo_spec_2() {
-; CHECK-NEXT:    ret <4 x i32> <i32 -2147483648, i32 0, i32 0, i32 0>
-;
-  %res = tail call <4 x i32> @llvm.wasm.dot(<8 x i16> <i16 -32768, i16 -32768, i16 0, i16 0, i16 0, i16 0, i16 0, i16 0>, <8 x i16> <i16 -32768, i16 -32768, i16 0, i16 0, i16 0, i16 0, i16 0, i16 0>)
-  ret <4 x i32> %res
-}
-

@vitalybuka vitalybuka merged commit f615269 into llvm:main Aug 6, 2025
13 checks passed
@llvm-ci
Copy link
Collaborator

llvm-ci commented Aug 6, 2025

LLVM Buildbot has detected a new failure on builder lldb-aarch64-ubuntu running on linaro-lldb-aarch64-ubuntu while building llvm at step 6 "test".

Full details are available at: https://lab.llvm.org/buildbot/#/builders/59/builds/22233

Here is the relevant piece of the build log for the reference
Step 6 (test) failure: build (failure)
...
PASS: lldb-api :: python_api/process/cancel_attach/TestCancelAttach.py (1184 of 2304)
PASS: lldb-api :: tools/lldb-dap/breakpoint/TestDAP_setExceptionBreakpoints.py (1185 of 2304)
PASS: lldb-api :: tools/lldb-dap/breakpoint/TestDAP_setFunctionBreakpoints.py (1186 of 2304)
PASS: lldb-api :: tools/lldb-dap/breakpoint/TestDAP_setBreakpoints.py (1187 of 2304)
PASS: lldb-api :: python_api/watchpoint/watchlocation/TestTargetWatchAddress.py (1188 of 2304)
PASS: lldb-api :: tools/lldb-dap/commands/TestDAP_commands.py (1189 of 2304)
PASS: lldb-api :: tools/lldb-dap/console/TestDAP_redirection_to_console.py (1190 of 2304)
PASS: lldb-api :: tools/lldb-dap/completions/TestDAP_completions.py (1191 of 2304)
PASS: lldb-api :: tools/lldb-dap/coreFile/TestDAP_coreFile.py (1192 of 2304)
UNRESOLVED: lldb-api :: functionalities/statusline/TestStatusline.py (1193 of 2304)
******************** TEST 'lldb-api :: functionalities/statusline/TestStatusline.py' FAILED ********************
Script:
--
/usr/bin/python3.10 /home/tcwg-buildbot/worker/lldb-aarch64-ubuntu/llvm-project/lldb/test/API/dotest.py -u CXXFLAGS -u CFLAGS --env LLVM_LIBS_DIR=/home/tcwg-buildbot/worker/lldb-aarch64-ubuntu/build/./lib --env LLVM_INCLUDE_DIR=/home/tcwg-buildbot/worker/lldb-aarch64-ubuntu/build/include --env LLVM_TOOLS_DIR=/home/tcwg-buildbot/worker/lldb-aarch64-ubuntu/build/./bin --arch aarch64 --build-dir /home/tcwg-buildbot/worker/lldb-aarch64-ubuntu/build/lldb-test-build.noindex --lldb-module-cache-dir /home/tcwg-buildbot/worker/lldb-aarch64-ubuntu/build/lldb-test-build.noindex/module-cache-lldb/lldb-api --clang-module-cache-dir /home/tcwg-buildbot/worker/lldb-aarch64-ubuntu/build/lldb-test-build.noindex/module-cache-clang/lldb-api --executable /home/tcwg-buildbot/worker/lldb-aarch64-ubuntu/build/./bin/lldb --compiler /home/tcwg-buildbot/worker/lldb-aarch64-ubuntu/build/./bin/clang --dsymutil /home/tcwg-buildbot/worker/lldb-aarch64-ubuntu/build/./bin/dsymutil --make /usr/bin/gmake --llvm-tools-dir /home/tcwg-buildbot/worker/lldb-aarch64-ubuntu/build/./bin --lldb-obj-root /home/tcwg-buildbot/worker/lldb-aarch64-ubuntu/build/tools/lldb --lldb-libs-dir /home/tcwg-buildbot/worker/lldb-aarch64-ubuntu/build/./lib --cmake-build-type Release /home/tcwg-buildbot/worker/lldb-aarch64-ubuntu/llvm-project/lldb/test/API/functionalities/statusline -p TestStatusline.py
--
Exit Code: 1

Command Output (stdout):
--
lldb version 22.0.0git (https://github.com/llvm/llvm-project.git revision f61526971f9c62118090443c8b97fab07ae9499f)
  clang revision f61526971f9c62118090443c8b97fab07ae9499f
  llvm revision f61526971f9c62118090443c8b97fab07ae9499f
Skipping the following test categories: ['libc++', 'msvcstl', 'dsym', 'gmodules', 'debugserver', 'objc']

--
Command Output (stderr):
--
PASS: LLDB (/home/tcwg-buildbot/worker/lldb-aarch64-ubuntu/build/bin/clang-aarch64) :: test (TestStatusline.TestStatusline)
PASS: LLDB (/home/tcwg-buildbot/worker/lldb-aarch64-ubuntu/build/bin/clang-aarch64) :: test_deadlock (TestStatusline.TestStatusline)
lldb-server exiting...
FAIL: LLDB (/home/tcwg-buildbot/worker/lldb-aarch64-ubuntu/build/bin/clang-aarch64) :: test_modulelist_deadlock (TestStatusline.TestStatusline)
PASS: LLDB (/home/tcwg-buildbot/worker/lldb-aarch64-ubuntu/build/bin/clang-aarch64) :: test_no_color (TestStatusline.TestStatusline)
PASS: LLDB (/home/tcwg-buildbot/worker/lldb-aarch64-ubuntu/build/bin/clang-aarch64) :: test_no_target (TestStatusline.TestStatusline)
PASS: LLDB (/home/tcwg-buildbot/worker/lldb-aarch64-ubuntu/build/bin/clang-aarch64) :: test_resize (TestStatusline.TestStatusline)
======================================================================
ERROR: test_modulelist_deadlock (TestStatusline.TestStatusline)
   Regression test for a deadlock that occurs when the status line is enabled before connecting
----------------------------------------------------------------------
Traceback (most recent call last):
  File "/home/tcwg-buildbot/worker/lldb-aarch64-ubuntu/llvm-project/lldb/test/API/functionalities/statusline/TestStatusline.py", line 199, in test_modulelist_deadlock
    self.expect(
  File "/home/tcwg-buildbot/worker/lldb-aarch64-ubuntu/llvm-project/lldb/packages/Python/lldbsuite/test/lldbpexpect.py", line 95, in expect
    self.expect_prompt()
  File "/home/tcwg-buildbot/worker/lldb-aarch64-ubuntu/llvm-project/lldb/packages/Python/lldbsuite/test/lldbpexpect.py", line 19, in expect_prompt
    self.child.expect_exact(self.PROMPT)
  File "/usr/local/lib/python3.10/dist-packages/pexpect/spawnbase.py", line 432, in expect_exact
    return exp.expect_loop(timeout)
  File "/usr/local/lib/python3.10/dist-packages/pexpect/expect.py", line 181, in expect_loop
    return self.timeout(e)

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
llvm:analysis Includes value tracking, cost tables and constant folding llvm:instcombine Covers the InstCombine, InstSimplify and AggressiveInstCombine passes llvm:transforms
Projects
None yet
Development

Successfully merging this pull request may close these issues.

4 participants