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

duplicated compare instruction #8733

Closed
llvmbot opened this issue Oct 12, 2010 · 3 comments
Closed

duplicated compare instruction #8733

llvmbot opened this issue Oct 12, 2010 · 3 comments
Labels
backend:X86 bugzilla Issues migrated from bugzilla

Comments

@llvmbot
Copy link
Collaborator

llvmbot commented Oct 12, 2010

Bugzilla Link 8361
Resolution FIXED
Resolved on May 05, 2011 12:04
Version trunk
OS Linux
Blocks #8497
Reporter LLVM Bugzilla Contributor
CC @atrick,@lattner,@efriedma-quic,@ggreif

Extended Description

Keywords: duplicate duplicated redundant repeated compare comparison cmp

The compare instruction is repeated unnecessarily in the code generated from this:

const char *f(int x, int y)
{
return x < y ? "<" : x == y ? "=" : ">";
}

I've seen this with the ARM and x86 back ends.

Currently on r116298.

@lattner
Copy link
Collaborator

lattner commented Oct 12, 2010

Yep, this is because MachineCSE isn't doing everything it needs to

@ggreif
Copy link
Contributor

ggreif commented Oct 12, 2010

This problem shows up on all targets I look at:

PPC32:
f: # @​f

BB#0: # %entry

    cmpw 0, 3, 4
    blt 0, .LBB0_4

BB#1: # %cond.false

    cmplw 0, 3, 4
    bne 0, .LBB0_3

Thumb:
f:
@ BB#0: @ %entry
cmp r0, r1
blt .LBB0_4
@ BB#1: @ %cond.false
cmp r0, r1
bne .LBB0_3

ARM:
f: @ @​f
@ BB#0: @ %entry
cmp r0, r1
ldrlt r0, .LCPI0_2
bxlt lr
ldr r3, .LCPI0_1
cmp r0, r1
mov r0, r3

x86:
f: # @​f

BB#0: # %entry

    movl    8(%esp), %eax
    movl    4(%esp), %ecx
    cmpl    %eax, %ecx
    jl      .LBB0_2

BB#1: # %cond.false

    cmpl    %eax, %ecx
    movl    $.L.str1, %ecx

Starting investigation, maybe I can come up with something acceptable.

@efriedma-quic
Copy link
Collaborator

r130928.

@llvmbot llvmbot transferred this issue from llvm/llvm-bugzilla-archive Dec 3, 2021
This issue was closed.
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
backend:X86 bugzilla Issues migrated from bugzilla
Projects
None yet
Development

No branches or pull requests

4 participants