@@ -710,7 +710,7 @@ void HWConformity::fixImmAndARFSrc(INST_LIST_ITER it, G4_BB *bb)
710
710
src2 = inst->getSrc (2 );
711
711
712
712
/* Check for usage of two constants in binary operations */
713
- if (src0 != NULL && (src0->isImm () || src0->isAddrExp ()) && inst->getNumSrc () == 2 )
713
+ if (src0 && (src0->isImm () || src0->isAddrExp ()) && inst->getNumSrc () == 2 )
714
714
{
715
715
if (INST_COMMUTATIVE (inst->opcode ()) && !src1->isImm ())
716
716
{
@@ -753,26 +753,18 @@ void HWConformity::fixImmAndARFSrc(INST_LIST_ITER it, G4_BB *bb)
753
753
*/
754
754
else if (inst->opcode () == G4_sel && !src1->isImm ())
755
755
{
756
- bool SwapOpnd = false ;
757
756
G4_CondMod *cond = inst->getCondMod ();
758
- if (cond != NULL )
757
+ if (cond)
759
758
{
760
759
switch (cond->getMod ())
761
760
{
762
761
case Mod_ne:
763
- {
764
762
inst->setCondMod (builder.createCondMod (Mod_e, cond->getBase (), 0 ));
765
- SwapOpnd = true ;
766
763
break ;
767
- }
768
764
case Mod_e:
769
- {
770
765
inst->setCondMod (builder.createCondMod (Mod_ne, cond->getBase (), 0 ));
771
- SwapOpnd = true ;
772
766
break ;
773
- }
774
767
default :
775
- SwapOpnd = true ;
776
768
break ;
777
769
}
778
770
}
@@ -783,21 +775,10 @@ void HWConformity::fixImmAndARFSrc(INST_LIST_ITER it, G4_BB *bb)
783
775
G4_PredState reverse = pred->getState () == PredState_Minus ? PredState_Plus : PredState_Minus;
784
776
inst->setPredicate (builder.createPredicate (
785
777
reverse, pred->getBase (), pred->getSubRegOff (), pred->getControl ()));
786
- SwapOpnd = true ;
787
- }
788
-
789
- if (SwapOpnd)
790
- {
791
- inst->setSrc (src1, 0 );
792
- inst->setSrc (src0, 1 );
793
- inst->swapDefUse ();
794
- }
795
- else
796
- {
797
- G4_Type tmpType = getNonVectorType (src0->getType ());
798
- G4_Operand* newSrc0 = insertMovBefore (it, 0 , tmpType, bb);
799
- inst->setSrc (newSrc0, 0 );
800
778
}
779
+ inst->setSrc (src1, 0 );
780
+ inst->setSrc (src0, 1 );
781
+ inst->swapDefUse ();
801
782
}
802
783
else if (!inst->isMath ())
803
784
{
@@ -823,6 +804,7 @@ void HWConformity::fixImmAndARFSrc(INST_LIST_ITER it, G4_BB *bb)
823
804
{
824
805
newSrc = builder.createImmWithLowerType (res, resultType);
825
806
807
+ // change instruction into a MOV
826
808
// change instruction into a MOV
827
809
inst->setOpcode (G4_mov);
828
810
inst->setSrc (newSrc, 0 );
@@ -841,7 +823,9 @@ void HWConformity::fixImmAndARFSrc(INST_LIST_ITER it, G4_BB *bb)
841
823
inst->swapDefUse ();
842
824
src0 = inst->getSrc (0 );
843
825
src1 = inst->getSrc (1 );
826
+ // this needs to fall through as we still need move for src0
844
827
}
828
+
845
829
if (INST_COMMUTATIVE (inst->opcode ()) && src0->isAddrExp () && src1->isImm ())
846
830
{
847
831
// The original IR has both addr expr and immediate
@@ -862,7 +846,8 @@ void HWConformity::fixImmAndARFSrc(INST_LIST_ITER it, G4_BB *bb)
862
846
}
863
847
else
864
848
{
865
- G4_Type newSrcType = inst->needsDWType () ? (IS_UNSIGNED_INT (src0->getType ()) ? Type_UD : Type_D) : src0->getType ();
849
+ G4_Type newSrcType = inst->needsDWType () ? (IS_UNSIGNED_INT (src0->getType ()) ? Type_UD : Type_D) :
850
+ getNonVectorType (src0->getType ());
866
851
inst->setSrc (insertMovBefore (it, 0 , newSrcType, bb), 0 );
867
852
}
868
853
}
0 commit comments