Eric Botcazou <ebotca...@adacore.com> writes: >> In http://gcc.gnu.org/ml/gcc-patches/2012-11/msg00257.html I said: >> >> get_best_mode has various checks to decide what counts as an acceptable >> bitfield mode. It actually has two copies of them, with slightly >> different alignment checks: >> >> MIN (unit, BIGGEST_ALIGNMENT) > align >> >> vs. >> >> unit <= MIN (align, BIGGEST_ALIGNMENT) >> >> The second looks more correct, since we can't necessarily guarantee >> larger alignments than BIGGEST_ALIGNMENT in all cases. >> >> PR 55438 shows why I was wrong. BIGGEST_ALIGNMENT is not (as I thought) >> the biggest supported alignment, but the: >> >> Biggest alignment that any data type can require on this machine, in >> bits. Note that this is not the biggest alignment that is supported, >> just the biggest alignment that, when violated, may cause a fault. >> >> So it's perfectly possible for BIGGEST_ALIGNMENT to be 8 on 32-bit machines. > > That means that the Sequent check was flawed, doesn't it? It also seems that > the entire business of alignment with size comparisons is dubious.
Yeah, I suppose the Sequent test didn't really have any effect on BIGGEST_ALIGNMENT == BITS_PER_UNIT targets. >> Also, in cases like these, the supposedly conservative: >> >> && GET_MODE_BITSIZE (mode) <= align >> >> doesn't preserve the cap in the original: >> >> MIN (unit, BIGGEST_ALIGNMENT) > align >> >> Fixed by using GET_MODE_ALIGNMENT instead. > > Note that the comment just above needs to be adjusted then. OK, how about: /* ??? For historical reasons, reject modes that would normally receive greater alignment, even if unaligned accesses are acceptable. This has both advantages and disadvantages. > What about the similar check in next_mode? > > /* Stop if the mode requires too much alignment. */ > if (unit > align_ && SLOW_UNALIGNED_ACCESS (mode_, align_)) > break; > > It seems to me that we should change it as well. I think here we really do want unit (i.e. the GET_MODE_BITSIZE). We're dividing the bitfield into unit-sized chunks and want to know whether those chunks are aligned or not. If they aren't aligned, we need to know whether unaligned accesses are OK. Richard