Branch: refs/heads/main
  Home:   https://github.com/WebKit/WebKit
  Commit: bccb52eace5ba6706ce9d44c7dadd1b1a8b9055c
      
https://github.com/WebKit/WebKit/commit/bccb52eace5ba6706ce9d44c7dadd1b1a8b9055c
  Author: Sergey Rubanov <[email protected]>
  Date:   2026-07-16 (Thu, 16 Jul 2026)

  Changed paths:
    A JSTests/wasm/stress/divide-rem-by-negative-constant-power-of-two.js
    M Source/JavaScriptCore/wasm/WasmBBQJIT64.h

  Log Message:
  -----------
  [JSC] BBQ: strength-reduce signed div/rem by negative power-of-two constants
https://bugs.webkit.org/show_bug.cgi?id=269744

Reviewed by Keith Miller.

When BBQ sees a constant divisor that is a power of two, it turns
div/rem into shifts and masks. That path only ran for positive
divisors, so values like -2 or -32 always took the slow general case.

This extends the same path to negative signed divisors by working
with the absolute value. Remainder does not depend on the sign of
the divisor, so it can reuse the positive case as-is. Division by a
negative power of two is just the positive result with the sign
flipped. Taking the magnitude of INT_MIN needs a bit of care since
it is not representable as a signed integer.

* Source/JavaScriptCore/wasm/WasmBBQJIT64.h:
(JSC::Wasm::BBQJIT::emitModOrDiv):
* JSTests/wasm/stress/divide-rem-by-negative-constant-power-of-two.js: Added.

Canonical link: https://commits.webkit.org/317309@main



To unsubscribe from these emails, change your notification settings at 
https://github.com/WebKit/WebKit/settings/notifications

Reply via email to