-
Bug
-
Resolution: Unresolved
-
Not Prioritized
-
Code Generation Tools
-
CODEGEN-13376
-
C6000_8.3.13
-
default
The attached C++ source file has these lines ...
enum class A : unsigned short { A1 = 0xFFFFu };
The test case includes a switch statement that compares a variable of the enum type for equality with the value A1. Build it ...
% cl6x --src_interlist file.cpp
Inspect file.asm to see these lines ...
LDHU .D2T2 *SP(4),B4 ; [B_D64P] |8| NOP 4 ; [A_L64P] CMPEQ .L2 B4,-1,B0 ; [B_L64P] |8| [ B0] BNOP $C$L1,5 ; [] |8|
The LDHU causes the upper 16-bits of B4 to be 0. Then it is compared against -1. This is wrong. Either the value in B4 should be sign extended, or the comparison should be against 0xffff.
When built with any level of optimization, these problems do not occur.