Ignore:
Timestamp:
Apr 4, 2017, 3:37:51 PM (8 years ago)
Author:
[email protected]
Message:

B3::LowerToAir incorrectly selects BitXor(AtomicStrongCAS(...), $1)
https://bugs.webkit.org/show_bug.cgi?id=169867

Reviewed by Saam Barati.

The BitXor(AtomicWeakCAS(...), $1) optimization makes a lot of sense because we an fold the
BitXor into the CAS condition read-out. But there is no version of this that is profitable or
correct for AtomicStrongCAS. The inversion case is handled by Equal(AtomicStrongCAS(...), ...)
becoming NotEqual(AtomicStrongCAS(...), ...), and we alraedy handle that separately.

So, the fix here is to make the BitXor CAS pattern only recognize AtomicWeakCAS.

  • b3/B3LowerToAir.cpp:

(JSC::B3::Air::LowerToAir::lower):

  • b3/testb3.cpp:

(JSC::B3::testAtomicStrongCAS):

File:
1 edited

Legend:

Unmodified
Added
Removed
  • trunk/Source/JavaScriptCore/b3/testb3.cpp

    r214901 r214908  
    1486614866        value[0] = static_cast<T>(-1);
    1486714867        CHECK_EQ(invoke<typename NativeTraits<T>::CanonicalType>(*code, value), static_cast<typename NativeTraits<T>::CanonicalType>(static_cast<T>(-1)));
     14868        CHECK_EQ(value[0], static_cast<T>(-1));
     14869        CHECK_EQ(value[1], 13);
     14870        checkMyDisassembly(*code, true);
     14871    }
     14872   
     14873    {
     14874        // Test for https://bugs.webkit.org/show_bug.cgi?id=169867.
     14875       
     14876        Procedure proc;
     14877        BasicBlock* root = proc.addBlock();
     14878        root->appendNew<Value>(
     14879            proc, Return, Origin(),
     14880            root->appendNew<Value>(
     14881                proc, BitXor, Origin(),
     14882                root->appendNew<AtomicValue>(
     14883                    proc, AtomicStrongCAS, Origin(), width,
     14884                    root->appendIntConstant(proc, Origin(), type, 42),
     14885                    root->appendIntConstant(proc, Origin(), type, 0xbeef),
     14886                    root->appendNew<ArgumentRegValue>(proc, Origin(), GPRInfo::argumentGPR0)),
     14887                root->appendIntConstant(proc, Origin(), type, 1)));
     14888       
     14889        typename NativeTraits<T>::CanonicalType one = 1;
     14890       
     14891        auto code = compileProc(proc);
     14892        T value[2];
     14893        value[0] = 42;
     14894        value[1] = 13;
     14895        CHECK_EQ(invoke<typename NativeTraits<T>::CanonicalType>(*code, value), 42 ^ one);
     14896        CHECK_EQ(value[0], static_cast<T>(0xbeef));
     14897        CHECK_EQ(value[1], 13);
     14898        value[0] = static_cast<T>(300);
     14899        CHECK_EQ(invoke<typename NativeTraits<T>::CanonicalType>(*code, value), static_cast<typename NativeTraits<T>::CanonicalType>(static_cast<T>(300)) ^ one);
     14900        CHECK_EQ(value[0], static_cast<T>(300));
     14901        CHECK_EQ(value[1], 13);
     14902        value[0] = static_cast<T>(-1);
     14903        CHECK_EQ(invoke<typename NativeTraits<T>::CanonicalType>(*code, value), static_cast<typename NativeTraits<T>::CanonicalType>(static_cast<T>(-1)) ^ one);
    1486814904        CHECK_EQ(value[0], static_cast<T>(-1));
    1486914905        CHECK_EQ(value[1], 13);
Note: See TracChangeset for help on using the changeset viewer.