[llvm] b899d13 - [NFC][InstCombine] Add tests for negation of freeze

Roman Lebedev via llvm-commits llvm-commits at lists.llvm.org
Sun Aug 23 13:28:47 PDT 2020


Author: Roman Lebedev
Date: 2020-08-23T23:28:19+03:00
New Revision: b899d13a0f157a43295d0906fe761d39c8cf467f

URL: https://github.com/llvm/llvm-project/commit/b899d13a0f157a43295d0906fe761d39c8cf467f
DIFF: https://github.com/llvm/llvm-project/commit/b899d13a0f157a43295d0906fe761d39c8cf467f.diff

LOG: [NFC][InstCombine] Add tests for negation of freeze

Added: 
    

Modified: 
    llvm/test/Transforms/InstCombine/sub-of-negatible.ll

Removed: 
    


################################################################################
diff  --git a/llvm/test/Transforms/InstCombine/sub-of-negatible.ll b/llvm/test/Transforms/InstCombine/sub-of-negatible.ll
index d0850107a567..01889eaf5643 100644
--- a/llvm/test/Transforms/InstCombine/sub-of-negatible.ll
+++ b/llvm/test/Transforms/InstCombine/sub-of-negatible.ll
@@ -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}


        


More information about the llvm-commits mailing list