[PATCH, rtl-optimization]: Really fix PR 26449, [4.2/4.3 Regression] ICE in loop invariant motion

Uros Bizjak ubizjak@gmail.com
Fri Sep 14 12:08:00 GMT 2007


Recent PR deals with familiar bug in loop invariant motion (PR26449),
where force_operand wasn't able to expand RTX without optab. The bug
was 'fixed' some time ago, but the fix was wrong. The fix only checked
for NULL_RTX from force_operand. However, force_operand never returns
NULL_RTX, but ICEs at expand_simple_binop for unsupported RTX.

The problem arises with vector insns, where they combine VEC_SELECT,
VEC_CONCAT and VEC_DUPLICATE - all RTX  without corresponding optabs.
Also, please note that these insn are all marked as RTX_BIN_ARITH and
RTX_UNARY, so they enter expansion inside force_operand.

Proposed patch skips processing for RTX without optabs. The ICE is
inevitable here, so instead of ICEing, we return untouched RTX. This
is enough to fix this sort of ICE, and similar to the case where
non-RTX_BIN_ARITH and non-RTX_UNARY expressions enter force_operand.

The ICE can be triggered on x86_64:

> gcc.c-torture/execute/loop-15.c fails with -O1 -ftree-vectorize:

> loop-15.c: In function 'main':
> loop-15.c:40: internal compiler error: in expand_simple_binop, at optabs.c:1306

Attached patch reverts wrong fix and introduces above solution that
fixes above problem for x86_64. Patch was bootstrapped and regression
tested on i686-pc-linux-gnu.

OK for mainline?

2007-09-14  Uros Bizjak  <ubizjak@gmail.com>

        PR rtl-optimization/26449
        * expr.c (force_operand): Check that we have optab for code
        before calling expand_simple_binop.  Use IN_RANGE to check OP2.

        2006-06-07  Zdenek Dvorak <dvorakz@suse.cz>
        PR rtl-optimization/26449
        * loop-invariant.c (move_invariant_reg): Fail if force_operand fails.

-------------- next part --------------
An embedded and charset-unspecified text was scrubbed...
Name: pr26449.diff.txt
URL: <http://gcc.gnu.org/pipermail/gcc-patches/attachments/20070914/b8195a09/attachment.txt>

More information about the Gcc-patches mailing list