On 08/30/2016 10:23 PM, Peter Bergner wrote:
PR77289 exposes a latent problem with LRA constraint matching.  In the buggy
test cases, LRA performs a speculative register elimination before checking
operands for matching constraints.  With the elimination, the operands
appear to match.  However, when we call check_rtl() which attempts to
recognize the instruction, the reg above it not eliminated leading to a
"insn does not satisfy its constraints" ICE.

This patch fixes the problem by not performing register elimination during
constraint matching.  operands_match_p() uses get_hard_reg() to grab a
REG's hard reg number, so I have removed get_hard_reg()'s call to
get_final_hard_regno() which performs the register elimination, which
fixes the bug.  uses_hard_regs_p() is the other caller of get_hard_regno()
and it still needs register elimination to be called, so I have changed
it to call get_final_hard_regno() instead.  Since uses_hard_regs_p()
may call get_final_hard_regno() with a pseudo, I have added support
for mapping those to hard reg numbers before performing the register
elimination.

This has passed bootstrap and regtesting with no regressions.
Ok for mainline?

Peter

gcc/
        PR rtl-optimization/77289
        * lra-constraints.c (get_final_hard_regno): Add support for non hard
        register numbers.  Remove support for subregs.
        (get_hard_regno): Use SUBREG_P.  Don't call get_final_hard_regno().
        (get_reg_class): Delete removed get_final_hard_regno() argument.
        (uses_hard_regs_p): Call get_final_hard_regno().

gcc/testsuite/
        PR rtl-optimization/77289
        * gcc.target/powerpc/pr77289.c: New test.
OK.

Jeff

Reply via email to