[PATCH] D48930: [InstCombine] Apply foldICmpUsingKnownBits to early bailout case
Sanjay Patel via Phabricator via llvm-commits
llvm-commits at lists.llvm.org
Wed Jul 4 08:23:16 PDT 2018
spatel added a comment.
Bailing out on optimizations is a hack, so I'd prefer not to perpetuate that.
I have no context for this patch other than the one test case shown here. I see 2 potential missing folds that would solve that case (and I suspect that we actually have these folds but they are again guarded by min/max bailout hacks):
https://rise4fun.com/Alive/Pe9U
Name: narrow min/max in instcombine
%z = zext i16 %x to i32
%c = icmp ult i32 %z, 255
%s = select i1 %c, i32 %z, i32 255
%t = trunc i32 %s to i16
=>
%c2 = icmp ult i16 %x, 255
%t = select i1 %c2, i16 %x, i16 255
Name: fold min/max in instsimplify
%a = and i16 %x, 255
%z = zext i16 %a to i32
%c = icmp ult i32 %z, 255
%s = select i1 %c, i32 %z, i32 255
=>
%s = %z
Can we add/fix one of those folds instead of trying to solve this in visitICmpInst()?
https://reviews.llvm.org/D48930
More information about the llvm-commits
mailing list