[PATCH] D60426: [InstCombine] prevent possible miscompile with negate+sdiv of vector op
Roman Lebedev via Phabricator via llvm-commits
llvm-commits at lists.llvm.org
Mon Apr 8 23:13:02 PDT 2019
lebedev.ri accepted this revision.
lebedev.ri added a comment.
This LG, thank you!
In D60426#1459186 <https://reviews.llvm.org/D60426#1459186>, @shchenz wrote:
> LGTM for this patch.
>
> But should we also consider about the following pattern in file `test/Transforms/InstCombine/div.ll`
>
> define <2 x i64> @test34(<2 x i64> %x) {
> ; CHECK-LABEL: @test34(
> ; CHECK-NEXT: [[DIV:%.*]] = sdiv exact <2 x i64> [[X:%.*]], <i64 -3, i64 -4>
> ; CHECK-NEXT: ret <2 x i64> [[DIV]]
> ;
> %neg = sub nsw <2 x i64> zeroinitializer, %x
> %div = sdiv exact <2 x i64> %neg, <i64 3, i64 4>
> ret <2 x i64> %div
> }
>
>
> This one is `sdiv (neg(%x), constant)`, it should have same issue, right? But I think this should be another issue about `sdiv` combination?
Yes, that seems to have the same general problem.
https://godbolt.org/z/vPVHmh
================
Comment at: llvm/test/Transforms/InstCombine/div.ll:820
;
%div = sdiv <2 x i8> %x, <i8 -1, i8 1>
%neg = sub <2 x i8> zeroinitializer, %div
----------------
Could also add a test for SINT_MIN (yes, i have seen the next test here)
CHANGES SINCE LAST ACTION
https://reviews.llvm.org/D60426/new/
https://reviews.llvm.org/D60426
More information about the llvm-commits
mailing list