patch: emit tail calls with zeroext/signext on return

Tim Northover t.p.northover at gmail.com
Wed Jul 31 03:43:34 PDT 2013


> Is this still more conservative than required? Since zeroext and signext
> mean "extended by callee" for a return value (and non-{zero,sign}ext appears
> to mean "high bits are junk"), it seems like we should also be able to emit
> a tail call when a non-{zero,sign}ext function calls a {zero,sign}ext
> function, as in your test_extend3 case.

Actually, I now think this does have implications for sameNoopInput
(or whatever it gets replaced with). The problem is that after this
decision we look through truncate operations.

I've found distressingly little documentation about who does what
extension on x86-64, but I *think* the following shouldn't be a tail
call:

unsigned short foo(void);
unsigned char bar() {
  return foo();
}

We currently ensure that all unused bits out to 32-bit size are
extended appropriately, which means we insert a movzbl or movsbl
between the returns. With this patch that would no longer happen.

It's probably safe to *instead* drop a zero/signext as Richard
suggest. Or we could enhance the following call to take more care.

Cheers.

Tim



More information about the llvm-commits mailing list