[llvm] r345034 - [InstCombine] swap select profile metadata when swapping select ops

Sanjay Patel via llvm-commits llvm-commits at lists.llvm.org
Tue Oct 23 07:43:31 PDT 2018


Author: spatel
Date: Tue Oct 23 07:43:31 2018
New Revision: 345034

URL: http://llvm.org/viewvc/llvm-project?rev=345034&view=rev
Log:
[InstCombine] swap select profile metadata when swapping select ops

Modified:
    llvm/trunk/lib/Transforms/InstCombine/InstCombineSelect.cpp
    llvm/trunk/test/Transforms/InstCombine/select_meta.ll

Modified: llvm/trunk/lib/Transforms/InstCombine/InstCombineSelect.cpp
URL: http://llvm.org/viewvc/llvm-project/llvm/trunk/lib/Transforms/InstCombine/InstCombineSelect.cpp?rev=345034&r1=345033&r2=345034&view=diff
==============================================================================
--- llvm/trunk/lib/Transforms/InstCombine/InstCombineSelect.cpp (original)
+++ llvm/trunk/lib/Transforms/InstCombine/InstCombineSelect.cpp Tue Oct 23 07:43:31 2018
@@ -1993,6 +1993,7 @@ Instruction *InstCombiner::visitSelectIn
     SI.setOperand(0, BinaryOperator::getNotArgument(CondVal));
     SI.setOperand(1, FalseVal);
     SI.setOperand(2, TrueVal);
+    SI.swapProfMetadata();
     return &SI;
   }
 

Modified: llvm/trunk/test/Transforms/InstCombine/select_meta.ll
URL: http://llvm.org/viewvc/llvm-project/llvm/trunk/test/Transforms/InstCombine/select_meta.ll?rev=345034&r1=345033&r2=345034&view=diff
==============================================================================
--- llvm/trunk/test/Transforms/InstCombine/select_meta.ll (original)
+++ llvm/trunk/test/Transforms/InstCombine/select_meta.ll Tue Oct 23 07:43:31 2018
@@ -298,11 +298,11 @@ define i32 @umax2(i32 %x) {
   ret i32 %sel
 }
 
-; FIXME: The condition is inverted, and the select ops are swapped. The metadata should be swapped.
+; The condition is inverted, and the select ops are swapped. The metadata should be swapped.
 
 define i32 @not_cond(i1 %c, i32 %tv, i32 %fv) {
 ; CHECK-LABEL: @not_cond(
-; CHECK-NEXT:    [[R:%.*]] = select i1 [[C:%.*]], i32 [[FV:%.*]], i32 [[TV:%.*]], !prof ![[$MD1]]
+; CHECK-NEXT:    [[R:%.*]] = select i1 [[C:%.*]], i32 [[FV:%.*]], i32 [[TV:%.*]], !prof ![[$MD3]]
 ; CHECK-NEXT:    ret i32 [[R]]
 ;
   %notc = xor i1 %c, true
@@ -310,11 +310,11 @@ define i32 @not_cond(i1 %c, i32 %tv, i32
   ret i32 %r
 }
 
-; FIXME: The condition is inverted, and the select ops are swapped. The metadata should be swapped.
+; The condition is inverted, and the select ops are swapped. The metadata should be swapped.
 
 define <2 x i32> @not_cond_vec(<2 x i1> %c, <2 x i32> %tv, <2 x i32> %fv) {
 ; CHECK-LABEL: @not_cond_vec(
-; CHECK-NEXT:    [[R:%.*]] = select <2 x i1> [[C:%.*]], <2 x i32> [[FV:%.*]], <2 x i32> [[TV:%.*]], !prof ![[$MD1]]
+; CHECK-NEXT:    [[R:%.*]] = select <2 x i1> [[C:%.*]], <2 x i32> [[FV:%.*]], <2 x i32> [[TV:%.*]], !prof ![[$MD3]]
 ; CHECK-NEXT:    ret <2 x i32> [[R]]
 ;
   %notc = xor <2 x i1> %c, <i1 true, i1 true>
@@ -323,7 +323,7 @@ define <2 x i32> @not_cond_vec(<2 x i1>
 }
 
 ; FIXME: Should match vector 'not' with undef element. After that...
-; FIXME: The condition is inverted, and the select ops are swapped. The metadata should be swapped.
+; The condition is inverted, and the select ops are swapped. The metadata should be swapped.
 
 define <2 x i32> @not_cond_vec_undef(<2 x i1> %c, <2 x i32> %tv, <2 x i32> %fv) {
 ; CHECK-LABEL: @not_cond_vec_undef(




More information about the llvm-commits mailing list