[llvm] f81151e - [InstCombine] add tests for diff-of-squares; NFC

Sanjay Patel via llvm-commits llvm-commits at lists.llvm.org
Wed Jan 18 05:13:45 PST 2023


Author: Sanjay Patel
Date: 2023-01-18T08:13:37-05:00
New Revision: f81151edbfa3d65acb9f84d6ef214da60495556a

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

LOG: [InstCombine] add tests for diff-of-squares; NFC

Ideally, these negative tests would have been added
before 68c197f07eea to make sure the specific
operand matching is working as expected, but I did
not remember to include them.

Added: 
    

Modified: 
    llvm/test/Transforms/InstCombine/sub.ll

Removed: 
    


################################################################################
diff  --git a/llvm/test/Transforms/InstCombine/sub.ll b/llvm/test/Transforms/InstCombine/sub.ll
index 120036a8cfa4..31a162f39e8d 100644
--- a/llvm/test/Transforms/InstCombine/sub.ll
+++ b/llvm/test/Transforms/InstCombine/sub.ll
@@ -2498,3 +2498,33 @@ define i8 @
diff _of_squares_use2(i8 %x, i8 %y) {
   %r = sub i8 %x2, %y2
   ret i8 %r
 }
+
+; negative test - must be squares
+
+define i8 @
diff _of_muls1(i8 %x, i8 %y, i8 %z) {
+; CHECK-LABEL: @
diff _of_muls1(
+; CHECK-NEXT:    [[M:%.*]] = mul i8 [[X:%.*]], [[Z:%.*]]
+; CHECK-NEXT:    [[Y2:%.*]] = mul i8 [[Y:%.*]], [[Y]]
+; CHECK-NEXT:    [[R:%.*]] = sub i8 [[M]], [[Y2]]
+; CHECK-NEXT:    ret i8 [[R]]
+;
+  %m = mul i8 %x, %z
+  %y2 = mul i8 %y, %y
+  %r = sub i8 %m, %y2
+  ret i8 %r
+}
+
+; negative test - must be squares
+
+define i8 @
diff _of_muls2(i8 %x, i8 %y, i8 %z) {
+; CHECK-LABEL: @
diff _of_muls2(
+; CHECK-NEXT:    [[X2:%.*]] = mul i8 [[X:%.*]], [[X]]
+; CHECK-NEXT:    [[M:%.*]] = mul i8 [[Y:%.*]], [[Z:%.*]]
+; CHECK-NEXT:    [[R:%.*]] = sub i8 [[X2]], [[M]]
+; CHECK-NEXT:    ret i8 [[R]]
+;
+  %x2 = mul i8 %x, %x
+  %m = mul i8 %y, %z
+  %r = sub i8 %x2, %m
+  ret i8 %r
+}


        


More information about the llvm-commits mailing list