"if TypeInfo(TSameTypeXYZ) = TypeInfo(TSameTypeXYZ) then" alway-true-check isn't optimized out
Original Reporter info from Mantis: benjamin@0ok.de @bero1985
-
Reporter name: Benjamin Rosseaux
Original Reporter info from Mantis: benjamin@0ok.de @bero1985
- Reporter name: Benjamin Rosseaux
Description:
As said in the summary, at "if TypeInfo(TSameTypeXYZ) = TypeInfo(TSameTypeXYZ) then" the always-true-check isn't optimized out (even not with -O4). For example:
function TSupraHashMap<TSupraHashMapKey,TSupraHashMapValue>.HashKey(const Key:TSupraHashMapKey):UInt32;
...
end else if TypeInfo(TSupraHashMapKey)=TypeInfo(RawByteString) then begin
result:=HashData(PByte(@RawByteString(pointer(@Key)^)[1]),length(RawByteString(pointer(@Key)^)));
...
will be to on i386:
# [208] (TypeInfo(TSupraHashMapKey)=TypeInfo(RawByteString)) then begin
movl $RTTI_$SYSTEM_$$_RAWBYTESTRING,%edx
movl $RTTI_$SYSTEM_$$_RAWBYTESTRING,%eax
cmpl %eax,%edx
jne .Lj7369
and on x64:
# [208] (TypeInfo(TSupraHashMapKey)=TypeInfo(RawByteString)) then begin
leaq RTTI_$SYSTEM_$$_RAWBYTESTRING(%rip),%rax
leaq RTTI_$SYSTEM_$$_RAWBYTESTRING(%rip),%rdx
cmpq %rdx,%rax
jne .Lj7507
and the same thing with the "if TypeInfo(TSameTypeXYZ) = TypeInfo(TNotSameTypeXYZ) then" case, where the whole always-false-if-branch will be also not killed yet.
Mantis conversion info:
- Mantis ID: 30260
- Build: stable release
- Version: 3.0.0
- Fixed in version: 3.3.1
- Fixed in revision: 47008 (#e124b07e)
- Monitored by: » @bero1985 (Benjamin Rosseaux), » @MageSlayer (Denis Golovan)