[all-commits] [llvm/llvm-project] 248fca: [InstCombine] Do not use operand info in `replace...
Yingwei Zheng via All-commits
all-commits at lists.llvm.org
Sun Jul 21 21:00:16 PDT 2024
Branch: refs/heads/main
Home: https://github.com/llvm/llvm-project
Commit: 248fcab2fc9b3fc1bde5cd5b1fe8615791225c9e
https://github.com/llvm/llvm-project/commit/248fcab2fc9b3fc1bde5cd5b1fe8615791225c9e
Author: Yingwei Zheng <dtcxzyw2333 at gmail.com>
Date: 2024-07-22 (Mon, 22 Jul 2024)
Changed paths:
M llvm/include/llvm/Analysis/ValueTracking.h
M llvm/lib/Analysis/ValueTracking.cpp
M llvm/lib/Transforms/InstCombine/InstCombineSelect.cpp
M llvm/test/Transforms/InstCombine/select-binop-cmp.ll
M llvm/test/Transforms/InstCombine/select.ll
Log Message:
-----------
[InstCombine] Do not use operand info in `replaceInInstruction` (#99492)
Consider the following case:
```
%cmp = icmp eq ptr %p, null
%load = load i32, ptr %p, align 4
%sel = select i1 %cmp, i32 %load, i32 0
```
`foldSelectValueEquivalence` converts `load i32, ptr %p, align 4` into
`load i32, ptr null, align 4`, which causes immediate UB. `%load` is
speculatable, but it doesn't hold after operand substitution.
This patch introduces a new helper
`isSafeToSpeculativelyExecuteWithVariableReplaced`. It ignores operand
info in these instructions since their operands will be replaced later.
Fixes #99436.
---------
Co-authored-by: Nikita Popov <github at npopov.com>
To unsubscribe from these emails, change your notification settings at https://github.com/llvm/llvm-project/settings/notifications
More information about the All-commits
mailing list