[llvm] [ValueTracking] Try to infer range of select from true and false values. (PR #68256)

Mikhail Gudim via llvm-commits llvm-commits at lists.llvm.org
Thu Oct 5 07:08:51 PDT 2023


================
@@ -0,0 +1,15 @@
+; RUN: opt < %s -aa-pipeline=basic-aa -passes=aa-eval -print-all-alias-modref-info -disable-output 2>&1 | FileCheck %s
+
+ at a = dso_local local_unnamed_addr global [10 x i32] zeroinitializer, align 4
+
+; CHECK-LABEL: Function: select_in_gep
+; CHECK: NoAlias: i32* %arrayidx, i32* getelementptr inbounds ([10 x i32], ptr @a, i64 0, i64 3)
+define i32 @select_in_gep(i1 %c)  {
+entry:
+  %cond = select i1 %c, i64 2, i64 1
+  %0 = load i32, ptr getelementptr inbounds ([10 x i32], ptr @a, i64 0, i64 3), align 4
----------------
mgudim wrote:

Done. I had it to demonstrate that without my patch optimizer can't remove the second load.

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


More information about the llvm-commits mailing list