[cfe-dev] Behavior of -mcpu

Stefan Teleman via cfe-dev cfe-dev at lists.llvm.org
Thu Feb 28 11:40:05 PST 2019


On Thu, Feb 28, 2019 at 2:09 PM David Greene via cfe-dev
<cfe-dev at lists.llvm.org> wrote:
>
> Interesting.  I am observing different behavior between -mcpu= and
> -march= -mtune= with aarch64-unknown-linux-gnu:
>
> $ clang -Ofast -S -target aarch64-unknown-linux-gnu -mcpu=thunderx2t99 -mllvm -debug-only=loop-data-prefetch ./prefetch.c
> Prefetching 3 iterations ahead (loop size: 35) in partial: Loop at depth 1 containing: %for.body<header>
> <latch><exiting>
>
> $ clang -Ofast -S -target aarch64-unknown-linux-gnu -march=armv8 -mtune=thunderx2t99 -mllvm -debug-only=loop-data-prefetch ./prefetch.c
> [nothing]
>
> I expected to see the same behavior.  Is this a bug?  Just to be sure I
> tried armv8.1a, armv8.2a and armv8.3a and still got nothing.

We never supported -mtune=thunderx2t99.

-mcpu=thunderx2t99
-march=armv8.1-a+lse

Although the -march flag here is somewhat redundant --
-mcpu=thunderx2t99 implies -march=armv8.1-a+lse:

%> cat t.c
#include <stdint.h>

int32_t compare_and_swap(volatile int32_t* ptr, int32_t oldval, int32_t newval)
{
  int32_t ret = *ptr;
  (void) __sync_bool_compare_and_swap(ptr, oldval, newval);
  return ret;
}

%> clang -O3 -std=c99 -mcpu=thunderx2t99 -S t.c -o t.S
%> egrep -e 'casal' -n t.S
9:      casal   w1, w2, [x0]
%>

I.e. you still get the LSE Atomics even without the -march=armv8.1-a+lse.

--Stefan

-- 
Stefan Teleman
stefan.teleman at gmail.com



More information about the cfe-dev mailing list