SHIFT Is Unchangeable
From: Bryan Parkoff (bryan.nospam.parkoff_at_nospam.com)
Date: 01/17/04
- Next message: A.Cloos: "Re: Beginner: HLA, ASM, MASM32?"
- Previous message: Matt Taylor: "Re: Non Intel & AMD Arch"
- Next in thread: Terje Mathisen: "Re: SHIFT Is Unchangeable"
- Reply: Terje Mathisen: "Re: SHIFT Is Unchangeable"
- Reply: Jack Klein: "Re: SHIFT Is Unchangeable"
- Messages sorted by: [ date ] [ thread ] [ subject ] [ author ]
Date: Sat, 17 Jan 2004 04:40:12 +0000 (UTC)
I learn that Intel is not willing to fix SHIFT problem on Pentium 4
since 486DX through Pentium 3 are doing fine. Do you complain that SHIFT
wants to steal 4-6 cycles on Pentium 4? Intel must have reasons to leave
SHIFT unchangeable because they think best to do with their budget. It is
really nonsense.
Do you wish to wait until year 2007 before Pentium 4 will become
available at 20GHz? Would you be satisifed that SHIFT's 4-6 cycles remain
unchangeable on 20GHz? If Intel changes their mind and fix SHIFT that
should cost only one cycle instead of 4-6 cycles on 20GHz. It would be over
100-1000 times faster like RISC's SHIFT.
I want to show you C++ example by using SHIFT and pointer. If SHIFT is
used before C++ is compiled into machine language. It will run faster on
Pentium 3, but it will run slower on Pentium 4. It is very annoying that I
have to modify C++ code in order to run faster on Pentium 4 than Pentium 3.
It does not do good. I try to tell C/C++ programmers to avoid SHIFT and use
pointer instead.
I create one 32 Bits variable and four pointer variables. Four pointer
variables link or point to one 32 Bits variable. Each pointer variable is 8
Bits. In fact is that only ONE variable is created. Pointer is not REALLY
variable. Look at my example below.
unsigned int AA = 0;
unsigned char* const AA_Byte1 = (unsigned char*)&AA;
unsigned char* const AA_Byte2 = (unsigned char*)&AA + 1;
unsigned char* const AA_Byte3 = (unsigned char*)&AA + 2;
unsigned char* const AA_Byte4 = (unsigned char*)&AA + 3;
AA = 0x41424344;
printf("First Byte: %Xh", *AA_Byte1);
printf("Second Byte: %Xh", *AA_Byte2);
printf("Third Byte: %Xh", *AA_Byte3);
printf("Fourth Byte: %Xh", *AA_Byte4);
printf("Native DWord: %Xh", AA);
My style above works fine for my own coding. I don't need to use SHIFT,
AND, OR, or other keywords because it may slow on Pentium 4. For example
below.
unsigned char A = 0x01;
unsigned char B = 0x20;
unsigned int C = (B << 8 | A) & 0xffff;
Compare C++ code and assembly language. Look at my example below.
mov eax, dword ptr [AA]
mov eax, 041424344h
mov dword ptr [AA], eax
or
mov dword ptr [AA], 041424344h
Get each BYTE value.
mov al, byte ptr [AA]
mov cl, byte ptr [AA+1]
mov dl, byte ptr [AA+2]
mov bl, byte ptr [AA+3]
Do you notice that assembly language looks very neat because it does not
require to use SHL or SHR instructions? I don't believe that each BYTE may
misalign on DWORD, but it seems fine on both Pentium 3 and Pentium 4.
What is your opinion or answer? Avoid SHIFT and use POINTER on both
C/C++ code and assembly code on both Pentium 3 and Pentium 4. It would
benefit great.
If it is only the truth that Intel tries to tell everyone to avoid SHIFT
so they decide to add 4-6 cycles for SHIFT, all C/C++ and assembly
programmers MUST LISTEN what Intel SAYS. They don't have to LISTEN IF they
don't like the way Intel says.
I claim that Intel is probably correct by adding 4-6 cycles for SHIFT on
Pentium 4 because Intel encourages the programmers to AVOID using SHIFT
otherwise, the programmers complain because of speed problem.
Please tell me what you think my C++ code and assembly code that they
don't use SHIFT. Would it benefit great on both Pentium 3 and Pentium 4?
Thanks.....
-- Bryan Parkoff
- Next message: A.Cloos: "Re: Beginner: HLA, ASM, MASM32?"
- Previous message: Matt Taylor: "Re: Non Intel & AMD Arch"
- Next in thread: Terje Mathisen: "Re: SHIFT Is Unchangeable"
- Reply: Terje Mathisen: "Re: SHIFT Is Unchangeable"
- Reply: Jack Klein: "Re: SHIFT Is Unchangeable"
- Messages sorted by: [ date ] [ thread ] [ subject ] [ author ]
Relevant Pages
|