[PATCH] D64713: [InstCombine] X *fast (C ? 1.0 : 0.0) -> C ? X : 0.0
Roman Lebedev via Phabricator via llvm-commits
llvm-commits at lists.llvm.org
Mon Jul 29 07:55:12 PDT 2019
lebedev.ri added a comment.
In D64713#1604369 <https://reviews.llvm.org/D64713#1604369>, @xbolva00 wrote:
> Do we miss int version of this? @spatel @lebedev.ri
>
> int foo(int x, int y, bool b) {
> return x / (b ? 1 : y);
> }
>
>
> We have sdiv x, (select b 1 y), x86-64:
> cmov...
> idiv...
I'd agree that having `select %b (div %x, %y), %x` would be better but that does not look like a valid transform:
https://godbolt.org/z/4Fs_dB
https://rise4fun.com/Alive/xplW
Optimization: D64713-int
ERROR: Domain of definedness of Target is smaller than Source's for i32 %r
Example:
%b i1 = 0x1 (1, -1)
%y i32 = poison
%x i32 = poison
%cond i32 = 0x00000001 (1)
%t0 i32 = UB
Source value: poison
Target value: UB
$ /repositories/alive2/build-Clang-unknown/alive -root-only /tmp/test.ll
Processing /tmp/test.ll..
----------------------------------------
Name: D64713-int
%cond = select i1 %b, i8 1, i8 %y
%r = sdiv i8 %x, %cond
ret i8 %r
=>
%cond = select i1 %b, i8 1, i8 %y
%t0 = sdiv i8 %x, %y
%r = select i1 %b, i8 %x, i8 %t0
ret i8 %r
ERROR: Source is more defined than target
Example:
i1 %b = #x1 (1)
i8 %y = poison
i8 %x = poison
Source:
i8 %cond = #x01 (1)
i8 %r = poison
Target:
i8 %cond = #x01 (1)
i8 %t0 = poison
i8 %r = poison
Repository:
rG LLVM Github Monorepo
CHANGES SINCE LAST ACTION
https://reviews.llvm.org/D64713/new/
https://reviews.llvm.org/D64713
More information about the llvm-commits
mailing list