[NFC][InstCombine] Add tests for negation of freeze
authorRoman Lebedev <lebedev.ri@gmail.com>
Sun, 23 Aug 2020 19:48:16 +0000 (22:48 +0300)
committerRoman Lebedev <lebedev.ri@gmail.com>
Sun, 23 Aug 2020 20:28:19 +0000 (23:28 +0300)
llvm/test/Transforms/InstCombine/sub-of-negatible.ll

index d085010..01889ea 100644 (file)
@@ -1211,5 +1211,33 @@ define i8 @dont_negate_ordinary_select(i8 %x, i8 %y, i8 %z, i1 %c) {
   ret i8 %t1
 }
 
+; Freeze is transparent as far as negation is concerned
+define i4 @negate_freeze(i4 %x, i4 %y, i4 %z) {
+; CHECK-LABEL: @negate_freeze(
+; CHECK-NEXT:    [[T0:%.*]] = sub i4 [[X:%.*]], [[Y:%.*]]
+; CHECK-NEXT:    [[T1:%.*]] = freeze i4 [[T0]]
+; CHECK-NEXT:    [[T2:%.*]] = sub i4 [[Z:%.*]], [[T1]]
+; CHECK-NEXT:    ret i4 [[T2]]
+;
+  %t0 = sub i4 %x, %y
+  %t1 = freeze i4 %t0
+  %t2 = sub i4 %z, %t1
+  ret i4 %t2
+}
+define i4 @negate_freeze_extrause(i4 %x, i4 %y, i4 %z) {
+; CHECK-LABEL: @negate_freeze_extrause(
+; CHECK-NEXT:    [[T0:%.*]] = sub i4 [[X:%.*]], [[Y:%.*]]
+; CHECK-NEXT:    [[T1:%.*]] = freeze i4 [[T0]]
+; CHECK-NEXT:    call void @use4(i4 [[T1]])
+; CHECK-NEXT:    [[T2:%.*]] = sub i4 [[Z:%.*]], [[T1]]
+; CHECK-NEXT:    ret i4 [[T2]]
+;
+  %t0 = sub i4 %x, %y
+  %t1 = freeze i4 %t0
+  call void @use4(i4 %t1)
+  %t2 = sub i4 %z, %t1
+  ret i4 %t2
+}
+
 ; CHECK: !0 = !{!"branch_weights", i32 40, i32 1}
 !0 = !{!"branch_weights", i32 40, i32 1}