[llvm] [FuncSpec] Improve handling of Comparison Instructions (PR #114073)

David Sherwood via llvm-commits llvm-commits at lists.llvm.org
Wed Oct 30 08:16:58 PDT 2024


================
@@ -0,0 +1,74 @@
+; NOTE: Assertions have been autogenerated by utils/update_test_checks.py UTC_ARGS: --include-generated-funcs --version 5
+; RUN: opt -passes="ipsccp<func-spec>" -funcspec-min-function-size=1       \
+; RUN:                                 -funcspec-for-literal-constant=true \
+; RUN:                                 -funcspec-min-codesize-savings=50   \
+; RUN:                                 -funcspec-min-latency-savings=0     \
+; RUN:                                 -S < %s | FileCheck %s
+
+; Verify that we are able to estimate the codesize savings arising from a branch
+; based on a comparison with a value found to have a constant range by IPSCCP.
+define i32 @main() {
+  %notspec = call i32 @test(i32 8)
+  %spec = call i32 @test(i32 0)
+  %sum = add i32 %notspec, %spec
+  ret i32 %sum
+}
+
+define i32 @test(i32 %x) {
+entry:
+  %range = call i32 @foo(), !range !{ i32 1, i32 0 }
+  %bound = shl nsw nuw i32 %range, 3
+  %cmp = icmp uge i32 %x, %bound
----------------
david-arm wrote:

Is it worth also having a test where `%x` is on the RHS so that we're testing the new code you've added?

https://github.com/llvm/llvm-project/pull/114073


More information about the llvm-commits mailing list