OSDN Git Service

{DAGCombiner] Fold (rot x, 0) -> x
authorSimon Pilgrim <llvm-dev@redking.me.uk>
Wed, 5 Jul 2017 18:27:11 +0000 (18:27 +0000)
committerSimon Pilgrim <llvm-dev@redking.me.uk>
Wed, 5 Jul 2017 18:27:11 +0000 (18:27 +0000)
git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@307184 91177308-0d34-0410-b5e6-96231b3b80d8

lib/CodeGen/SelectionDAG/DAGCombiner.cpp
test/CodeGen/X86/combine-rotates.ll

index 6fb5e39..7a34179 100644 (file)
@@ -5273,6 +5273,10 @@ SDValue DAGCombiner::visitRotate(SDNode *N) {
   SDValue N1 = N->getOperand(1);
   EVT VT = N->getValueType(0);
 
+  // fold (rot x, 0) -> x
+  if (isNullConstantOrNullSplatConstant(N1))
+    return N0;
+
   // fold (rot* x, (trunc (and y, c))) -> (rot* x, (and (trunc y), (trunc c))).
   if (N1.getOpcode() == ISD::TRUNCATE &&
       N1.getOperand(0).getOpcode() == ISD::AND) {
index 1bce1cf..713ee5d 100644 (file)
@@ -59,7 +59,6 @@ define <4 x i32> @combine_vec_rot_rot_splat(<4 x i32> %x) {
 define <4 x i32> @combine_vec_rot_rot_splat_zero(<4 x i32> %x) {
 ; XOP-LABEL: combine_vec_rot_rot_splat_zero:
 ; XOP:       # BB#0:
-; XOP-NEXT:    vprotd $0, %xmm0, %xmm0
 ; XOP-NEXT:    retq
 ;
 ; AVX512-LABEL: combine_vec_rot_rot_splat_zero: