[llvm] r332703 - [SystemZ] Fold AHIMux in foldMemoryOperandImpl.
Jonas Paulsson via llvm-commits
llvm-commits at lists.llvm.org
Fri May 18 04:54:04 PDT 2018
Author: jonpa
Date: Fri May 18 04:54:04 2018
New Revision: 332703
URL: http://llvm.org/viewvc/llvm-project?rev=332703&view=rev
Log:
[SystemZ] Fold AHIMux in foldMemoryOperandImpl.
AHIMux can be folded the same way as AHI.
Review: Ulrich Weigand
Added:
llvm/trunk/test/CodeGen/SystemZ/selectcc-04.ll
Modified:
llvm/trunk/lib/Target/SystemZ/SystemZISelDAGToDAG.cpp
Modified: llvm/trunk/lib/Target/SystemZ/SystemZISelDAGToDAG.cpp
URL: http://llvm.org/viewvc/llvm-project/llvm/trunk/lib/Target/SystemZ/SystemZISelDAGToDAG.cpp?rev=332703&r1=332702&r2=332703&view=diff
==============================================================================
--- llvm/trunk/lib/Target/SystemZ/SystemZISelDAGToDAG.cpp (original)
+++ llvm/trunk/lib/Target/SystemZ/SystemZISelDAGToDAG.cpp Fri May 18 04:54:04 2018
@@ -1509,7 +1509,13 @@ void SystemZDAGToDAGISel::Select(SDNode
CCMask = CurDAG->getConstant(ConstCCValid ^ ConstCCMask, SDLoc(Node),
CCMask.getValueType());
SDValue Op4 = Node->getOperand(4);
- Node = CurDAG->UpdateNodeOperands(Node, Op1, Op0, CCValid, CCMask, Op4);
+ SDNode *UpdatedNode =
+ CurDAG->UpdateNodeOperands(Node, Op1, Op0, CCValid, CCMask, Op4);
+ if (UpdatedNode != Node) {
+ // In case this node already exists, replace Node with it.
+ ReplaceNode(Node, UpdatedNode);
+ Node = UpdatedNode;
+ }
}
break;
}
Added: llvm/trunk/test/CodeGen/SystemZ/selectcc-04.ll
URL: http://llvm.org/viewvc/llvm-project/llvm/trunk/test/CodeGen/SystemZ/selectcc-04.ll?rev=332703&view=auto
==============================================================================
--- llvm/trunk/test/CodeGen/SystemZ/selectcc-04.ll (added)
+++ llvm/trunk/test/CodeGen/SystemZ/selectcc-04.ll Fri May 18 04:54:04 2018
@@ -0,0 +1,38 @@
+; This function contains two selects which differ only by having reversed
+; operand order. They are in fact equivalent, since the icmps that preceede
+; them also are the same except for reversed conditions. SelectionDAG will
+; discover this and return the other SELECT_CCMASK when the operands are
+; canonicalized. This must be handled by SystemZDAGToDAGISel::Select, or
+; instruction selection will fail.
+;
+; RUN: llc < %s -mtriple=s390x-linux-gnu -mcpu=z13
+
+
+ at g_1531 = external global [7 x i64], align 8
+ at g_277 = external global <{ i64, i8, i8, i8, i8, i8, i8 }>, align 8
+ at g_62.6 = external global i32, align 4
+
+define dso_local void @fun() {
+entry:
+ %tmp = add nuw nsw i16 0, 238
+ %tmp4 = sub nsw i16 %tmp, 0
+ store i64 4, i64* getelementptr inbounds (<{ i64, i8, i8, i8, i8, i8, i8 }>, <{ i64, i8, i8, i8, i8, i8, i8 }>* @g_277, i64 0, i32 0), align 8
+ %tmp5 = load i64, i64* getelementptr inbounds ([7 x i64], [7 x i64]* @g_1531, i64 0, i64 5), align 8
+ %tmp6 = trunc i64 %tmp5 to i32
+ %tmp7 = trunc i64 %tmp5 to i16
+ %tmp8 = shl i32 %tmp6, 24
+ %tmp9 = ashr exact i32 %tmp8, 24
+ %tmp10 = urem i16 %tmp7, %tmp4
+ %tmp11 = icmp eq i16 %tmp10, 0
+ %tmp12 = select i1 %tmp11, i32 0, i32 %tmp9
+ %tmp13 = icmp sge i32 %tmp12, undef
+ %tmp14 = zext i1 %tmp13 to i32
+ %tmp15 = or i32 0, %tmp14
+ %tmp16 = icmp ne i16 %tmp10, 0
+ %tmp17 = select i1 %tmp16, i32 %tmp9, i32 0
+ %tmp18 = icmp sge i32 %tmp17, undef
+ %tmp19 = zext i1 %tmp18 to i32
+ %tmp20 = or i32 %tmp15, %tmp19
+ store i32 %tmp20, i32* @g_62.6, align 4
+ unreachable
+}
More information about the llvm-commits
mailing list