[llvm] [FuncSpec] Improve handling of Comparison Instructions (PR #114073)
Hari Limaye via llvm-commits
llvm-commits at lists.llvm.org
Wed Oct 30 10:01:43 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
----------------
hazzlim wrote:
Good idea - I've added a test which exercises the case where the Const use is on the RHS, and also where the argument is not used directly in the condition.
https://github.com/llvm/llvm-project/pull/114073
More information about the llvm-commits
mailing list