[llvm] [X86] combineAndNotOrIntoAndNotAnd - don't fold other constant operands (PR #113264)
via llvm-commits
llvm-commits at lists.llvm.org
Mon Oct 21 21:59:31 PDT 2024
llvmbot wrote:
<!--LLVM PR SUMMARY COMMENT-->
@llvm/pr-subscribers-backend-x86
Author: Miguel Saldivar (Saldivarcher)
<details>
<summary>Changes</summary>
---
Full diff: https://github.com/llvm/llvm-project/pull/113264.diff
2 Files Affected:
- (modified) llvm/lib/Target/X86/X86ISelLowering.cpp (+2-2)
- (modified) llvm/test/CodeGen/X86/pr108731.ll (+20)
``````````diff
diff --git a/llvm/lib/Target/X86/X86ISelLowering.cpp b/llvm/lib/Target/X86/X86ISelLowering.cpp
index bcb84add65d83e..5ae5a7dbe0f6da 100644
--- a/llvm/lib/Target/X86/X86ISelLowering.cpp
+++ b/llvm/lib/Target/X86/X86ISelLowering.cpp
@@ -50049,8 +50049,8 @@ static SDValue combineAndNotOrIntoAndNotAnd(SDNode *N, SelectionDAG &DAG) {
SDValue X, Y, Z;
if (sd_match(N, m_And(m_Value(X),
m_OneUse(m_Or(m_Value(Y), m_Not(m_Value(Z))))))) {
- // Don't fold if Y is a constant to prevent infinite loops.
- if (!isa<ConstantSDNode>(Y))
+ // Don't fold if Y and Z are constants to prevent infinite loops.
+ if (!isa<ConstantSDNode>(Y) && !isa<ConstantSDNode>(Z))
return DAG.getNode(
ISD::AND, DL, VT, X,
DAG.getNOT(
diff --git a/llvm/test/CodeGen/X86/pr108731.ll b/llvm/test/CodeGen/X86/pr108731.ll
index 473b4f7f4da2e3..2983d108eaeddc 100644
--- a/llvm/test/CodeGen/X86/pr108731.ll
+++ b/llvm/test/CodeGen/X86/pr108731.ll
@@ -192,3 +192,23 @@ define void @PR112347(ptr %p0, ptr %p1, ptr %p2) {
ret void
}
+define void @PR113240(i64 %a) {
+; CHECK-LABEL: PR113240:
+; CHECK: # %bb.0: # %entry
+; CHECK-NEXT: movq %rdi, %rax
+; CHECK-NEXT: notq %rax
+; CHECK-NEXT: movabsq $8796093022206, %rcx # imm = 0x7FFFFFFFFFE
+; CHECK-NEXT: notq %rcx
+; CHECK-NEXT: orq %rax, %rcx
+; CHECK-NEXT: andq %rdi, %rcx
+; CHECK-NEXT: movq %rcx, 0
+; CHECK-NEXT: retq
+entry:
+ %and = and i64 %a, 8796093022206
+ %bf.value = and i64 8796093022206, 0
+ %not = xor i64 %and, -1
+ %and4 = and i64 %a, %not
+ store i64 %and4, ptr null, align 8
+ ret void
+}
+
``````````
</details>
https://github.com/llvm/llvm-project/pull/113264
More information about the llvm-commits
mailing list