aboutsummaryrefslogtreecommitdiff
path: root/llvm/lib/CodeGen/CodeGenPrepare.cpp
diff options
context:
space:
mode:
authorAZero13 <gfunni234@gmail.com>2025-09-25 09:55:01 -0400
committerGitHub <noreply@github.com>2025-09-25 22:55:01 +0900
commit09bdbfd9d1a7b10b3b91c86672ca2994dc997c82 (patch)
tree5518375d924c3408a4f0bda2d9179f6265c65089 /llvm/lib/CodeGen/CodeGenPrepare.cpp
parent373a2f1f222608d1f274c42281f4ffeed47a17a1 (diff)
downloadllvm-09bdbfd9d1a7b10b3b91c86672ca2994dc997c82.zip
llvm-09bdbfd9d1a7b10b3b91c86672ca2994dc997c82.tar.gz
llvm-09bdbfd9d1a7b10b3b91c86672ca2994dc997c82.tar.bz2
[CodeGenPrepare] Bail out of usubo creation if sub's parent is not the same as the comparison (#160358)
We match uadd's behavior here. Codegen comparison: https://godbolt.org/z/x8j4EhGno
Diffstat (limited to 'llvm/lib/CodeGen/CodeGenPrepare.cpp')
-rw-r--r--llvm/lib/CodeGen/CodeGenPrepare.cpp6
1 files changed, 6 insertions, 0 deletions
diff --git a/llvm/lib/CodeGen/CodeGenPrepare.cpp b/llvm/lib/CodeGen/CodeGenPrepare.cpp
index d290f20..eb73d01b 100644
--- a/llvm/lib/CodeGen/CodeGenPrepare.cpp
+++ b/llvm/lib/CodeGen/CodeGenPrepare.cpp
@@ -1749,6 +1749,12 @@ bool CodeGenPrepare::combineToUSubWithOverflow(CmpInst *Cmp,
Sub->hasNUsesOrMore(1)))
return false;
+ // We don't want to move around uses of condition values this late, so we
+ // check if it is legal to create the call to the intrinsic in the basic
+ // block containing the icmp.
+ if (Sub->getParent() != Cmp->getParent() && !Sub->hasOneUse())
+ return false;
+
if (!replaceMathCmpWithIntrinsic(Sub, Sub->getOperand(0), Sub->getOperand(1),
Cmp, Intrinsic::usub_with_overflow))
return false;