This is the mail archive of the gcc@gcc.gnu.org mailing list for the GCC project.


Index Nav: [Date Index] [Subject Index] [Author Index] [Thread Index]
Message Nav: [Date Prev] [Date Next] [Thread Prev] [Thread Next]
Other format: [Raw text]

Re: Do C++ signed types have modulo semantics?


Joe Buck wrote:

I don't think we should give the user any such promise, and if we do
give such a promise, we will never catch icc.  The main problem is that
we will no longer be able to optimize many loops.

It's entirely possible that I was naive in assuming that this wouldn't have a big optimization impact. Reiterating my response to Daniel, if it is in fact the case that this is a major loss for optimization, then I would have to retract my claim.


Here's a simple example.

int blah(int);

int func(int a, int b) {
    if (b >= 0) {
	int c = a + b;
	int count = 0;
	for (int i = a; i <= c; i++)
	    count++;
	blah(count);
    }
}

Yes, I understand.


I just didn't imagine that these kinds of opportunities came up very often. (Perhaps that's because I routinely write code that can't be compiled well, and so don't think about this situation. In particular, I often use unsigned types when the underlying quantity really is always non-negative, and I'm saddened to learn that doing that would result in inferior code.)

--
Mark Mitchell
CodeSourcery, LLC
mark@codesourcery.com
(916) 791-8304


Index Nav: [Date Index] [Subject Index] [Author Index] [Thread Index]
Message Nav: [Date Prev] [Date Next] [Thread Prev] [Thread Next]