Quantcast
Channel: Intel® Software - Intel® C++ Compiler
Viewing all articles
Browse latest Browse all 1175

icc-16.0.3 not respecting no-ansi-alias flag?

$
0
0

Compiling a.c with icc -O2 results in reordering of memory accesses, even when -no-ansi-alias flag is used.

We are using icc version 16.0.3

$ cat a.c

#include "stdlib.h"

char *foo(size_t size);

struct list { int hd; struct list * tl; };

struct list * reverselist (struct list * l) {

    struct list * r, * r2;

    for (r = NULL; l != NULL; l = l->tl) {

        r2 = (struct list *)foo(sizeof(struct list));

        r2->hd = l->hd;

        r2->tl = r;

        r = r2;

    }

    return r;

}

$ icc -O2 -m32 -S -falias -no-ansi-alias -fargument-alias a.c

# Showing the compiled assembly for the loop body generated in a.s

..B1.3: # Preds ..B1.2 ..B1.4

addl $4, %esp #9.25

pushl $8 #9.25

# foo(size_t) call foo #9.25

..B1.4: # Preds ..B1.3

movl %edi, 4(%eax) #11.5

movl %eax, %edi #12.5

movl (%esi), %ecx #10.14

movl 4(%esi), %esi #8.33

testl %esi, %esi #8.23

movl %ecx, (%eax) #10.5

jne ..B1.3 # Prob 82% #8.23

The write to r2->hd (instruction 10.5) has been reordered after the read from l->tl (instruction 8.33). Based on the documentation of no-ansi-alias, this should not be possible, as r2->hd could potentially alias with l->tl in the loop body. Are we missing something?

Thanks in advance, for your help.


Viewing all articles
Browse latest Browse all 1175

Trending Articles



<script src="https://jsc.adskeeper.com/r/s/rssing.com.1596347.js" async> </script>