[PATCH] D63963: [Codegen][SelectionDAG] X u% C == 0 fold: non-splat vector improvements
Roman Lebedev via Phabricator via llvm-commits
llvm-commits at lists.llvm.org
Sat Jun 29 02:49:53 PDT 2019
lebedev.ri added a comment.
It really bothered me, so here's alive proofs for powers-of-two:
$ ~/src/alive2/build-Clang-release/alive /tmp/test.ll
OMP: Info #270: omp_set_nested routine deprecated, please use omp_set_max_active_levels instead.
Processing /tmp/test.ll..
----------------------------------------
Name: power-of-two
%o0 = shl i16 1, %K ; so %o0 is a power-of-two
%o1 = urem i16 %X, %o0
%r = icmp eq i16 %o1, 0
=>
%o0 = shl i16 1, %K ; so %o0 is a power-of-two
%o1 = urem i16 %X, %o0
%n0 = mul i16 %X, 1 ; multiplicative inverse of d0=1 is 1
%n1 = fshr i16 %n0, %n0, %K
%n2 = udiv i16 -1, %o0
%r = icmp ule i16 %n1, %n2
Done: 1
Optimization is correct!
----------------------------------------
Name: power-of-two
%o0 = shl i16 1, %K ; so %o0 is a power-of-two
%o1 = urem i16 %X, %o0
%r = icmp ne i16 %o1, 0
=>
%o0 = shl i16 1, %K ; so %o0 is a power-of-two
%o1 = urem i16 %X, %o0
%n0 = mul i16 %X, 1 ; multiplicative inverse of d0=1 is 1
%n1 = fshr i16 %n0, %n0, %K
%n2 = udiv i16 -1, %o0
%r = icmp ugt i16 %n1, %n2
Done: 1
Optimization is correct!
----------------------------------------
Name: one
%o1 = urem i16 %X, 1
%r = icmp eq i16 %o1, 0
=>
%o1 = urem i16 %X, 1
%n0 = mul i16 %X, 0
%n1 = fshr i16 %n0, %n0, 0
%r = icmp ule i16 %n1, -1
Done: 1
Optimization is correct!
----------------------------------------
Name: one
%o1 = urem i16 %X, 1
%r = icmp ne i16 %o1, 0
=>
%o1 = urem i16 %X, 1
%n0 = mul i16 %X, 0
%n1 = fshr i16 %n0, %n0, 0
%r = icmp ugt i16 %n1, -1
Done: 1
Optimization is correct!
Repository:
rL LLVM
CHANGES SINCE LAST ACTION
https://reviews.llvm.org/D63963/new/
https://reviews.llvm.org/D63963
More information about the llvm-commits
mailing list