Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

[tree-ssa-phiopt] Redundant sign extension with conditional __builtin_clzl #26

Open
xiangzhai opened this issue Feb 3, 2018 · 0 comments
Labels
Milestone

Comments

@xiangzhai
Copy link

Hi fellows,

As PR71016 mentioned:
Testcase:

long int foo (long i)
{
  return (i == 0) ? 17 : __builtin_clzl (i);
}

But not effect Mips Target GCC 5.5

.file   1 "gcc-pr71016.c"
        .section .mdebug.abi64
        .previous
        .nan    legacy
        .module fp=64
        .module oddspreg
        .abicalls
        .text
        .align  2
        .align  3
        .globl  foo
        .set    nomips16
        .set    nomicromips
        .ent    foo
        .type   foo, @function
foo:
        .frame  $sp,0,$31               # vars= 0, regs= 0/0, args= 0, gp= 0
        .mask   0x00000000,0
        .fmask  0x00000000,0
        .set    noreorder
        .set    nomacro
        bne     $4,$0,.L6
        nop

        j       $31
        li      $2,17                   # 0x11

        .align  3
.L6:
        j       $31
        dclz    $2,$4

        .set    macro
        .set    reorder
        .end    foo
        .size   foo, .-foo
        .ident  "GCC: (GNU) 5.5.0 20171010 (LLVM China GCC 5.5-2018.01)"

6-branch, 7-branch, 8.x-trunk:

.file   1 "gcc-pr71016.c"
        .section .mdebug.abi64
        .previous
        .nan    legacy
        .module fp=64
        .module oddspreg
        .abicalls
        .text
        .align  2
        .align  3
        .globl  foo
        .set    nomips16
        .set    nomicromips
        .ent    foo
        .type   foo, @function
foo:
        .frame  $sp,0,$31               # vars= 0, regs= 0/0, args= 0, gp= 0
        .mask   0x00000000,0
        .fmask  0x00000000,0
        .set    noreorder
        .set    nomacro
        bne     $4,$0,.L6
        nop

        jr      $31
        li      $2,17                   # 0x11

        .align  3
.L6:
        jr      $31
        dclz    $2,$4

        .set    macro
        .set    reorder
        .end    foo
        .size   foo, .-foo
        .ident  "GCC: (GNU) 6.4.1 20180202 (LLVM China GCC 6-branch)"

or LLVM 7.x:

.text
        .abicalls
        .section        .mdebug.abi64,"",@progbits
        .nan    legacy
        .file   "gcc-pr71016.c"
        .text
        .globl  foo
        .p2align        3
        .type   foo,@function
        .set    nomicromips
        .set    nomips16
        .ent    foo
foo:
        .frame  $sp,0,$ra
        .mask   0x00000000,0
        .fmask  0x00000000,0
        .set    noreorder
        .set    nomacro
        .set    noat
        dclz    $2, $4
        daddiu  $1, $zero, 17
        jr      $ra
        movz    $2, $1, $4
        .set    at
        .set    macro
        .set    reorder
        .end    foo
.Lfunc_end0:
        .size   foo, .Lfunc_end0-foo


        .ident  "LLVM China clang version 7.0.0 (trunk 322941) (llvm/trunk 322942) (based on LLVM 7.0.0svn)"
        .section        ".note.GNU-stack","",@progbits
        .text

Jakub fixed the issue for GCC 8.x, and tested for AArch64 and X86 Targets I argue that it might be a potential issue not reproducible by such testcase?

Regards,
Leslie Zhai

@xiangzhai xiangzhai added this to the gcc-5-branch milestone Feb 3, 2018
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Projects
None yet
Development

No branches or pull requests

1 participant