Problem with Shift Left Can anyone help?

The following code usually matches the emulator, but not always. The emulator is always correct:

int x = somevalue;// pos or neg
y = x << 6;

Under what conditions does gpu SAL not match cpu SAL? It’s very rare, but they do not always match and it’s killing me. Is is an overflow thing?

Thanks to all.

With a lot of experience in hashing, random number generation, and encryption, I use bitlevel ops intensely constantly. I’ve never seen any variation from the CPU.

A common programmer error with RIGHT shifts is to forget that the behavior differs with signed and unsigned integers and that can be a coding gotcha if you miss it. But left shifts are left shifts.

Post a small test program that fails and we can try it out.

I also suspect the sign thing…

Also, if the shift value is more than 31 or less than 0 you might run into undefined, implementation specific behaviour

I had a quick look at the ptx documentation (PTX ISA Version 1.4 p.77) and found the following:

“Shift amounts greater than the register width N are clamped to N.”