Skip to content

[X86] Failure to merge ISD::SUB(x,y) and X86ISD::SUB(x,y) #39829

@RKSimon

Description

@RKSimon
Bugzilla Link 40483
Resolution FIXED
Resolved on Jul 25, 2019 07:25
Version trunk
OS Windows NT
Blocks #41819
CC @topperc,@zmodem,@RKSimon,@rotateright
Fixed by commit(s) r353044,r354771

Extended Description

We sometimes fail to recognise that ISD::SUB(x,y) and X86ISD::SUB(x,y) can be represented by the X86ISD::SUB(x,y).

https://godbolt.org/z/-RFU9J

#include <x86intrin.h>

using u64 = unsigned long long;

u64 test_sub1(u64 *p, u64 x) {
u64 r = *p - x;
_subborrow_u64(0, *p, x, p);
return *p - r; // zero
}

u64 test_sub2(u64 *p, u64 x) {
u64 r = *p - x;
_subborrow_u64(0, *p, x, p);
return r - *p; // zero
}

_Z9test_sub1Pyy:
movq (%rdi), %rcx
movq %rcx, %rax
subq %rsi, %rax
movq %rax, (%rdi)
subq %rcx, %rsi
addq %rsi, %rax
retq
_Z9test_sub2Pyy:
subq %rsi, (%rdi)
xorl %eax, %eax
retq

Metadata

Metadata

Assignees

No one assigned

    Labels

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions