load widening no more?


Here is a simple test on which (I swear!) clang used to perform load widening.
Not any more. What’s happened?

% cat lw.cc
struct S {
int a;
unsigned char x, y, z, w;

int foo(S *s) {
if (s->x == 0 && s->y == 0) return 0;
return 1;

% clang -O2 -S -o - lw.cc | grep ‘(%’
cmpb $0, 4(%rdi)
cmpb $0, 5(%rdi)
% gcc -O2 -S -o - lw.cc | grep ‘(%’
cmpw $0, 4(%rdi)


clang isn't setting the alignment on the load of "s->x" aggressively
enough for the LLVM optimizers to kick in.

Granted, even if you do fix that, we still generate completely
ridiculous code, but that's a separate issue.