From 4634a9ba1ef2805944ec429a2304b278d484cbf3 Mon Sep 17 00:00:00 2001 From: Robert Lougher Date: Tue, 15 Apr 2014 18:34:24 +0000 Subject: [PATCH] Revert r191049/r191059 as it can produce wrong code (see PR17975). It has already been reverted on the 3.4 branch in r196521. git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@206311 91177308-0d34-0410-b5e6-96231b3b80d8 --- lib/CodeGen/SelectionDAG/DAGCombiner.cpp | 21 ----- .../CodeGen/ARM64/regress-interphase-shift.ll | 4 + test/CodeGen/X86/rotate3.ll | 76 ------------------- 3 files changed, 4 insertions(+), 97 deletions(-) delete mode 100644 test/CodeGen/X86/rotate3.ll diff --git a/lib/CodeGen/SelectionDAG/DAGCombiner.cpp b/lib/CodeGen/SelectionDAG/DAGCombiner.cpp index f0c604de180..b6b0341dc93 100644 --- a/lib/CodeGen/SelectionDAG/DAGCombiner.cpp +++ b/lib/CodeGen/SelectionDAG/DAGCombiner.cpp @@ -3555,27 +3555,6 @@ SDNode *DAGCombiner::MatchRotatePosNeg(SDValue Shifted, SDValue Pos, HasPos ? Pos : Neg).getNode(); } - // fold (or (shl (*ext x), (*ext y)), - // (srl (*ext x), (*ext (sub 32, y)))) -> - // (*ext (rotl x, y)) or (*ext (rotr x, (sub 32, y))) - // - // fold (or (shl (*ext x), (*ext (sub 32, y))), - // (srl (*ext x), (*ext y))) -> - // (*ext (rotr x, y)) or (*ext (rotl x, (sub 32, y))) - if (Shifted.getOpcode() == ISD::ZERO_EXTEND || - Shifted.getOpcode() == ISD::ANY_EXTEND) { - SDValue InnerShifted = Shifted.getOperand(0); - EVT InnerVT = InnerShifted.getValueType(); - bool HasPosInner = TLI.isOperationLegalOrCustom(PosOpcode, InnerVT); - if (HasPosInner || TLI.isOperationLegalOrCustom(NegOpcode, InnerVT)) { - if (matchRotateSub(InnerPos, InnerNeg, InnerVT.getSizeInBits())) { - SDValue V = DAG.getNode(HasPosInner ? PosOpcode : NegOpcode, DL, - InnerVT, InnerShifted, HasPosInner ? Pos : Neg); - return DAG.getNode(Shifted.getOpcode(), DL, VT, V).getNode(); - } - } - } - return nullptr; } diff --git a/test/CodeGen/ARM64/regress-interphase-shift.ll b/test/CodeGen/ARM64/regress-interphase-shift.ll index fddf59195dd..fec89334801 100644 --- a/test/CodeGen/ARM64/regress-interphase-shift.ll +++ b/test/CodeGen/ARM64/regress-interphase-shift.ll @@ -4,6 +4,10 @@ ; on the phase of legalization, which led to the creation of an unexpected and ; unselectable "rotr" node: (i32 (rotr i32, i64)). +; FIXME: This test is xfailed because it relies on an optimization that has +; been reverted (see PR17975). +; XFAIL: * + define void @foo(i64* nocapture %d) { ; CHECK-LABEL: foo: ; CHECK: rorv diff --git a/test/CodeGen/X86/rotate3.ll b/test/CodeGen/X86/rotate3.ll deleted file mode 100644 index b92f7c2a60a..00000000000 --- a/test/CodeGen/X86/rotate3.ll +++ /dev/null @@ -1,76 +0,0 @@ -; Check that (or (shl x, y), (srl x, (sub 32, y))) is folded into (rotl x, y) -; and (or (shl x, (sub 32, y)), (srl x, r)) into (rotr x, y) even if the -; argument is zero extended. Fix for PR16726. - -; RUN: llc < %s -march=x86-64 -mcpu=corei7 | FileCheck %s - -define zeroext i8 @rolbyte(i32 %nBits_arg, i8 %x_arg) nounwind readnone { -entry: - %tmp1 = zext i8 %x_arg to i32 - %tmp3 = shl i32 %tmp1, %nBits_arg - %tmp8 = sub i32 8, %nBits_arg - %tmp10 = lshr i32 %tmp1, %tmp8 - %tmp11 = or i32 %tmp3, %tmp10 - %tmp12 = trunc i32 %tmp11 to i8 - ret i8 %tmp12 -} -; CHECK: rolb %cl, %{{[a-z0-9]+}} - - -define zeroext i8 @rorbyte(i32 %nBits_arg, i8 %x_arg) nounwind readnone { -entry: - %tmp1 = zext i8 %x_arg to i32 - %tmp3 = lshr i32 %tmp1, %nBits_arg - %tmp8 = sub i32 8, %nBits_arg - %tmp10 = shl i32 %tmp1, %tmp8 - %tmp11 = or i32 %tmp3, %tmp10 - %tmp12 = trunc i32 %tmp11 to i8 - ret i8 %tmp12 -} -; CHECK: rorb %cl, %{{[a-z0-9]+}} - -define zeroext i16 @rolword(i32 %nBits_arg, i16 %x_arg) nounwind readnone { -entry: - %tmp1 = zext i16 %x_arg to i32 - %tmp3 = shl i32 %tmp1, %nBits_arg - %tmp8 = sub i32 16, %nBits_arg - %tmp10 = lshr i32 %tmp1, %tmp8 - %tmp11 = or i32 %tmp3, %tmp10 - %tmp12 = trunc i32 %tmp11 to i16 - ret i16 %tmp12 -} -; CHECK: rolw %cl, %{{[a-z0-9]+}} - -define zeroext i16 @rorword(i32 %nBits_arg, i16 %x_arg) nounwind readnone { -entry: - %tmp1 = zext i16 %x_arg to i32 - %tmp3 = lshr i32 %tmp1, %nBits_arg - %tmp8 = sub i32 16, %nBits_arg - %tmp10 = shl i32 %tmp1, %tmp8 - %tmp11 = or i32 %tmp3, %tmp10 - %tmp12 = trunc i32 %tmp11 to i16 - ret i16 %tmp12 -} -; CHECK: rorw %cl, %{{[a-z0-9]+}} - -define i64 @roldword(i64 %nBits_arg, i32 %x_arg) nounwind readnone { -entry: - %tmp1 = zext i32 %x_arg to i64 - %tmp3 = shl i64 %tmp1, %nBits_arg - %tmp8 = sub i64 32, %nBits_arg - %tmp10 = lshr i64 %tmp1, %tmp8 - %tmp11 = or i64 %tmp3, %tmp10 - ret i64 %tmp11 -} -; CHECK: roll %cl, %{{[a-z0-9]+}} - -define zeroext i64 @rordword(i64 %nBits_arg, i32 %x_arg) nounwind readnone { -entry: - %tmp1 = zext i32 %x_arg to i64 - %tmp3 = lshr i64 %tmp1, %nBits_arg - %tmp8 = sub i64 32, %nBits_arg - %tmp10 = shl i64 %tmp1, %tmp8 - %tmp11 = or i64 %tmp3, %tmp10 - ret i64 %tmp11 -} -; CHECK: rorl %cl, %{{[a-z0-9]+}}