[llvm] [FuncSpec] Enable SpecializeLiteralConstant by default (PR #113442)

Hari Limaye via llvm-commits llvm-commits at lists.llvm.org
Thu Oct 24 16:06:34 PDT 2024


================
@@ -0,0 +1,147 @@
+; NOTE: Assertions have been autogenerated by utils/update_test_checks.py UTC_ARGS: --include-generated-funcs --version 5
+; RUN: opt -passes="ipsccp<func-spec>" -force-specialization \
+; RUN:     -funcspec-max-iters=3 -S < %s | FileCheck %s
+
+; RUN: opt -passes="ipsccp<func-spec>" -force-specialization          \
+; RUN:     -funcspec-for-literal-constant=false -funcspec-max-iters=3 \
+; RUN:     -S < %s | FileCheck %s --check-prefix=NOLIT
+
+ at global_true = constant i1 true
+ at global_false = constant i1 false
+
+define i64 @main() {
+entry:
+  %binop1 = call ptr @select_binop(ptr @global_true)
+  %binop2 = call ptr @select_binop(ptr @global_false)
+
+  %c1 = call i64 @compute(ptr %binop1)
+  %c2 = call i64 @compute(ptr %binop2)
+  %add = add i64 %c1, %c2
+  ret i64 %add
+}
+
+define ptr @select_binop(ptr %flag) {
+  %flag.val = load i1, ptr %flag
+  %binop = select i1 %flag.val, ptr @plus, ptr @minus
+  ret ptr %binop
+}
+
+define internal i64 @compute(ptr %binop) {
+entry:
+  %res = call i64 %binop(i64 1, i64 1)
----------------
hazzlim wrote:

Sorry yes this was accidental - fixed.

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


More information about the llvm-commits mailing list