InstCombine introduces unnecessary and 1
when folding trunc nuw
+zext
#134908
Labels
and 1
when folding trunc nuw
+zext
#134908
Rust in which we spotted this originally: https://rust.godbolt.org/z/Knr5jdEY5, cc rust-lang/rust#139098 (comment)
Take this input IR:
Today https://llvm.godbolt.org/z/vnfGGxfbr,
--passes=instcombine
transforms that toHowever it should not be adding that
and i8 %0, 1
-- thetrunc nuw
means it ought to know it doesn't need to do that.It should instead be emitting https://alive2.llvm.org/ce/z/oN3dig
Note that the correctness for this doesn't depend on the range information; removing that from the parameter it still validates https://alive2.llvm.org/ce/z/_ed2Ch.
(If you run a full -O2 or -O3 then CVP will get rid of the
and
, but that's not run in -O1. And InstCombine has the information it needs to do it correctly anyway, AFAICT, so it just should.)The text was updated successfully, but these errors were encountered: