no_extend = 1;
xop0 = widen_operand (xop0, wider_mode, unsignedp, no_extend);
- xop1 = widen_operand (xop1, wider_mode, unsignedp, no_extend);
+
+ /* The second operand of a shift must always be extended. */
+ xop1 = widen_operand (xop1, wider_mode, unsignedp,
+ no_extend && binoptab != ashl_optab
+ && binoptab != lshl_optab);
+
temp = expand_binop (wider_mode, binoptab, xop0, xop1, NULL_RTX,
unsignedp, OPTAB_DIRECT);
if (temp)
no_extend = 1;
xop0 = widen_operand (xop0, wider_mode, unsignedp, no_extend);
- xop1 = widen_operand (xop1, wider_mode, unsignedp, no_extend);
+
+ /* The second operand of a shift must always be extended. */
+ xop1 = widen_operand (xop1, wider_mode, unsignedp,
+ no_extend && binoptab != ashl_optab
+ && binoptab != lshl_optab);
temp = expand_binop (wider_mode, binoptab, xop0, xop1, NULL_RTX,
unsignedp, methods);