http://gcc.gnu.org/bugzilla/show_bug.cgi?id=53124
Bug #: 53124 Summary: Arm NEON narrowing right shift instructions impose incorrect operand bounds (intrinsic and asm) Classification: Unclassified Product: gcc Version: 4.4.2 Status: UNCONFIRMED Severity: normal Priority: P3 Component: c AssignedTo: unassig...@gcc.gnu.org ReportedBy: kse...@rim.com The following code produces "Constant out of range" compiler error, even though it's supposed to allow any immediate up to (size(datatype) - 1), or 31 in this case. See http://infocenter.arm.com/help/topic/com.arm.doc.dui0489c/CIHGJIHA.html Using inline assembly implementation doesn't work either resulting in "Error: immediate out of range for narrowing operation". int16x4_t rshift8_and_saturate_uint12( int32x4_t arg ) { uint32x4_t saturated_at32 = vqshluq_n_s32( arg, 32-(8+12) ); #if 1 return vshrn_n_s32( vreinterpretq_s32_u32( saturated_at32 ), 32-12 ); #else int16x4_t result; asm volatile( "VSHRN.I32 %P0, %q1, #20" : "=w"(result) : "w"(saturated_at32)); return result; #endif } It appears similar to http://gcc.gnu.org/bugzilla/show_bug.cgi?id=41196 although in this case the ssembler code will probably need to be fixed as well. Also, by looking at /gcc/config/arm/neon.md it seems all V[Q]SHR[U]N are affected.