1 ; NOTE: Assertions have been autogenerated by utils/update_test_checks.py
2 ; RUN: opt < %s -reassociate -instcombine -S | FileCheck %s
4 ; Test that we can turn things like X*-(Y*Z) -> X*-1*Y*Z.
6 define i32 @test1(i32 %a, i32 %b, i32 %z) {
8 ; CHECK-NEXT: [[E:%.*]] = mul i32 [[A:%.*]], 12345
9 ; CHECK-NEXT: [[F:%.*]] = mul i32 [[E]], [[B:%.*]]
10 ; CHECK-NEXT: [[G:%.*]] = mul i32 [[F]], [[Z:%.*]]
11 ; CHECK-NEXT: ret i32 [[G]]
16 %f = mul i32 %e, 12345
21 define i32 @test2(i32 %a, i32 %b, i32 %z) {
22 ; CHECK-LABEL: @test2(
23 ; CHECK-NEXT: [[E:%.*]] = mul i32 [[A:%.*]], 40
24 ; CHECK-NEXT: [[F:%.*]] = mul i32 [[E]], [[Z:%.*]]
25 ; CHECK-NEXT: ret i32 [[F]]
34 define <2 x i32> @negate_vec_undefs(<2 x i32> %a, <2 x i32> %b, <2 x i32> %z) {
35 ; CHECK-LABEL: @negate_vec_undefs(
36 ; CHECK-NEXT: [[E:%.*]] = mul <2 x i32> [[A:%.*]], <i32 40, i32 40>
37 ; CHECK-NEXT: [[F:%.*]] = mul <2 x i32> [[E]], [[Z:%.*]]
38 ; CHECK-NEXT: ret <2 x i32> [[F]]
40 %d = mul <2 x i32> %z, <i32 40, i32 40>
41 %c = sub <2 x i32> <i32 0, i32 undef>, %d
42 %e = mul <2 x i32> %a, %c
43 %f = sub <2 x i32> <i32 0, i32 undef>, %e