diff mbox

Fix ubsan expansion of multiplication (PR rtl-optimization/60030)

Message ID 20140206163847.GZ12671@tucnak.redhat.com
State New
Headers show

Commit Message

Jakub Jelinek Feb. 6, 2014, 4:38 p.m. UTC
On Thu, Feb 06, 2014 at 08:27:09AM -0800, Richard Henderson wrote:
> > All I know is that the generated code with the ZERO_EXTEND has been larger
> > than with the paradoxical subreg.  But if you prefer, I can surely emit a
> > ZERO_EXTEND and open a PR for GCC 5.0 that we should investigate why we
> > generate worse code then.
> 
> Yes please.

Ok, I'll retest this before committing then:

2014-02-06  Jakub Jelinek  <jakub@redhat.com>

	PR rtl-optimization/60030
	* internal-fn.c (ubsan_expand_si_overflow_mul_check): Surround
	lopart with paradoxical subreg before shifting it up by hprec.



	Jakub
diff mbox

Patch

--- gcc/internal-fn.c.jj	2014-01-29 12:43:24.000000000 +0100
+++ gcc/internal-fn.c	2014-02-03 10:40:57.000000000 +0100
@@ -646,7 +646,8 @@  ubsan_expand_si_overflow_mul_check (gimp
 	    emit_cmp_and_jump_insns (hipart, const0_rtx, GE, NULL_RTX, hmode,
 				     false, after_hipart_neg, PROB_EVEN);
 
-	  tem = expand_shift (LSHIFT_EXPR, mode, lopart, hprec, NULL_RTX, 1);
+	  tem = convert_modes (mode, hmode, lopart, 1);
+	  tem = expand_shift (LSHIFT_EXPR, mode, tem, hprec, NULL_RTX, 1);
 	  tem = expand_simple_binop (mode, MINUS, loxhi, tem, NULL_RTX,
 				     1, OPTAB_DIRECT);
 	  emit_move_insn (loxhi, tem);