function l $main() {
@start.0
@body.1
%.4 =l shl 1, 72
ret %.4
@.2
ret
}
Produces:
.globl main
main:
pushq %rbp
movq %rsp, %rbp
movl $256, %eax
leave
ret
.type main, @function
.size main, .-main
Expected 0 here.
It's documented behavior. "The shifting amount is taken modulo the size of the result type". 72 mod 64 == 8 and 2^8 == 256, so the code behaves according to spec. The constant folder even goes through a bit of sweat to guarantee that: https://c9x.me/git/qbe.git/tree/fold.c#n392
The rationale for this choice is that it's the natural behavior of all qbe targets. So shl in qbe is a simple machine shift left.
Ah, alright.