[PATCH] D126174: [SelectionDAG] Fold abs(undef) to 0 instead of undef.
Craig Topper via Phabricator via llvm-commits
llvm-commits at lists.llvm.org
Sun May 22 12:56:29 PDT 2022
This revision was landed with ongoing or failed builds.
This revision was automatically updated to reflect the committed changes.
Closed by commit rG768a1ca5eccb: [SelectionDAG] Fold abs(undef) to 0 instead of undef. (authored by craig.topper).
Repository:
rG LLVM Github Monorepo
CHANGES SINCE LAST ACTION
https://reviews.llvm.org/D126174/new/
https://reviews.llvm.org/D126174
Files:
llvm/lib/CodeGen/SelectionDAG/SelectionDAG.cpp
llvm/test/CodeGen/X86/pr55271.ll
Index: llvm/test/CodeGen/X86/pr55271.ll
===================================================================
--- /dev/null
+++ llvm/test/CodeGen/X86/pr55271.ll
@@ -0,0 +1,15 @@
+; NOTE: Assertions have been autogenerated by utils/update_llc_test_checks.py
+; RUN: llc < %s -mtriple=x86_64-unknown-linux-gnu | FileCheck %s
+
+; abs(undef) should fold to 0 not undef.
+
+declare i32 @llvm.abs.i32(i32, i1 immarg) #0
+
+define i32 @abs(i32 %0) {
+; CHECK-LABEL: abs:
+; CHECK: # %bb.0:
+; CHECK-NEXT: xorl %eax, %eax
+; CHECK-NEXT: retq
+ %2 = call i32 @llvm.abs.i32(i32 undef, i1 false)
+ ret i32 %2
+}
Index: llvm/lib/CodeGen/SelectionDAG/SelectionDAG.cpp
===================================================================
--- llvm/lib/CodeGen/SelectionDAG/SelectionDAG.cpp
+++ llvm/lib/CodeGen/SelectionDAG/SelectionDAG.cpp
@@ -5243,7 +5243,7 @@
assert(VT.isInteger() && VT == Operand.getValueType() &&
"Invalid ABS!");
if (OpOpcode == ISD::UNDEF)
- return getUNDEF(VT);
+ return getConstant(0, DL, VT);
break;
case ISD::BSWAP:
assert(VT.isInteger() && VT == Operand.getValueType() &&
-------------- next part --------------
A non-text attachment was scrubbed...
Name: D126174.431250.patch
Type: text/x-patch
Size: 1144 bytes
Desc: not available
URL: <http://lists.llvm.org/pipermail/llvm-commits/attachments/20220522/64693ca4/attachment.bin>
More information about the llvm-commits
mailing list