[libav-bugs] [Bug 593] New: Assembly code chooses THUMB instructions over ARM

bugzilla at libav.org bugzilla at libav.org
Wed Nov 20 17:34:04 CET 2013


           Summary: Assembly code chooses THUMB instructions over ARM
           Product: Libav
           Version: 9
          Platform: ARM
        OS/Version: All
            Status: NEW
          Severity: normal
          Priority: Normal
         Component: libavcodec
        AssignedTo: bugzilla at libav.org
        ReportedBy: sclark at vgocom.com

I would like to admit first that I am not an expert in these details of
the ARM architecture.

According to the Wikipedia article on ARM
the THUMB instruction set is preferable to the normal ARM instruction set
when the processor has a limited-width data path to memory (16 bits or less).
I don't think this is typical of ARM processor configurations.

It appears to me that the libav ./configure script sets the CONFIG_THUMB
flag if it detects that the THUMB instruction set is available.  Later,
the assembly code in libavcodec/arm/simple_idct_arm.S and libavutil/arm/asm.S
uses the THUMB instruction set if CONFIG_THUMB is set.  I suspect this is an
error: the THUMB instructions should only be used if explicitly requested.

The workaround is to add --disable-thumb to the ./configure command line.

I believe the correct behavior is to make ./configure disable THUMB by

There are two consequences to enabling THUMB inappropriately:
1.  The THUMB instructions run slower (if I understand correctly).
2.  The nearby ARM instructions are misaligned, so two memory cycles are
required to fetch them.


I discovered this issue when updating my application from iOS 6 to iOS 7.
At the same time, the development machine upgraded from OS X 10.8 to 10.9
and the cross-development tools upgraded from Xcode 4 to Xcode 5.  I had
to solve a number of build issues and update gas-preprocessor.pl.  When I
linked my application, the linker complained that various "functions" in
libavcodec/arm/simple_idct_arm.S were not 4-byte aligned.  The "functions"
were labels.  I couldn't figure out how a series of 32-bit instructions
could start aligned and later be misaligned.  Eventually I thought of the
THUMB instructions.

Thank you very much.

Configure bugmail: https://bugzilla.libav.org/userprefs.cgi?tab=email
------- You are receiving this mail because: -------
You are watching all bug changes.

More information about the libav-bugs mailing list