[llvm] [SDAG] Freeze condition in select of load fold (PR #208683)
Nikita Popov via llvm-commits
llvm-commits at lists.llvm.org
Fri Jul 10 05:48:39 PDT 2026
================
@@ -0,0 +1,21 @@
+; NOTE: Assertions have been autogenerated by utils/update_llc_test_checks.py UTC_ARGS: --version 6
+; RUN: llc -mtriple=x86_64-unknown-linux-gnu < %s | FileCheck %s
+
+; Make sure there is an and 1, otherwise a case where the select condition
+; was poison could result in an out of bounds read instead.
+define i32 @test(i32 %x, ptr %p) {
+; CHECK-LABEL: test:
+; CHECK: # %bb.0:
+; CHECK-NEXT: # kill: def $edi killed $edi def $rdi
+; CHECK-NEXT: andl $1, %edi
+; CHECK-NEXT: movl 4(%rsi,%rdi,4), %eax
+; CHECK-NEXT: retq
+ %p1 = getelementptr i8, ptr %p, i64 4
+ %v1 = load i32, ptr %p1
+ %p2 = getelementptr i8, ptr %p, i64 8
+ %v2 = load i32, ptr %p2
+ %c = trunc nuw i32 %x to i1
+ %v = select i1 %c, i32 %v2, i32 %v1
+ %res = freeze i32 %v
----------------
nikic wrote:
Nope, I dropped it.
https://github.com/llvm/llvm-project/pull/208683
More information about the llvm-commits
mailing list