[PATCH, x86_64]: Fix PR target/31167

Uros Bizjak ubizjak@gmail.com
Wed Mar 14 19:47:00 GMT 2007


The problem, exposed by the testcase in the bugreport, is with TImode 
addti3_1 pattern and its splitter. Same problems can be expected with 
subti3_1, negti2_1 and their splitters.

The core of the problem is in splitter, where we split TImode immediate 
into two DImode immediates. Unfortunatelly, 64bit instructions can 
accept only 32bit immediates.

The solution is straightforward. As TImode immediates can't be split 
into two legal DImode values, we reject all but 32bit type "e" immediate 
values for affected TImode patterns.

The testcase:

--cut here--
typedef int int32_t;

int32_t round32hi (const __int128_t arg)
  const int SHIFT = 96;
  const int mshift = 96;
  const __int128_t M = (~(__int128_t) 0) << mshift;
  const __int128_t L = (~M) + 1;
  const __int128_t L1 = ((__int128_t) L) >> 1;
  const __int128_t Mlo = ((__int128_t) (~M)) >> 1;
  __int128_t vv = arg & M;

  if ((arg & (L1)) && ((arg & Mlo) || (arg & L)))
    vv += L;

  return (int32_t) (vv >> SHIFT);
--cut here--

then compiles into:

        movabsq $-4294967296, %rax
        movq    %rsi, %r9
        xorl    %r8d, %r8d
        andq    %rax, %r9
        testl   $2147483648, %esi
        je      .L2
        movq    %rsi, %rax
        andl    $2147483647, %eax
        orq     %rdi, %rax
        je      .L8
        xorl    %eax, %eax
        movabsq $4294967296, %rdx
        addq    %rax, %r8
        adcq    %rdx, %r9
        movq    %r9, %r8
        sarq    $32, %r8
        movl    %r8d, %eax
        .p2align 4,,7
        movabsq $4294967296, %rax
        testq   %rax, %rsi
        jne     .L4
        jmp     .L2

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

        PR target/31167
        * config/i386/i386.md (*addti3_1, *addti3_1 splitter): Use
        x86_64_general_operand as operand[2] predicate.  Remove "iF"
        from operand constraints and use "e" constraint instead.
        (*subti3_1, *subti3_1 splitter): Ditto.
        (*negti2_1, *negti2_1 splitter): Use x86_64_general_operand as
        operand[1] predicate.


        PR target/31167
        * gcc.target/i386/pr31167.c: New test.

Patch is bootstrapped on x86_64-pc-linux-gnu, regression tested for all 
default languages. As this patch is pure x86_64 stuff, it needs a x86_64 
maintainer approval.

-------------- next part --------------
A non-text attachment was scrubbed...
Name: i386-timode.diff
Type: text/x-patch
Size: 3173 bytes
Desc: not available
URL: <http://gcc.gnu.org/pipermail/gcc-patches/attachments/20070314/a1f733d3/attachment.bin>

More information about the Gcc-patches mailing list